4 * Copyright 1993,1994 Alexandre Julliard
5 * Copyright 1996 Alex Korobka
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * PALETTEOBJ is documented in the Dr. Dobbs Journal May 1993.
23 * Information in the "Undocumented Windows" is incorrect.
34 #include "wine/winuser16.h"
35 #include "gdi_private.h"
36 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(palette);
41 typedef struct tagPALETTEOBJ
44 const DC_FUNCTIONS *funcs; /* DC function table */
45 LOGPALETTE logpalette; /* _MUST_ be the last field */
48 static INT PALETTE_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
49 static BOOL PALETTE_UnrealizeObject( HGDIOBJ handle, void *obj );
50 static BOOL PALETTE_DeleteObject( HGDIOBJ handle, void *obj );
52 static const struct gdi_obj_funcs palette_funcs =
54 NULL, /* pSelectObject */
55 PALETTE_GetObject, /* pGetObject16 */
56 PALETTE_GetObject, /* pGetObjectA */
57 PALETTE_GetObject, /* pGetObjectW */
58 PALETTE_UnrealizeObject, /* pUnrealizeObject */
59 PALETTE_DeleteObject /* pDeleteObject */
62 /* Pointers to USER implementation of SelectPalette/RealizePalette */
63 /* they will be patched by USER on startup */
64 HPALETTE (WINAPI *pfnSelectPalette)(HDC hdc, HPALETTE hpal, WORD bkgnd ) = GDISelectPalette;
65 UINT (WINAPI *pfnRealizePalette)(HDC hdc) = GDIRealizePalette;
67 static UINT SystemPaletteUse = SYSPAL_STATIC; /* currently not considered */
69 static HPALETTE hPrimaryPalette = 0; /* used for WM_PALETTECHANGED */
70 static HPALETTE hLastRealizedPalette = 0; /* UnrealizeObject() needs it */
72 #define NB_RESERVED_COLORS 20 /* number of fixed colors in system palette */
74 static const PALETTEENTRY sys_pal_template[NB_RESERVED_COLORS] =
76 /* first 10 entries in the system palette */
77 /* red green blue flags */
78 { 0x00, 0x00, 0x00, 0 },
79 { 0x80, 0x00, 0x00, 0 },
80 { 0x00, 0x80, 0x00, 0 },
81 { 0x80, 0x80, 0x00, 0 },
82 { 0x00, 0x00, 0x80, 0 },
83 { 0x80, 0x00, 0x80, 0 },
84 { 0x00, 0x80, 0x80, 0 },
85 { 0xc0, 0xc0, 0xc0, 0 },
86 { 0xc0, 0xdc, 0xc0, 0 },
87 { 0xa6, 0xca, 0xf0, 0 },
89 /* ... c_min/2 dynamic colorcells */
91 /* ... gap (for sparse palettes) */
93 /* ... c_min/2 dynamic colorcells */
95 { 0xff, 0xfb, 0xf0, 0 },
96 { 0xa0, 0xa0, 0xa4, 0 },
97 { 0x80, 0x80, 0x80, 0 },
98 { 0xff, 0x00, 0x00, 0 },
99 { 0x00, 0xff, 0x00, 0 },
100 { 0xff, 0xff, 0x00, 0 },
101 { 0x00, 0x00, 0xff, 0 },
102 { 0xff, 0x00, 0xff, 0 },
103 { 0x00, 0xff, 0xff, 0 },
104 { 0xff, 0xff, 0xff, 0 } /* last 10 */
107 /***********************************************************************
110 * Create the system palette.
112 HPALETTE PALETTE_Init(void)
117 /* create default palette (20 system colors) */
119 palPtr = HeapAlloc( GetProcessHeap(), 0,
120 sizeof(LOGPALETTE) + (NB_RESERVED_COLORS-1)*sizeof(PALETTEENTRY));
121 if (!palPtr) return FALSE;
123 palPtr->palVersion = 0x300;
124 palPtr->palNumEntries = NB_RESERVED_COLORS;
125 memcpy( palPtr->palPalEntry, sys_pal_template, sizeof(sys_pal_template) );
126 hpalette = CreatePalette( palPtr );
127 HeapFree( GetProcessHeap(), 0, palPtr );
132 /***********************************************************************
133 * CreatePalette [GDI32.@]
135 * Creates a logical color palette.
138 * Success: Handle to logical palette
141 HPALETTE WINAPI CreatePalette(
142 const LOGPALETTE* palette) /* [in] Pointer to logical color palette */
144 PALETTEOBJ * palettePtr;
148 if (!palette) return 0;
149 TRACE("entries=%i\n", palette->palNumEntries);
151 size = sizeof(LOGPALETTE) + (palette->palNumEntries - 1) * sizeof(PALETTEENTRY);
153 if (!(palettePtr = GDI_AllocObject( size + sizeof(int*) +sizeof(GDIOBJHDR),
154 PALETTE_MAGIC, (HGDIOBJ *)&hpalette,
155 &palette_funcs ))) return 0;
156 memcpy( &palettePtr->logpalette, palette, size );
157 palettePtr->funcs = NULL;
158 GDI_ReleaseObj( hpalette );
160 TRACE(" returning %p\n", hpalette);
165 /***********************************************************************
166 * CreateHalftonePalette [GDI32.@]
168 * Creates a halftone palette.
171 * Success: Handle to logical halftone palette
174 * FIXME: This simply creates the halftone palette derived from running
175 * tests on a windows NT machine. This is assuming a color depth
176 * of greater that 256 color. On a 256 color device the halftone
177 * palette will be different and this function will be incorrect
179 HPALETTE WINAPI CreateHalftonePalette(
180 HDC hdc) /* [in] Handle to device context */
185 WORD NumberOfEntries;
186 PALETTEENTRY aEntries[256];
189 Palette.Version = 0x300;
190 Palette.NumberOfEntries = 256;
191 GetSystemPaletteEntries(hdc, 0, 256, Palette.aEntries);
193 Palette.NumberOfEntries = 20;
195 for (i = 0; i < Palette.NumberOfEntries; i++)
197 Palette.aEntries[i].peRed=0xff;
198 Palette.aEntries[i].peGreen=0xff;
199 Palette.aEntries[i].peBlue=0xff;
200 Palette.aEntries[i].peFlags=0x00;
203 Palette.aEntries[0].peRed=0x00;
204 Palette.aEntries[0].peBlue=0x00;
205 Palette.aEntries[0].peGreen=0x00;
208 for (i=1; i <= 6; i++)
210 Palette.aEntries[i].peRed=(i%2)?0x80:0;
211 Palette.aEntries[i].peGreen=(i==2)?0x80:(i==3)?0x80:(i==6)?0x80:0;
212 Palette.aEntries[i].peBlue=(i>3)?0x80:0;
215 for (i=7; i <= 12; i++)
220 Palette.aEntries[i].peRed=0xc0;
221 Palette.aEntries[i].peBlue=0xc0;
222 Palette.aEntries[i].peGreen=0xc0;
225 Palette.aEntries[i].peRed=0xc0;
226 Palette.aEntries[i].peGreen=0xdc;
227 Palette.aEntries[i].peBlue=0xc0;
230 Palette.aEntries[i].peRed=0xa6;
231 Palette.aEntries[i].peGreen=0xca;
232 Palette.aEntries[i].peBlue=0xf0;
235 Palette.aEntries[i].peRed=0xff;
236 Palette.aEntries[i].peGreen=0xfb;
237 Palette.aEntries[i].peBlue=0xf0;
240 Palette.aEntries[i].peRed=0xa0;
241 Palette.aEntries[i].peGreen=0xa0;
242 Palette.aEntries[i].peBlue=0xa4;
245 Palette.aEntries[i].peRed=0x80;
246 Palette.aEntries[i].peGreen=0x80;
247 Palette.aEntries[i].peBlue=0x80;
251 for (i=13; i <= 18; i++)
253 Palette.aEntries[i].peRed=(i%2)?0xff:0;
254 Palette.aEntries[i].peGreen=(i==14)?0xff:(i==15)?0xff:(i==18)?0xff:0;
255 Palette.aEntries[i].peBlue=(i>15)?0xff:0x00;
258 return CreatePalette((LOGPALETTE *)&Palette);
262 /***********************************************************************
263 * GetPaletteEntries [GDI32.@]
265 * Retrieves palette entries.
268 * Success: Number of entries from logical palette
271 UINT WINAPI GetPaletteEntries(
272 HPALETTE hpalette, /* [in] Handle of logical palette */
273 UINT start, /* [in] First entry to receive */
274 UINT count, /* [in] Number of entries to receive */
275 LPPALETTEENTRY entries) /* [out] Address of array receiving entries */
280 TRACE("hpal = %p, count=%i\n", hpalette, count );
282 palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
283 if (!palPtr) return 0;
285 /* NOTE: not documented but test show this to be the case */
288 int rc = palPtr->logpalette.palNumEntries;
289 GDI_ReleaseObj( hpalette );
293 numEntries = palPtr->logpalette.palNumEntries;
294 if (start+count > numEntries) count = numEntries - start;
297 if (start >= numEntries)
299 GDI_ReleaseObj( hpalette );
302 memcpy( entries, &palPtr->logpalette.palPalEntry[start],
303 count * sizeof(PALETTEENTRY) );
304 for( numEntries = 0; numEntries < count ; numEntries++ )
305 if (entries[numEntries].peFlags & 0xF0)
306 entries[numEntries].peFlags = 0;
309 GDI_ReleaseObj( hpalette );
314 /***********************************************************************
315 * SetPaletteEntries [GDI32.@]
317 * Sets color values for range in palette.
320 * Success: Number of entries that were set
323 UINT WINAPI SetPaletteEntries(
324 HPALETTE hpalette, /* [in] Handle of logical palette */
325 UINT start, /* [in] Index of first entry to set */
326 UINT count, /* [in] Number of entries to set */
327 const PALETTEENTRY *entries) /* [in] Address of array of structures */
332 TRACE("hpal=%p,start=%i,count=%i\n",hpalette,start,count );
334 if (hpalette == GetStockObject(DEFAULT_PALETTE)) return 0;
335 palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
336 if (!palPtr) return 0;
338 numEntries = palPtr->logpalette.palNumEntries;
339 if (start >= numEntries)
341 GDI_ReleaseObj( hpalette );
344 if (start+count > numEntries) count = numEntries - start;
345 memcpy( &palPtr->logpalette.palPalEntry[start], entries,
346 count * sizeof(PALETTEENTRY) );
347 UnrealizeObject( hpalette );
348 GDI_ReleaseObj( hpalette );
353 /***********************************************************************
354 * ResizePalette [GDI32.@]
356 * Resizes logical palette.
362 BOOL WINAPI ResizePalette(
363 HPALETTE hPal, /* [in] Handle of logical palette */
364 UINT cEntries) /* [in] Number of entries in logical palette */
366 PALETTEOBJ * palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hPal, PALETTE_MAGIC );
367 UINT cPrevEnt, prevVer;
368 int prevsize, size = sizeof(LOGPALETTE) + (cEntries - 1) * sizeof(PALETTEENTRY);
370 TRACE("hpal = %p, prev = %i, new = %i\n",
371 hPal, palPtr ? palPtr->logpalette.palNumEntries : -1, cEntries );
372 if( !palPtr ) return FALSE;
373 cPrevEnt = palPtr->logpalette.palNumEntries;
374 prevVer = palPtr->logpalette.palVersion;
375 prevsize = sizeof(LOGPALETTE) + (cPrevEnt - 1) * sizeof(PALETTEENTRY) +
376 sizeof(int*) + sizeof(GDIOBJHDR);
377 size += sizeof(int*) + sizeof(GDIOBJHDR);
379 if (!(palPtr = GDI_ReallocObject( size, hPal, palPtr ))) return FALSE;
381 PALETTE_UnrealizeObject( hPal, palPtr );
383 if( cEntries > cPrevEnt ) memset( (BYTE*)palPtr + prevsize, 0, size - prevsize );
384 palPtr->logpalette.palNumEntries = cEntries;
385 palPtr->logpalette.palVersion = prevVer;
386 GDI_ReleaseObj( hPal );
391 /***********************************************************************
392 * AnimatePalette [GDI32.@]
394 * Replaces entries in logical palette.
401 * Should use existing mapping when animating a primary palette
403 BOOL WINAPI AnimatePalette(
404 HPALETTE hPal, /* [in] Handle to logical palette */
405 UINT StartIndex, /* [in] First entry in palette */
406 UINT NumEntries, /* [in] Count of entries in palette */
407 const PALETTEENTRY* PaletteColors) /* [in] Pointer to first replacement */
409 TRACE("%p (%i - %i)\n", hPal, StartIndex,StartIndex+NumEntries);
411 if( hPal != GetStockObject(DEFAULT_PALETTE) )
415 const PALETTEENTRY *pptr = PaletteColors;
417 palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hPal, PALETTE_MAGIC );
418 if (!palPtr) return 0;
420 pal_entries = palPtr->logpalette.palNumEntries;
421 if (StartIndex >= pal_entries)
423 GDI_ReleaseObj( hPal );
426 if (StartIndex+NumEntries > pal_entries) NumEntries = pal_entries - StartIndex;
428 for (NumEntries += StartIndex; StartIndex < NumEntries; StartIndex++, pptr++) {
429 /* According to MSDN, only animate PC_RESERVED colours */
430 if (palPtr->logpalette.palPalEntry[StartIndex].peFlags & PC_RESERVED) {
431 TRACE("Animating colour (%d,%d,%d) to (%d,%d,%d)\n",
432 palPtr->logpalette.palPalEntry[StartIndex].peRed,
433 palPtr->logpalette.palPalEntry[StartIndex].peGreen,
434 palPtr->logpalette.palPalEntry[StartIndex].peBlue,
435 pptr->peRed, pptr->peGreen, pptr->peBlue);
436 memcpy( &palPtr->logpalette.palPalEntry[StartIndex], pptr,
437 sizeof(PALETTEENTRY) );
439 TRACE("Not animating entry %d -- not PC_RESERVED\n", StartIndex);
442 if (palPtr->funcs && palPtr->funcs->pRealizePalette)
443 palPtr->funcs->pRealizePalette( NULL, hPal, hPal == hPrimaryPalette );
445 GDI_ReleaseObj( hPal );
451 /***********************************************************************
452 * SetSystemPaletteUse [GDI32.@]
454 * Specify whether the system palette contains 2 or 20 static colors.
457 * Success: Previous system palette
458 * Failure: SYSPAL_ERROR
460 UINT WINAPI SetSystemPaletteUse(
461 HDC hdc, /* [in] Handle of device context */
462 UINT use) /* [in] Palette-usage flag */
464 UINT old = SystemPaletteUse;
466 /* Device doesn't support colour palettes */
467 if (!(GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)) {
472 case SYSPAL_NOSTATIC:
473 case SYSPAL_NOSTATIC256: /* WINVER >= 0x0500 */
475 SystemPaletteUse = use;
483 /***********************************************************************
484 * GetSystemPaletteUse [GDI32.@]
486 * Gets state of system palette.
489 * Current state of system palette
491 UINT WINAPI GetSystemPaletteUse(
492 HDC hdc) /* [in] Handle of device context */
494 return SystemPaletteUse;
498 /***********************************************************************
499 * GetSystemPaletteEntries [GDI32.@]
501 * Gets range of palette entries.
504 * Success: Number of entries retrieved from palette
507 UINT WINAPI GetSystemPaletteEntries(
508 HDC hdc, /* [in] Handle of device context */
509 UINT start, /* [in] Index of first entry to be retrieved */
510 UINT count, /* [in] Number of entries to be retrieved */
511 LPPALETTEENTRY entries) /* [out] Array receiving system-palette entries */
516 TRACE("hdc=%p,start=%i,count=%i\n", hdc,start,count);
518 if ((dc = DC_GetDCPtr( hdc )))
520 if (dc->funcs->pGetSystemPaletteEntries)
521 ret = dc->funcs->pGetSystemPaletteEntries( dc->physDev, start, count, entries );
522 GDI_ReleaseObj( hdc );
528 /***********************************************************************
529 * GetNearestPaletteIndex [GDI32.@]
531 * Gets palette index for color.
534 * Should index be initialized to CLR_INVALID instead of 0?
537 * Success: Index of entry in logical palette
538 * Failure: CLR_INVALID
540 UINT WINAPI GetNearestPaletteIndex(
541 HPALETTE hpalette, /* [in] Handle of logical color palette */
542 COLORREF color) /* [in] Color to be matched */
544 PALETTEOBJ* palObj = (PALETTEOBJ*)GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
549 int i, diff = 0x7fffffff;
551 PALETTEENTRY* entry = palObj->logpalette.palPalEntry;
553 for( i = 0; i < palObj->logpalette.palNumEntries && diff ; i++, entry++)
555 r = entry->peRed - GetRValue(color);
556 g = entry->peGreen - GetGValue(color);
557 b = entry->peBlue - GetBValue(color);
561 if( r < diff ) { index = i; diff = r; }
563 GDI_ReleaseObj( hpalette );
565 TRACE("(%p,%06x): returning %d\n", hpalette, color, index );
570 /***********************************************************************
571 * GetNearestColor [GDI32.@]
573 * Gets a system color to match.
576 * Success: Color from system palette that corresponds to given color
577 * Failure: CLR_INVALID
579 COLORREF WINAPI GetNearestColor(
580 HDC hdc, /* [in] Handle of device context */
581 COLORREF color) /* [in] Color to be matched */
583 unsigned char spec_type;
587 if (!(dc = DC_GetDCPtr( hdc ))) return CLR_INVALID;
589 if (dc->funcs->pGetNearestColor)
591 nearest = dc->funcs->pGetNearestColor( dc->physDev, color );
592 GDI_ReleaseObj( hdc );
596 if (!(GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE))
598 GDI_ReleaseObj( hdc );
602 spec_type = color >> 24;
603 if (spec_type == 1 || spec_type == 2)
605 /* we need logical palette for PALETTERGB and PALETTEINDEX colorrefs */
609 HPALETTE hpal = dc->hPalette ? dc->hPalette : GetStockObject( DEFAULT_PALETTE );
611 if (spec_type == 2) /* PALETTERGB */
612 index = GetNearestPaletteIndex( hpal, color );
613 else /* PALETTEINDEX */
614 index = LOWORD(color);
616 if (!GetPaletteEntries( hpal, index, 1, &entry ))
618 WARN("RGB(%x) : idx %d is out of bounds, assuming NULL\n", color, index );
619 if (!GetPaletteEntries( hpal, 0, 1, &entry ))
621 GDI_ReleaseObj( hdc );
625 color = RGB( entry.peRed, entry.peGreen, entry.peBlue );
627 nearest = color & 0x00ffffff;
628 GDI_ReleaseObj( hdc );
630 TRACE("(%06x): returning %06x\n", color, nearest );
635 /***********************************************************************
638 static INT PALETTE_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer )
640 PALETTEOBJ *palette = obj;
645 if (count > sizeof(WORD)) count = sizeof(WORD);
646 memcpy( buffer, &palette->logpalette.palNumEntries, count );
651 /***********************************************************************
652 * PALETTE_UnrealizeObject
654 static BOOL PALETTE_UnrealizeObject( HGDIOBJ handle, void *obj )
656 PALETTEOBJ *palette = obj;
660 if (palette->funcs->pUnrealizePalette)
661 palette->funcs->pUnrealizePalette( handle );
662 palette->funcs = NULL;
665 if (hLastRealizedPalette == handle)
667 TRACE("unrealizing palette %p\n", handle);
668 hLastRealizedPalette = 0;
674 /***********************************************************************
675 * PALETTE_DeleteObject
677 static BOOL PALETTE_DeleteObject( HGDIOBJ handle, void *obj )
679 PALETTE_UnrealizeObject( handle, obj );
680 return GDI_FreeObject( handle, obj );
684 /***********************************************************************
685 * GDISelectPalette (Not a Windows API)
687 HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg)
692 TRACE("%p %p\n", hdc, hpal );
694 if (GetObjectType(hpal) != OBJ_PAL)
696 WARN("invalid selected palette %p\n",hpal);
699 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
701 if (dc->funcs->pSelectPalette) hpal = dc->funcs->pSelectPalette( dc->physDev, hpal, FALSE );
705 if (!wBkg) hPrimaryPalette = hpal;
708 GDI_ReleaseObj( hdc );
713 /***********************************************************************
714 * GDIRealizePalette (Not a Windows API)
716 UINT WINAPI GDIRealizePalette( HDC hdc )
719 DC* dc = DC_GetDCPtr( hdc );
723 TRACE("%p...\n", hdc );
725 if( dc->hPalette == GetStockObject( DEFAULT_PALETTE ))
727 if (dc->funcs->pRealizeDefaultPalette)
728 realized = dc->funcs->pRealizeDefaultPalette( dc->physDev );
730 else if(dc->hPalette != hLastRealizedPalette )
732 if (dc->funcs->pRealizePalette)
734 PALETTEOBJ *palPtr = GDI_GetObjPtr( dc->hPalette, PALETTE_MAGIC );
737 realized = dc->funcs->pRealizePalette( dc->physDev, dc->hPalette,
738 (dc->hPalette == hPrimaryPalette) );
739 palPtr->funcs = dc->funcs;
740 GDI_ReleaseObj( dc->hPalette );
743 hLastRealizedPalette = dc->hPalette;
745 else TRACE(" skipping (hLastRealizedPalette = %p)\n", hLastRealizedPalette);
747 GDI_ReleaseObj( hdc );
748 TRACE(" realized %i colors.\n", realized );
753 /***********************************************************************
754 * RealizeDefaultPalette (GDI.365)
756 UINT16 WINAPI RealizeDefaultPalette16( HDC16 hdc )
761 TRACE("%04x\n", hdc );
763 if (!(dc = DC_GetDCPtr( HDC_32(hdc) ))) return 0;
765 if (dc->funcs->pRealizeDefaultPalette) ret = dc->funcs->pRealizeDefaultPalette( dc->physDev );
766 GDI_ReleaseObj( HDC_32(hdc) );
770 /***********************************************************************
771 * IsDCCurrentPalette (GDI.412)
773 BOOL16 WINAPI IsDCCurrentPalette16(HDC16 hDC)
775 DC *dc = DC_GetDCPtr( HDC_32(hDC) );
778 BOOL bRet = dc->hPalette == hPrimaryPalette;
779 GDI_ReleaseObj( HDC_32(hDC) );
786 /***********************************************************************
787 * SelectPalette [GDI32.@]
789 * Selects logical palette into DC.
792 * Success: Previous logical palette
795 HPALETTE WINAPI SelectPalette(
796 HDC hDC, /* [in] Handle of device context */
797 HPALETTE hPal, /* [in] Handle of logical color palette */
798 BOOL bForceBackground) /* [in] Foreground/background mode */
800 return pfnSelectPalette( hDC, hPal, bForceBackground );
804 /***********************************************************************
805 * RealizePalette [GDI32.@]
807 * Maps palette entries to system palette.
810 * Success: Number of entries in logical palette
813 UINT WINAPI RealizePalette(
814 HDC hDC) /* [in] Handle of device context */
816 return pfnRealizePalette( hDC );
820 typedef HWND (WINAPI *WindowFromDC_funcptr)( HDC );
821 typedef BOOL (WINAPI *RedrawWindow_funcptr)( HWND, const RECT *, HRGN, UINT );
823 /**********************************************************************
824 * UpdateColors [GDI32.@]
826 * Remaps current colors to logical palette.
832 BOOL WINAPI UpdateColors(
833 HDC hDC) /* [in] Handle of device context */
836 int size = GetDeviceCaps( hDC, SIZEPALETTE );
840 mod = GetModuleHandleA("user32.dll");
843 WindowFromDC_funcptr pWindowFromDC = (WindowFromDC_funcptr)GetProcAddress(mod,"WindowFromDC");
846 HWND hWnd = pWindowFromDC( hDC );
848 /* Docs say that we have to remap current drawable pixel by pixel
849 * but it would take forever given the speed of XGet/PutPixel.
853 RedrawWindow_funcptr pRedrawWindow = GetProcAddress( mod, "RedrawWindow" );
854 if (pRedrawWindow) pRedrawWindow( hWnd, NULL, 0, RDW_INVALIDATE );
862 /*********************************************************************
863 * SetMagicColors (GDI.606)
865 VOID WINAPI SetMagicColors16(HDC16 hDC, COLORREF color, UINT16 index)
867 FIXME("(hDC %04x, color %04x, index %04x): stub\n", hDC, (int)color, index);
871 /*********************************************************************
872 * SetMagicColors (GDI.@)
874 BOOL WINAPI SetMagicColors(HDC hdc, ULONG u1, ULONG u2)
876 FIXME("(%p 0x%08x 0x%08x): stub\n", hdc, u1, u2);
880 /**********************************************************************
881 * GetICMProfileA [GDI32.@]
883 * Returns the filename of the specified device context's color
884 * management profile, even if color management is not enabled
888 * TRUE if name copied successfully OR lpszFilename is NULL
889 * FALSE if the buffer length pointed to by lpcbName is too small
892 * The buffer length pointed to by lpcbName is ALWAYS updated to
893 * the length required regardless of other actions this function
897 * How does Windows assign these? Some registry key?
901 /*********************************************************************/
903 BOOL WINAPI GetICMProfileA(HDC hDC, LPDWORD lpcbName, LPSTR lpszFilename)
906 static const char icm[] = "winefake.icm";
908 FIXME("(%p, %p, %p): partial stub\n", hDC, lpcbName, lpszFilename);
910 callerLen = *lpcbName;
912 /* all 3 behaviors require the required buffer size to be set */
913 *lpcbName = sizeof(icm);
915 /* behavior 1: if lpszFilename is NULL, return size of string and no error */
916 if (!lpszFilename) return TRUE;
918 /* behavior 2: if buffer size too small, return size of string and error */
919 if (callerLen < sizeof(icm))
921 SetLastError(ERROR_INSUFFICIENT_BUFFER);
925 /* behavior 3: if buffer size OK and pointer not NULL, copy and return size */
926 memcpy(lpszFilename, icm, sizeof(icm));
930 /**********************************************************************
931 * GetICMProfileW [GDI32.@]
933 BOOL WINAPI GetICMProfileW(HDC hDC, LPDWORD lpcbName, LPWSTR lpszFilename)
936 static const WCHAR icm[] = { 'w','i','n','e','f','a','k','e','.','i','c','m', 0 };
938 FIXME("(%p, %p, %p): partial stub\n", hDC, lpcbName, lpszFilename);
940 callerLen = *lpcbName;
942 /* all 3 behaviors require the required buffer size to be set */
943 *lpcbName = sizeof(icm) / sizeof(WCHAR);
945 /* behavior 1: if lpszFilename is NULL, return size of string and no error */
946 if (!lpszFilename) return TRUE;
948 /* behavior 2: if buffer size too small, return size of string and error */
949 if (callerLen < sizeof(icm)/sizeof(WCHAR))
951 SetLastError(ERROR_INSUFFICIENT_BUFFER);
955 /* behavior 3: if buffer size OK and pointer not NULL, copy and return size */
956 memcpy(lpszFilename, icm, sizeof(icm));
960 /**********************************************************************
961 * GetLogColorSpaceA [GDI32.@]
964 BOOL WINAPI GetLogColorSpaceA(HCOLORSPACE hColorSpace, LPLOGCOLORSPACEA lpBuffer, DWORD nSize)
966 FIXME("%p %p 0x%08x: stub!\n", hColorSpace, lpBuffer, nSize);
970 /**********************************************************************
971 * GetLogColorSpaceW [GDI32.@]
974 BOOL WINAPI GetLogColorSpaceW(HCOLORSPACE hColorSpace, LPLOGCOLORSPACEW lpBuffer, DWORD nSize)
976 FIXME("%p %p 0x%08x: stub!\n", hColorSpace, lpBuffer, nSize);
980 /**********************************************************************
981 * SetICMProfileA [GDI32.@]
984 BOOL WINAPI SetICMProfileA(HDC hDC, LPSTR lpszFilename)
986 FIXME("hDC %p filename %s: stub!\n", hDC, debugstr_a(lpszFilename));
987 return TRUE; /* success */
990 /**********************************************************************
991 * SetICMProfileA [GDI32.@]
994 BOOL WINAPI SetICMProfileW(HDC hDC, LPWSTR lpszFilename)
996 FIXME("hDC %p filename %s: stub!\n", hDC, debugstr_w(lpszFilename));
997 return TRUE; /* success */
1000 /**********************************************************************
1001 * UpdateICMRegKeyA [GDI32.@]
1004 BOOL WINAPI UpdateICMRegKeyA(DWORD dwReserved, LPSTR lpszCMID, LPSTR lpszFileName, UINT nCommand)
1006 FIXME("(0x%08x, %s, %s, 0x%08x): stub!\n", dwReserved, debugstr_a(lpszCMID),
1007 debugstr_a(lpszFileName), nCommand);
1008 return TRUE; /* success */
1011 /**********************************************************************
1012 * UpdateICMRegKeyW [GDI32.@]
1015 BOOL WINAPI UpdateICMRegKeyW(DWORD dwReserved, LPWSTR lpszCMID, LPWSTR lpszFileName, UINT nCommand)
1017 FIXME("(0x%08x, %s, %s, 0x%08x): stub!\n", dwReserved, debugstr_w(lpszCMID),
1018 debugstr_w(lpszFileName), nCommand);
1019 return TRUE; /* success */