4 * Copyright 1993,1994 Alexandre Julliard
5 * Copyright 1996 Alex Korobka
7 * PALETTEOBJ is documented in the Dr. Dobbs Journal May 1993.
8 * Information in the "Undocumented Windows" is incorrect.
17 #include "wine/winuser16.h"
21 #include "debugtools.h"
25 DEFAULT_DEBUG_CHANNEL(palette
);
27 PALETTE_DRIVER
*PALETTE_Driver
= NULL
;
29 /* Pointers to USER implementation of SelectPalette/RealizePalette */
30 /* they will be patched by USER on startup */
31 FARPROC pfnSelectPalette
= NULL
;
32 FARPROC pfnRealizePalette
= NULL
;
34 static UINT SystemPaletteUse
= SYSPAL_STATIC
; /* currently not considered */
36 static HPALETTE16 hPrimaryPalette
= 0; /* used for WM_PALETTECHANGED */
37 static HPALETTE16 hLastRealizedPalette
= 0; /* UnrealizeObject() needs it */
40 /***********************************************************************
43 * Create the system palette.
45 HPALETTE16
PALETTE_Init(void)
51 const PALETTEENTRY
* __sysPalTemplate
= COLOR_GetSystemPaletteTemplate();
53 /* create default palette (20 system colors) */
55 palPtr
= HeapAlloc( GetProcessHeap(), 0,
56 sizeof(LOGPALETTE
) + (NB_RESERVED_COLORS
-1)*sizeof(PALETTEENTRY
));
57 if (!palPtr
) return FALSE
;
59 palPtr
->palVersion
= 0x300;
60 palPtr
->palNumEntries
= NB_RESERVED_COLORS
;
61 for( i
= 0; i
< NB_RESERVED_COLORS
; i
++ )
63 palPtr
->palPalEntry
[i
].peRed
= __sysPalTemplate
[i
].peRed
;
64 palPtr
->palPalEntry
[i
].peGreen
= __sysPalTemplate
[i
].peGreen
;
65 palPtr
->palPalEntry
[i
].peBlue
= __sysPalTemplate
[i
].peBlue
;
66 palPtr
->palPalEntry
[i
].peFlags
= 0;
68 hpalette
= CreatePalette16( palPtr
);
69 HeapFree( GetProcessHeap(), 0, palPtr
);
71 palObj
= (PALETTEOBJ
*) GDI_GetObjPtr( hpalette
, PALETTE_MAGIC
);
74 if (!(palObj
->mapping
= HeapAlloc( GetProcessHeap(), 0, sizeof(int) * 20 )))
75 ERR("Can not create palette mapping -- out of memory!");
76 GDI_ReleaseObj( hpalette
);
81 /***********************************************************************
82 * PALETTE_ValidateFlags
84 void PALETTE_ValidateFlags(PALETTEENTRY
* lpPalE
, int size
)
88 lpPalE
[i
].peFlags
= PC_SYS_USED
| (lpPalE
[i
].peFlags
& 0x07);
92 /***********************************************************************
93 * CreatePalette16 (GDI.360)
95 HPALETTE16 WINAPI
CreatePalette16( const LOGPALETTE
* palette
)
97 return CreatePalette( palette
);
101 /***********************************************************************
102 * CreatePalette [GDI32.53] Creates a logical color palette
105 * Success: Handle to logical palette
108 HPALETTE WINAPI
CreatePalette(
109 const LOGPALETTE
* palette
) /* [in] Pointer to logical color palette */
111 PALETTEOBJ
* palettePtr
;
115 if (!palette
) return 0;
116 TRACE("entries=%i\n", palette
->palNumEntries
);
118 size
= sizeof(LOGPALETTE
) + (palette
->palNumEntries
- 1) * sizeof(PALETTEENTRY
);
120 if (!(palettePtr
= GDI_AllocObject( size
+ sizeof(int*) +sizeof(GDIOBJHDR
),
121 PALETTE_MAGIC
, &hpalette
))) return 0;
122 memcpy( &palettePtr
->logpalette
, palette
, size
);
123 PALETTE_ValidateFlags(palettePtr
->logpalette
.palPalEntry
,
124 palettePtr
->logpalette
.palNumEntries
);
125 palettePtr
->mapping
= NULL
;
126 GDI_ReleaseObj( hpalette
);
128 TRACE(" returning %04x\n", hpalette
);
133 /***********************************************************************
134 * CreateHalftonePalette16 [GDI.?] Creates a halftone palette
137 * Success: Handle to logical halftone palette
140 HPALETTE16 WINAPI
CreateHalftonePalette16(
141 HDC16 hdc
) /* [in] Handle to device context */
143 return CreateHalftonePalette(hdc
);
147 /***********************************************************************
148 * CreateHalftonePalette [GDI32.47] Creates a halftone palette
151 * Success: Handle to logical halftone palette
154 * FIXME: not truly tested
156 HPALETTE WINAPI
CreateHalftonePalette(
157 HDC hdc
) /* [in] Handle to device context */
162 WORD NumberOfEntries
;
163 PALETTEENTRY aEntries
[256];
166 Palette
.Version
= 0x300;
167 Palette
.NumberOfEntries
= 256;
168 GetSystemPaletteEntries(hdc
, 0, 256, Palette
.aEntries
);
170 for (r
= 0; r
< 6; r
++) {
171 for (g
= 0; g
< 6; g
++) {
172 for (b
= 0; b
< 6; b
++) {
173 i
= r
+ g
*6 + b
*36 + 10;
174 Palette
.aEntries
[i
].peRed
= r
* 51;
175 Palette
.aEntries
[i
].peGreen
= g
* 51;
176 Palette
.aEntries
[i
].peBlue
= b
* 51;
181 for (i
= 216; i
< 246; i
++) {
182 int v
= (i
- 216) * 8;
183 Palette
.aEntries
[i
].peRed
= v
;
184 Palette
.aEntries
[i
].peGreen
= v
;
185 Palette
.aEntries
[i
].peBlue
= v
;
188 return CreatePalette((LOGPALETTE
*)&Palette
);
192 /***********************************************************************
193 * GetPaletteEntries16 (GDI.363)
195 UINT16 WINAPI
GetPaletteEntries16( HPALETTE16 hpalette
, UINT16 start
,
196 UINT16 count
, LPPALETTEENTRY entries
)
198 return GetPaletteEntries( hpalette
, start
, count
, entries
);
202 /***********************************************************************
203 * GetPaletteEntries [GDI32.209] Retrieves palette entries
206 * Success: Number of entries from logical palette
209 UINT WINAPI
GetPaletteEntries(
210 HPALETTE hpalette
, /* [in] Handle of logical palette */
211 UINT start
, /* [in] First entry to receive */
212 UINT count
, /* [in] Number of entries to receive */
213 LPPALETTEENTRY entries
) /* [out] Address of array receiving entries */
218 TRACE("hpal = %04x, count=%i\n", hpalette
, count
);
220 palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( hpalette
, PALETTE_MAGIC
);
221 if (!palPtr
) return 0;
223 numEntries
= palPtr
->logpalette
.palNumEntries
;
224 if (start
+count
> numEntries
) count
= numEntries
- start
;
227 if (start
>= numEntries
)
229 GDI_ReleaseObj( hpalette
);
232 memcpy( entries
, &palPtr
->logpalette
.palPalEntry
[start
],
233 count
* sizeof(PALETTEENTRY
) );
234 for( numEntries
= 0; numEntries
< count
; numEntries
++ )
235 if (entries
[numEntries
].peFlags
& 0xF0)
236 entries
[numEntries
].peFlags
= 0;
239 GDI_ReleaseObj( hpalette
);
244 /***********************************************************************
245 * SetPaletteEntries16 (GDI.364)
247 UINT16 WINAPI
SetPaletteEntries16( HPALETTE16 hpalette
, UINT16 start
,
248 UINT16 count
, LPPALETTEENTRY entries
)
250 return SetPaletteEntries( hpalette
, start
, count
, entries
);
254 /***********************************************************************
255 * SetPaletteEntries [GDI32.326] Sets color values for range in palette
258 * Success: Number of entries that were set
261 UINT WINAPI
SetPaletteEntries(
262 HPALETTE hpalette
, /* [in] Handle of logical palette */
263 UINT start
, /* [in] Index of first entry to set */
264 UINT count
, /* [in] Number of entries to set */
265 LPPALETTEENTRY entries
) /* [in] Address of array of structures */
270 TRACE("hpal=%04x,start=%i,count=%i\n",hpalette
,start
,count
);
272 palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( hpalette
, PALETTE_MAGIC
);
273 if (!palPtr
) return 0;
275 numEntries
= palPtr
->logpalette
.palNumEntries
;
276 if (start
>= numEntries
)
278 GDI_ReleaseObj( hpalette
);
281 if (start
+count
> numEntries
) count
= numEntries
- start
;
282 memcpy( &palPtr
->logpalette
.palPalEntry
[start
], entries
,
283 count
* sizeof(PALETTEENTRY
) );
284 PALETTE_ValidateFlags(palPtr
->logpalette
.palPalEntry
,
285 palPtr
->logpalette
.palNumEntries
);
286 HeapFree( GetProcessHeap(), 0, palPtr
->mapping
);
287 palPtr
->mapping
= NULL
;
288 GDI_ReleaseObj( hpalette
);
293 /***********************************************************************
294 * ResizePalette16 (GDI.368)
296 BOOL16 WINAPI
ResizePalette16( HPALETTE16 hPal
, UINT16 cEntries
)
298 return ResizePalette( hPal
, cEntries
);
302 /***********************************************************************
303 * ResizePalette [GDI32.289] Resizes logical palette
309 BOOL WINAPI
ResizePalette(
310 HPALETTE hPal
, /* [in] Handle of logical palette */
311 UINT cEntries
) /* [in] Number of entries in logical palette */
313 PALETTEOBJ
* palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( hPal
, PALETTE_MAGIC
);
314 UINT cPrevEnt
, prevVer
;
315 int prevsize
, size
= sizeof(LOGPALETTE
) + (cEntries
- 1) * sizeof(PALETTEENTRY
);
318 TRACE("hpal = %04x, prev = %i, new = %i\n",
319 hPal
, palPtr
? palPtr
->logpalette
.palNumEntries
: -1,
321 if( !palPtr
) return FALSE
;
322 cPrevEnt
= palPtr
->logpalette
.palNumEntries
;
323 prevVer
= palPtr
->logpalette
.palVersion
;
324 prevsize
= sizeof(LOGPALETTE
) + (cPrevEnt
- 1) * sizeof(PALETTEENTRY
) +
325 sizeof(int*) + sizeof(GDIOBJHDR
);
326 size
+= sizeof(int*) + sizeof(GDIOBJHDR
);
327 mapping
= palPtr
->mapping
;
329 if (!(palPtr
= GDI_ReallocObject( size
, hPal
, palPtr
))) return FALSE
;
333 int *newMap
= (int*) HeapReAlloc(GetProcessHeap(), 0,
334 mapping
, cEntries
* sizeof(int) );
337 ERR("Can not resize mapping -- out of memory!");
338 GDI_ReleaseObj( hPal
);
341 palPtr
->mapping
= newMap
;
344 if( cEntries
> cPrevEnt
)
347 memset(palPtr
->mapping
+ cPrevEnt
, 0, (cEntries
- cPrevEnt
)*sizeof(int));
348 memset( (BYTE
*)palPtr
+ prevsize
, 0, size
- prevsize
);
349 PALETTE_ValidateFlags((PALETTEENTRY
*)((BYTE
*)palPtr
+ prevsize
),
350 cEntries
- cPrevEnt
);
352 palPtr
->logpalette
.palNumEntries
= cEntries
;
353 palPtr
->logpalette
.palVersion
= prevVer
;
354 GDI_ReleaseObj( hPal
);
359 /***********************************************************************
360 * AnimatePalette16 (GDI.367)
362 void WINAPI
AnimatePalette16( HPALETTE16 hPal
, UINT16 StartIndex
,
363 UINT16 NumEntries
, const PALETTEENTRY
* PaletteColors
)
365 AnimatePalette( hPal
, StartIndex
, NumEntries
, PaletteColors
);
369 /***********************************************************************
370 * AnimatePalette [GDI32.6] Replaces entries in logical palette
377 * Should use existing mapping when animating a primary palette
379 BOOL WINAPI
AnimatePalette(
380 HPALETTE hPal
, /* [in] Handle to logical palette */
381 UINT StartIndex
, /* [in] First entry in palette */
382 UINT NumEntries
, /* [in] Count of entries in palette */
383 const PALETTEENTRY
* PaletteColors
) /* [in] Pointer to first replacement */
385 TRACE("%04x (%i - %i)\n", hPal
, StartIndex
,StartIndex
+NumEntries
);
387 if( hPal
!= GetStockObject(DEFAULT_PALETTE
) )
389 PALETTEOBJ
* palPtr
= (PALETTEOBJ
*)GDI_GetObjPtr(hPal
, PALETTE_MAGIC
);
390 if (!palPtr
) return FALSE
;
392 if( (StartIndex
+ NumEntries
) <= palPtr
->logpalette
.palNumEntries
)
395 for( u
= 0; u
< NumEntries
; u
++ )
396 palPtr
->logpalette
.palPalEntry
[u
+ StartIndex
] = PaletteColors
[u
];
398 pSetMapping(palPtr
, StartIndex
, NumEntries
,
399 hPal
!= hPrimaryPalette
);
400 GDI_ReleaseObj( hPal
);
403 GDI_ReleaseObj( hPal
);
409 /***********************************************************************
410 * SetSystemPaletteUse16 (GDI.373)
412 UINT16 WINAPI
SetSystemPaletteUse16( HDC16 hdc
, UINT16 use
)
414 return SetSystemPaletteUse( hdc
, use
);
418 /***********************************************************************
419 * SetSystemPaletteUse [GDI32.335]
422 * Success: Previous system palette
423 * Failure: SYSPAL_ERROR
425 UINT WINAPI
SetSystemPaletteUse(
426 HDC hdc
, /* [in] Handle of device context */
427 UINT use
) /* [in] Palette-usage flag */
429 UINT old
= SystemPaletteUse
;
430 FIXME("(%04x,%04x): stub\n", hdc
, use
);
431 SystemPaletteUse
= use
;
436 /***********************************************************************
437 * GetSystemPaletteUse16 (GDI.374)
439 UINT16 WINAPI
GetSystemPaletteUse16( HDC16 hdc
)
441 return SystemPaletteUse
;
445 /***********************************************************************
446 * GetSystemPaletteUse [GDI32.223] Gets state of system palette
449 * Current state of system palette
451 UINT WINAPI
GetSystemPaletteUse(
452 HDC hdc
) /* [in] Handle of device context */
454 return SystemPaletteUse
;
458 /***********************************************************************
459 * GetSystemPaletteEntries16 (GDI.375)
461 UINT16 WINAPI
GetSystemPaletteEntries16( HDC16 hdc
, UINT16 start
, UINT16 count
,
462 LPPALETTEENTRY entries
)
464 return GetSystemPaletteEntries( hdc
, start
, count
, entries
);
468 /***********************************************************************
469 * GetSystemPaletteEntries [GDI32.222] Gets range of palette entries
472 * Success: Number of entries retrieved from palette
475 UINT WINAPI
GetSystemPaletteEntries(
476 HDC hdc
, /* [in] Handle of device context */
477 UINT start
, /* [in] Index of first entry to be retrieved */
478 UINT count
, /* [in] Number of entries to be retrieved */
479 LPPALETTEENTRY entries
) /* [out] Array receiving system-palette entries */
484 TRACE("hdc=%04x,start=%i,count=%i\n", hdc
,start
,count
);
486 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
490 count
= dc
->devCaps
->sizePalette
;
494 if (start
>= dc
->devCaps
->sizePalette
)
500 if (start
+count
>= dc
->devCaps
->sizePalette
)
501 count
= dc
->devCaps
->sizePalette
- start
;
502 for (i
= 0; i
< count
; i
++)
504 *(COLORREF
*)(entries
+ i
) = COLOR_GetSystemPaletteEntry( start
+ i
);
506 TRACE("\tidx(%02x) -> RGB(%08lx)\n",
507 start
+ i
, *(COLORREF
*)(entries
+ i
) );
510 GDI_ReleaseObj( hdc
);
515 /***********************************************************************
516 * GetNearestPaletteIndex16 (GDI.370)
518 UINT16 WINAPI
GetNearestPaletteIndex16( HPALETTE16 hpalette
, COLORREF color
)
520 return GetNearestPaletteIndex( hpalette
, color
);
524 /***********************************************************************
525 * GetNearestPaletteIndex [GDI32.203] Gets palette index for color
528 * Should index be initialized to CLR_INVALID instead of 0?
531 * Success: Index of entry in logical palette
532 * Failure: CLR_INVALID
534 UINT WINAPI
GetNearestPaletteIndex(
535 HPALETTE hpalette
, /* [in] Handle of logical color palette */
536 COLORREF color
) /* [in] Color to be matched */
538 PALETTEOBJ
* palObj
= (PALETTEOBJ
*)GDI_GetObjPtr( hpalette
, PALETTE_MAGIC
);
543 index
= COLOR_PaletteLookupPixel(palObj
->logpalette
.palPalEntry
,
544 palObj
->logpalette
.palNumEntries
,
545 NULL
, color
, FALSE
);
547 GDI_ReleaseObj( hpalette
);
549 TRACE("(%04x,%06lx): returning %d\n", hpalette
, color
, index
);
554 /***********************************************************************
555 * GetNearestColor16 (GDI.154)
557 COLORREF WINAPI
GetNearestColor16( HDC16 hdc
, COLORREF color
)
559 return GetNearestColor( hdc
, color
);
563 /***********************************************************************
564 * GetNearestColor [GDI32.202] Gets a system color to match
567 * Success: Color from system palette that corresponds to given color
568 * Failure: CLR_INVALID
570 COLORREF WINAPI
GetNearestColor(
571 HDC hdc
, /* [in] Handle of device context */
572 COLORREF color
) /* [in] Color to be matched */
574 COLORREF nearest
= CLR_INVALID
;
578 if ( (dc
= DC_GetDCPtr( hdc
)) )
580 HPALETTE hpal
= (dc
->hPalette
)? dc
->hPalette
: GetStockObject( DEFAULT_PALETTE
);
581 palObj
= GDI_GetObjPtr( hpal
, PALETTE_MAGIC
);
583 GDI_ReleaseObj( hdc
);
587 nearest
= COLOR_LookupNearestColor( palObj
->logpalette
.palPalEntry
,
588 palObj
->logpalette
.palNumEntries
, color
);
589 GDI_ReleaseObj( hpal
);
590 GDI_ReleaseObj( hdc
);
593 TRACE("(%06lx): returning %06lx\n", color
, nearest
);
598 /***********************************************************************
601 int PALETTE_GetObject( PALETTEOBJ
* palette
, int count
, LPSTR buffer
)
603 if (count
> sizeof(WORD
)) count
= sizeof(WORD
);
604 memcpy( buffer
, &palette
->logpalette
.palNumEntries
, count
);
609 /***********************************************************************
610 * PALETTE_UnrealizeObject
612 BOOL
PALETTE_UnrealizeObject( HPALETTE16 hpalette
, PALETTEOBJ
*palette
)
614 if (palette
->mapping
)
616 HeapFree( GetProcessHeap(), 0, palette
->mapping
);
617 palette
->mapping
= NULL
;
619 if (hLastRealizedPalette
== hpalette
) hLastRealizedPalette
= 0;
624 /***********************************************************************
625 * PALETTE_DeleteObject
627 BOOL
PALETTE_DeleteObject( HPALETTE16 hpalette
, PALETTEOBJ
*palette
)
629 HeapFree( GetProcessHeap(), 0, palette
->mapping
);
630 if (hLastRealizedPalette
== hpalette
) hLastRealizedPalette
= 0;
631 return GDI_FreeObject( hpalette
, palette
);
635 /***********************************************************************
636 * GDISelectPalette (GDI.361)
638 HPALETTE16 WINAPI
GDISelectPalette16( HDC16 hdc
, HPALETTE16 hpal
, WORD wBkg
)
643 TRACE("%04x %04x\n", hdc
, hpal
);
645 if (GetObjectType(hpal
) != OBJ_PAL
)
647 WARN("invalid selected palette %04x\n",hpal
);
650 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
653 GDI_ReleaseObj( hdc
);
654 if (!wBkg
) hPrimaryPalette
= hpal
;
659 /***********************************************************************
660 * GDIRealizePalette (GDI.362)
662 UINT16 WINAPI
GDIRealizePalette16( HDC16 hdc
)
666 DC
* dc
= DC_GetDCPtr( hdc
);
670 TRACE("%04x...\n", hdc
);
672 if(dc
->hPalette
!= hLastRealizedPalette
)
674 if( dc
->hPalette
== GetStockObject( DEFAULT_PALETTE
)) {
675 realized
= RealizeDefaultPalette16( hdc
);
676 GDI_ReleaseObj( hdc
);
677 return (UINT16
)realized
;
681 palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( dc
->hPalette
, PALETTE_MAGIC
);
684 GDI_ReleaseObj( hdc
);
685 FIXME("invalid selected palette %04x\n",dc
->hPalette
);
689 realized
= PALETTE_Driver
->
690 pSetMapping(palPtr
,0,palPtr
->logpalette
.palNumEntries
,
691 (dc
->hPalette
!= hPrimaryPalette
) ||
692 (dc
->hPalette
== GetStockObject( DEFAULT_PALETTE
)));
693 hLastRealizedPalette
= dc
->hPalette
;
694 GDI_ReleaseObj( dc
->hPalette
);
696 else TRACE(" skipping (hLastRealizedPalette = %04x)\n",
697 hLastRealizedPalette
);
698 GDI_ReleaseObj( hdc
);
700 TRACE(" realized %i colors.\n", realized
);
701 return (UINT16
)realized
;
705 /***********************************************************************
706 * RealizeDefaultPalette (GDI.365)
708 UINT16 WINAPI
RealizeDefaultPalette16( HDC16 hdc
)
714 TRACE("%04x\n", hdc
);
716 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
718 if (!(dc
->flags
& DC_MEMORY
))
720 palPtr
= (PALETTEOBJ
*)GDI_GetObjPtr( GetStockObject(DEFAULT_PALETTE
), PALETTE_MAGIC
);
723 /* lookup is needed to account for SetSystemPaletteUse() stuff */
724 ret
= PALETTE_Driver
->pUpdateMapping(palPtr
);
725 GDI_ReleaseObj( GetStockObject(DEFAULT_PALETTE
) );
728 GDI_ReleaseObj( hdc
);
732 /***********************************************************************
733 * IsDCCurrentPalette (GDI.412)
735 BOOL16 WINAPI
IsDCCurrentPalette16(HDC16 hDC
)
737 DC
*dc
= DC_GetDCPtr( hDC
);
740 BOOL bRet
= dc
->hPalette
== hPrimaryPalette
;
741 GDI_ReleaseObj( hDC
);
748 /***********************************************************************
749 * SelectPalette [GDI32.300] Selects logical palette into DC
752 * Success: Previous logical palette
755 HPALETTE WINAPI
SelectPalette(
756 HDC hDC
, /* [in] Handle of device context */
757 HPALETTE hPal
, /* [in] Handle of logical color palette */
758 BOOL bForceBackground
) /* [in] Foreground/background mode */
760 return pfnSelectPalette( hDC
, hPal
, bForceBackground
);
764 /***********************************************************************
765 * RealizePalette [GDI32.280] Maps palette entries to system palette
768 * Success: Number of entries in logical palette
771 UINT WINAPI
RealizePalette(
772 HDC hDC
) /* [in] Handle of device context */
774 return pfnRealizePalette( hDC
);
778 /**********************************************************************
779 * UpdateColors16 (GDI.366)
781 INT16 WINAPI
UpdateColors16( HDC16 hDC
)
787 if (!(dc
= DC_GetDCPtr( hDC
))) return 0;
788 size
= dc
->devCaps
->sizePalette
;
789 GDI_ReleaseObj( hDC
);
790 if (Callout
.WindowFromDC
)
792 hWnd
= Callout
.WindowFromDC( hDC
);
794 /* Docs say that we have to remap current drawable pixel by pixel
795 * but it would take forever given the speed of XGet/PutPixel.
798 Callout
.RedrawWindow( hWnd
, NULL
, 0, RDW_INVALIDATE
);
804 /**********************************************************************
805 * UpdateColors [GDI32.359] Remaps current colors to logical palette
811 BOOL WINAPI
UpdateColors(
812 HDC hDC
) /* [in] Handle of device context */
814 UpdateColors16( hDC
);
819 /*********************************************************************
820 * SetMagicColors16 (GDI.606)
822 VOID WINAPI
SetMagicColors16(HDC16 hDC
, COLORREF color
, UINT16 index
)
824 FIXME("(hDC %04x, color %04x, index %04x): stub\n", hDC
, (int)color
, index
);
828 /**********************************************************************
829 * GetICMProfileA [GDI32.316]
831 * Returns the filename of the specified device context's color
832 * management profile, even if color management is not enabled
836 * TRUE if name copied succesfully OR lpszFilename is NULL
837 * FALSE if the buffer length pointed to by lpcbName is too small
840 * The buffer length pointed to by lpcbName is ALWAYS updated to
841 * the length required regardless of other actions this function
845 * How does Windows assign these? Some registry key?
848 #define WINEICM "winefake.icm" /* easy-to-identify fake filename */
850 BOOL WINAPI
GetICMProfileA(HDC hDC
, LPDWORD lpcbName
, LPSTR lpszFilename
)
854 FIXME("(%04x, %p, %p): partial stub\n", hDC
, lpcbName
, lpszFilename
);
856 callerLen
= *lpcbName
;
858 /* all 3 behaviors require the required buffer size to be set */
859 *lpcbName
= strlen(WINEICM
);
861 /* behavior 1: if lpszFilename is NULL, return size of string and no error */
862 if ((DWORD
)lpszFilename
== (DWORD
)0x00000000)
865 /* behavior 2: if buffer size too small, return size of string and error */
866 if (callerLen
< strlen(WINEICM
))
868 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
872 /* behavior 3: if buffer size OK and pointer not NULL, copy and return size */
873 strcpy(lpszFilename
, WINEICM
);