Jump to content

GreDeviceCreatePalette: Difference between revisions

From EDM2
Created page with "GreDeviceCreatePalette is called by GreSelectPalette, to process an application's GpiSelectPalette request. The presentation driver is expected to perform any allocation and d..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
GreDeviceCreatePalette is called by GreSelectPalette, to process an application's GpiSelectPalette request. The presentation driver is expected to perform any allocation and data structure initialization needed for a subsequent GreDeviceRealizePalette to succeed.  
GreDeviceCreatePalette is called by [[GpiSelectPalette]], to process an application's GpiSelectPalette request. The presentation driver is expected to perform any allocation and data structure initialization needed for a subsequent ''GreDeviceRealizePalette'' to succeed.


This function can be hooked by the presentation driver.
This function can be hooked by the presentation driver.


; Simulation support: This function is simulated by a handling routine in Revision 2.0 (or later) of the graphics engine.
;Simulation support: This function is simulated by a handling routine in Revision 2.0 (or later) of the graphics engine.


== Syntax ==  
== Syntax ==  
  GreDeviceCreatePalette(hdc, ppalinfo, hdevpal, pInstance, lFunction);
  GreDeviceCreatePalette(hdc, ppalinfo, hdevpal, pInstance, lFunction)


== Parameters ==
== Parameters ==
;hdc (HDC) - input  
;hdc (HDC) - input:Device context handle.
:Device context handle.  
;ppalinfo (PPALETTEINFO) - input:Pointer to table of palette data.
 
:Pointer to table of palette data from GreCreatePalette. The structure of palinfo is as follows:
;ppalinfo (PPALETTEINFO) - input  
:Pointer to table of palette data.  
 
:Pointer to table of palette data from GreCreatePalette. The structure of palinfo is as follows:  
 
<pre>
<pre>
struct _PALETTEINFO { /* palinfo */
struct _PALETTEINFO { /* palinfo */
Line 30: Line 25:
</pre>
</pre>


;hdevpal (ULONG) - input  
;hdevpal (ULONG) - input:Device palette handle (NULL, if new).
:Device palette handle (NULL, if new).  
:If hdevpal=0, ppalinfo points to a palette information structure, which must be set into a new palette. The handle for this new palette is returned in hdevpal. The new palette is then selected into the DC.
 
:If hdevpal is nonzero, ppalinfo is ignored, the palette is selected into the DC, and hdevpal is a device palette handle previously returned by the presentation driver. In this case, hdevpal is used to bind the palette with the new DC. This technique is the driver-level mechanism for sharing palettes among contexts on the same device.
:If hdevpal=0, ppalinfo points to a palette information structure, which must be set into a new palette. The handle for this new palette is returned in hdevpal. The new palette is then selected into the DC.  
;pInstance (PVOID) - input:Pointer to instance data.
 
;lFunction (ULONG) - input:High-order WORD=flags; low-order WORD=NGreDeviceCreatePalette.
:If hdevpal is nonzero, ppalinfo is ignored, the palette is selected into the DC, and hdevpal is a device palette handle previously returned by the presentation driver. In this case, hdevpal is used to bind the palette with the new DC. This technique is the driver-level mechanism for sharing palettes among contexts on the same device.  
 
;pInstance (PVOID) - input  
:Pointer to instance data.  
 
;lFunction (ULONG) - input  
:High-order WORD=flags; low-order WORD=NGreDeviceCreatePalette.  


== Returns ==
== Returns ==
;rc (ULONG) - returns  
;rc (ULONG) - returns:Return codes.
:Return codes.  
:On completion, this function returns the handle to the device palette (hdevpal).
 
:Possible Errors Detected: When an error is detected, the handling routine must call WinSetErrorInfo to post the condition. Error codes for conditions that the handling routine is expected to check include:
:On completion, this function returns the handle to the device palette (hdevpal).  
:*PMERR_INV_IN_AREA
 
:*PMERR_INV_IN_PATH
:Possible Errors Detected: When an error is detected, the handling routine must call WinSetErrorInfo to post the condition. Error codes for conditions that the handling routine is expected to check include:  
 
:*PMERR_INV_IN_AREA  
:*PMERR_INV_IN_PATH  
 


== Sample ==
== Sample ==
Line 60: Line 43:
#include <os2.h>
#include <os2.h>


HDC            hdc;        /* Device context handle. */
HDC            hdc;        /* Device context handle. */
PPALETTEINFO    ppalinfo;  /* Pointer to table of palette data. */
PPALETTEINFO    ppalinfo;  /* Pointer to table of palette data. */
ULONG          hdevpal;    /* Device palette handle (NULL, if new). */
ULONG          hdevpal;    /* Device palette handle (NULL, if new). */
PVOID          pInstance;  /* Pointer to instance data. */
PVOID          pInstance;  /* Pointer to instance data. */
ULONG          lFunction;  /* High-order WORD=flags; low-order WORD=NGreDeviceCreatePalette. */
ULONG          lFunction;  /* High-order WORD=flags; low-order WORD=NGreDeviceCreatePalette. */
ULONG          rc;        /* Return codes. */
ULONG          rc;        /* Return codes. */


rc = GreDeviceCreatePalette(hdc, ppalinfo,
rc = GreDeviceCreatePalette(hdc, ppalinfo,
Line 72: Line 55:


== Remarks ==
== Remarks ==
When an application sets a bit map, the bits are specified as indexes into the color table supplied with the bit map. The presentation driver allocates its own copy of the bit map.


When an application sets a bit map, the bits are specified as indexes into the color table supplied with the bit map. The presentation driver allocates its own copy of the bit map.
The driver-level pels contain indexes to the nearest color in the default physical palette.
 
The driver-level pels contain indexes to the nearest color in the default physical palette.  


;Note: This means that GreGetBitMapBits does not necessarily return the same bit map that the application set. Information may be lost if the bit map is taken to a less color-capable system and then brought back to the (more capable) system on which it was created.  
;Note: This means that GreGetBitMapBits does not necessarily return the same bit map that the application set. Information may be lost if the bit map is taken to a less color-capable system and then brought back to the (more capable) system on which it was created.


However, an application can select a palette into a memory DC. This causes the color table and the bit-map bits to change to the nearest mapping to the new palette. Calls to GreRealizePalette are not performed on memory DCs. The palette takes effect as soon as it is selected.  
However, an application can select a palette into a memory DC. This causes the color table and the bit-map bits to change to the nearest mapping to the new palette. Calls to GreRealizePalette are not performed on memory DCs. The palette takes effect as soon as it is selected.


The presentation driver is expected to perform any allocation and data structure needed for a subsequent GreDeviceResizePalette to succeed.  
The presentation driver is expected to perform any allocation and data structure needed for a subsequent GreDeviceResizePalette to succeed.


[[Category:Gre]]
[[Category:Gre]]

Latest revision as of 04:27, 12 January 2021

GreDeviceCreatePalette is called by GpiSelectPalette, to process an application's GpiSelectPalette request. The presentation driver is expected to perform any allocation and data structure initialization needed for a subsequent GreDeviceRealizePalette to succeed.

This function can be hooked by the presentation driver.

Simulation support
This function is simulated by a handling routine in Revision 2.0 (or later) of the graphics engine.

Syntax

GreDeviceCreatePalette(hdc, ppalinfo, hdevpal, pInstance, lFunction)

Parameters

hdc (HDC) - input
Device context handle.
ppalinfo (PPALETTEINFO) - input
Pointer to table of palette data.
Pointer to table of palette data from GreCreatePalette. The structure of palinfo is as follows:
struct _PALETTEINFO { /* palinfo */

ULONG        flCmd;         /* Options from create                   */
ULONG        ulFormat;      /* Specifies format of entries at create */
                            /* Must be LCOLF-CONSECRGB               */
ULONG        clColorData;   /* Count of Palette entries              */
RGB2   argb[0];             /* Palette entries                       */

} PALETTEINFO; Additional RGB@ entries follow so that CLColorData-1 entries are
defined.
hdevpal (ULONG) - input
Device palette handle (NULL, if new).
If hdevpal=0, ppalinfo points to a palette information structure, which must be set into a new palette. The handle for this new palette is returned in hdevpal. The new palette is then selected into the DC.
If hdevpal is nonzero, ppalinfo is ignored, the palette is selected into the DC, and hdevpal is a device palette handle previously returned by the presentation driver. In this case, hdevpal is used to bind the palette with the new DC. This technique is the driver-level mechanism for sharing palettes among contexts on the same device.
pInstance (PVOID) - input
Pointer to instance data.
lFunction (ULONG) - input
High-order WORD=flags; low-order WORD=NGreDeviceCreatePalette.

Returns

rc (ULONG) - returns
Return codes.
On completion, this function returns the handle to the device palette (hdevpal).
Possible Errors Detected: When an error is detected, the handling routine must call WinSetErrorInfo to post the condition. Error codes for conditions that the handling routine is expected to check include:
  • PMERR_INV_IN_AREA
  • PMERR_INV_IN_PATH

Sample

#define INCL_GRE_PALETTE
#include <os2.h>

HDC             hdc;        /* Device context handle. */
PPALETTEINFO    ppalinfo;   /* Pointer to table of palette data. */
ULONG           hdevpal;    /* Device palette handle (NULL, if new). */
PVOID           pInstance;  /* Pointer to instance data. */
ULONG           lFunction;  /* High-order WORD=flags; low-order WORD=NGreDeviceCreatePalette. */
ULONG           rc;         /* Return codes. */

rc = GreDeviceCreatePalette(hdc, ppalinfo,
       hdevpal, pInstance, lFunction);

Remarks

When an application sets a bit map, the bits are specified as indexes into the color table supplied with the bit map. The presentation driver allocates its own copy of the bit map.

The driver-level pels contain indexes to the nearest color in the default physical palette.

Note
This means that GreGetBitMapBits does not necessarily return the same bit map that the application set. Information may be lost if the bit map is taken to a less color-capable system and then brought back to the (more capable) system on which it was created.

However, an application can select a palette into a memory DC. This causes the color table and the bit-map bits to change to the nearest mapping to the new palette. Calls to GreRealizePalette are not performed on memory DCs. The palette takes effect as soon as it is selected.

The presentation driver is expected to perform any allocation and data structure needed for a subsequent GreDeviceResizePalette to succeed.