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, INT count, LPVOID buffer );
49 static BOOL PALETTE_UnrealizeObject( HGDIOBJ handle );
50 static BOOL PALETTE_DeleteObject( HGDIOBJ handle );
52 static const struct gdi_obj_funcs palette_funcs =
54 NULL, /* pSelectObject */
55 PALETTE_GetObject, /* pGetObjectA */
56 PALETTE_GetObject, /* pGetObjectW */
57 PALETTE_UnrealizeObject, /* pUnrealizeObject */
58 PALETTE_DeleteObject /* pDeleteObject */
61 /* Pointers to USER implementation of SelectPalette/RealizePalette */
62 /* they will be patched by USER on startup */
63 HPALETTE (WINAPI *pfnSelectPalette)(HDC hdc, HPALETTE hpal, WORD bkgnd ) = GDISelectPalette;
64 UINT (WINAPI *pfnRealizePalette)(HDC hdc) = GDIRealizePalette;
66 static UINT SystemPaletteUse = SYSPAL_STATIC; /* currently not considered */
68 static HPALETTE hPrimaryPalette = 0; /* used for WM_PALETTECHANGED */
69 static HPALETTE hLastRealizedPalette = 0; /* UnrealizeObject() needs it */
71 #define NB_RESERVED_COLORS 20 /* number of fixed colors in system palette */
73 static const PALETTEENTRY sys_pal_template[NB_RESERVED_COLORS] =
75 /* first 10 entries in the system palette */
76 /* red green blue flags */
77 { 0x00, 0x00, 0x00, 0 },
78 { 0x80, 0x00, 0x00, 0 },
79 { 0x00, 0x80, 0x00, 0 },
80 { 0x80, 0x80, 0x00, 0 },
81 { 0x00, 0x00, 0x80, 0 },
82 { 0x80, 0x00, 0x80, 0 },
83 { 0x00, 0x80, 0x80, 0 },
84 { 0xc0, 0xc0, 0xc0, 0 },
85 { 0xc0, 0xdc, 0xc0, 0 },
86 { 0xa6, 0xca, 0xf0, 0 },
88 /* ... c_min/2 dynamic colorcells */
90 /* ... gap (for sparse palettes) */
92 /* ... c_min/2 dynamic colorcells */
94 { 0xff, 0xfb, 0xf0, 0 },
95 { 0xa0, 0xa0, 0xa4, 0 },
96 { 0x80, 0x80, 0x80, 0 },
97 { 0xff, 0x00, 0x00, 0 },
98 { 0x00, 0xff, 0x00, 0 },
99 { 0xff, 0xff, 0x00, 0 },
100 { 0x00, 0x00, 0xff, 0 },
101 { 0xff, 0x00, 0xff, 0 },
102 { 0x00, 0xff, 0xff, 0 },
103 { 0xff, 0xff, 0xff, 0 } /* last 10 */
106 /***********************************************************************
109 * Create the system palette.
111 HPALETTE PALETTE_Init(void)
116 /* create default palette (20 system colors) */
118 palPtr = HeapAlloc( GetProcessHeap(), 0,
119 sizeof(LOGPALETTE) + (NB_RESERVED_COLORS-1)*sizeof(PALETTEENTRY));
120 if (!palPtr) return FALSE;
122 palPtr->palVersion = 0x300;
123 palPtr->palNumEntries = NB_RESERVED_COLORS;
124 memcpy( palPtr->palPalEntry, sys_pal_template, sizeof(sys_pal_template) );
125 hpalette = CreatePalette( palPtr );
126 HeapFree( GetProcessHeap(), 0, palPtr );
131 /***********************************************************************
132 * CreatePalette [GDI32.@]
134 * Creates a logical color palette.
137 * Success: Handle to logical palette
140 HPALETTE WINAPI CreatePalette(
141 const LOGPALETTE* palette) /* [in] Pointer to logical color palette */
143 PALETTEOBJ * palettePtr;
147 if (!palette) return 0;
148 TRACE("entries=%i\n", palette->palNumEntries);
150 size = sizeof(LOGPALETTE) + (palette->palNumEntries - 1) * sizeof(PALETTEENTRY);
152 if (!(palettePtr = GDI_AllocObject( size + sizeof(int*) +sizeof(GDIOBJHDR),
153 PALETTE_MAGIC, (HGDIOBJ *)&hpalette,
154 &palette_funcs ))) return 0;
155 memcpy( &palettePtr->logpalette, palette, size );
156 palettePtr->funcs = NULL;
157 GDI_ReleaseObj( hpalette );
159 TRACE(" returning %p\n", hpalette);
164 /***********************************************************************
165 * CreateHalftonePalette [GDI32.@]
167 * Creates a halftone palette.
170 * Success: Handle to logical halftone palette
173 * FIXME: This simply creates the halftone palette derived from running
174 * tests on a windows NT machine. This is assuming a color depth
175 * of greater that 256 color. On a 256 color device the halftone
176 * palette will be different and this function will be incorrect
178 HPALETTE WINAPI CreateHalftonePalette(
179 HDC hdc) /* [in] Handle to device context */
184 WORD NumberOfEntries;
185 PALETTEENTRY aEntries[256];
188 Palette.Version = 0x300;
189 Palette.NumberOfEntries = 256;
190 GetSystemPaletteEntries(hdc, 0, 256, Palette.aEntries);
192 Palette.NumberOfEntries = 20;
194 for (i = 0; i < Palette.NumberOfEntries; i++)
196 Palette.aEntries[i].peRed=0xff;
197 Palette.aEntries[i].peGreen=0xff;
198 Palette.aEntries[i].peBlue=0xff;
199 Palette.aEntries[i].peFlags=0x00;
202 Palette.aEntries[0].peRed=0x00;
203 Palette.aEntries[0].peBlue=0x00;
204 Palette.aEntries[0].peGreen=0x00;
207 for (i=1; i <= 6; i++)
209 Palette.aEntries[i].peRed=(i%2)?0x80:0;
210 Palette.aEntries[i].peGreen=(i==2)?0x80:(i==3)?0x80:(i==6)?0x80:0;
211 Palette.aEntries[i].peBlue=(i>3)?0x80:0;
214 for (i=7; i <= 12; i++)
219 Palette.aEntries[i].peRed=0xc0;
220 Palette.aEntries[i].peBlue=0xc0;
221 Palette.aEntries[i].peGreen=0xc0;
224 Palette.aEntries[i].peRed=0xc0;
225 Palette.aEntries[i].peGreen=0xdc;
226 Palette.aEntries[i].peBlue=0xc0;
229 Palette.aEntries[i].peRed=0xa6;
230 Palette.aEntries[i].peGreen=0xca;
231 Palette.aEntries[i].peBlue=0xf0;
234 Palette.aEntries[i].peRed=0xff;
235 Palette.aEntries[i].peGreen=0xfb;
236 Palette.aEntries[i].peBlue=0xf0;
239 Palette.aEntries[i].peRed=0xa0;
240 Palette.aEntries[i].peGreen=0xa0;
241 Palette.aEntries[i].peBlue=0xa4;
244 Palette.aEntries[i].peRed=0x80;
245 Palette.aEntries[i].peGreen=0x80;
246 Palette.aEntries[i].peBlue=0x80;
250 for (i=13; i <= 18; i++)
252 Palette.aEntries[i].peRed=(i%2)?0xff:0;
253 Palette.aEntries[i].peGreen=(i==14)?0xff:(i==15)?0xff:(i==18)?0xff:0;
254 Palette.aEntries[i].peBlue=(i>15)?0xff:0x00;
257 return CreatePalette((LOGPALETTE *)&Palette);
261 /***********************************************************************
262 * GetPaletteEntries [GDI32.@]
264 * Retrieves palette entries.
267 * Success: Number of entries from logical palette
270 UINT WINAPI GetPaletteEntries(
271 HPALETTE hpalette, /* [in] Handle of logical palette */
272 UINT start, /* [in] First entry to receive */
273 UINT count, /* [in] Number of entries to receive */
274 LPPALETTEENTRY entries) /* [out] Address of array receiving entries */
279 TRACE("hpal = %p, count=%i\n", hpalette, count );
281 palPtr = GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
282 if (!palPtr) return 0;
284 /* NOTE: not documented but test show this to be the case */
287 int rc = palPtr->logpalette.palNumEntries;
288 GDI_ReleaseObj( hpalette );
292 numEntries = palPtr->logpalette.palNumEntries;
293 if (start+count > numEntries) count = numEntries - start;
296 if (start >= numEntries)
298 GDI_ReleaseObj( hpalette );
301 memcpy( entries, &palPtr->logpalette.palPalEntry[start],
302 count * sizeof(PALETTEENTRY) );
305 GDI_ReleaseObj( hpalette );
310 /***********************************************************************
311 * SetPaletteEntries [GDI32.@]
313 * Sets color values for range in palette.
316 * Success: Number of entries that were set
319 UINT WINAPI SetPaletteEntries(
320 HPALETTE hpalette, /* [in] Handle of logical palette */
321 UINT start, /* [in] Index of first entry to set */
322 UINT count, /* [in] Number of entries to set */
323 const PALETTEENTRY *entries) /* [in] Address of array of structures */
328 TRACE("hpal=%p,start=%i,count=%i\n",hpalette,start,count );
330 if (hpalette == GetStockObject(DEFAULT_PALETTE)) return 0;
331 palPtr = GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
332 if (!palPtr) return 0;
334 numEntries = palPtr->logpalette.palNumEntries;
335 if (start >= numEntries)
337 GDI_ReleaseObj( hpalette );
340 if (start+count > numEntries) count = numEntries - start;
341 memcpy( &palPtr->logpalette.palPalEntry[start], entries,
342 count * sizeof(PALETTEENTRY) );
343 UnrealizeObject( hpalette );
344 GDI_ReleaseObj( hpalette );
349 /***********************************************************************
350 * ResizePalette [GDI32.@]
352 * Resizes logical palette.
358 BOOL WINAPI ResizePalette(
359 HPALETTE hPal, /* [in] Handle of logical palette */
360 UINT cEntries) /* [in] Number of entries in logical palette */
362 PALETTEOBJ * palPtr = GDI_GetObjPtr( hPal, PALETTE_MAGIC );
363 UINT cPrevEnt, prevVer;
364 int prevsize, size = sizeof(LOGPALETTE) + (cEntries - 1) * sizeof(PALETTEENTRY);
366 TRACE("hpal = %p, prev = %i, new = %i\n",
367 hPal, palPtr ? palPtr->logpalette.palNumEntries : -1, cEntries );
368 if( !palPtr ) return FALSE;
369 cPrevEnt = palPtr->logpalette.palNumEntries;
370 prevVer = palPtr->logpalette.palVersion;
371 prevsize = sizeof(LOGPALETTE) + (cPrevEnt - 1) * sizeof(PALETTEENTRY) +
372 sizeof(int*) + sizeof(GDIOBJHDR);
373 size += sizeof(int*) + sizeof(GDIOBJHDR);
375 if (!(palPtr = GDI_ReallocObject( size, hPal, palPtr ))) return FALSE;
377 if( cEntries > cPrevEnt ) memset( (BYTE*)palPtr + prevsize, 0, size - prevsize );
378 palPtr->logpalette.palNumEntries = cEntries;
379 palPtr->logpalette.palVersion = prevVer;
380 GDI_ReleaseObj( hPal );
381 PALETTE_UnrealizeObject( hPal );
386 /***********************************************************************
387 * AnimatePalette [GDI32.@]
389 * Replaces entries in logical palette.
396 * Should use existing mapping when animating a primary palette
398 BOOL WINAPI AnimatePalette(
399 HPALETTE hPal, /* [in] Handle to logical palette */
400 UINT StartIndex, /* [in] First entry in palette */
401 UINT NumEntries, /* [in] Count of entries in palette */
402 const PALETTEENTRY* PaletteColors) /* [in] Pointer to first replacement */
404 TRACE("%p (%i - %i)\n", hPal, StartIndex,StartIndex+NumEntries);
406 if( hPal != GetStockObject(DEFAULT_PALETTE) )
410 const PALETTEENTRY *pptr = PaletteColors;
412 palPtr = GDI_GetObjPtr( hPal, PALETTE_MAGIC );
413 if (!palPtr) return 0;
415 pal_entries = palPtr->logpalette.palNumEntries;
416 if (StartIndex >= pal_entries)
418 GDI_ReleaseObj( hPal );
421 if (StartIndex+NumEntries > pal_entries) NumEntries = pal_entries - StartIndex;
423 for (NumEntries += StartIndex; StartIndex < NumEntries; StartIndex++, pptr++) {
424 /* According to MSDN, only animate PC_RESERVED colours */
425 if (palPtr->logpalette.palPalEntry[StartIndex].peFlags & PC_RESERVED) {
426 TRACE("Animating colour (%d,%d,%d) to (%d,%d,%d)\n",
427 palPtr->logpalette.palPalEntry[StartIndex].peRed,
428 palPtr->logpalette.palPalEntry[StartIndex].peGreen,
429 palPtr->logpalette.palPalEntry[StartIndex].peBlue,
430 pptr->peRed, pptr->peGreen, pptr->peBlue);
431 memcpy( &palPtr->logpalette.palPalEntry[StartIndex], pptr,
432 sizeof(PALETTEENTRY) );
434 TRACE("Not animating entry %d -- not PC_RESERVED\n", StartIndex);
437 if (palPtr->funcs && palPtr->funcs->pRealizePalette)
438 palPtr->funcs->pRealizePalette( NULL, hPal, hPal == hPrimaryPalette );
440 GDI_ReleaseObj( hPal );
446 /***********************************************************************
447 * SetSystemPaletteUse [GDI32.@]
449 * Specify whether the system palette contains 2 or 20 static colors.
452 * Success: Previous system palette
453 * Failure: SYSPAL_ERROR
455 UINT WINAPI SetSystemPaletteUse(
456 HDC hdc, /* [in] Handle of device context */
457 UINT use) /* [in] Palette-usage flag */
459 UINT old = SystemPaletteUse;
461 /* Device doesn't support colour palettes */
462 if (!(GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)) {
467 case SYSPAL_NOSTATIC:
468 case SYSPAL_NOSTATIC256: /* WINVER >= 0x0500 */
470 SystemPaletteUse = use;
478 /***********************************************************************
479 * GetSystemPaletteUse [GDI32.@]
481 * Gets state of system palette.
484 * Current state of system palette
486 UINT WINAPI GetSystemPaletteUse(
487 HDC hdc) /* [in] Handle of device context */
489 return SystemPaletteUse;
493 /***********************************************************************
494 * GetSystemPaletteEntries [GDI32.@]
496 * Gets range of palette entries.
499 * Success: Number of entries retrieved from palette
502 UINT WINAPI GetSystemPaletteEntries(
503 HDC hdc, /* [in] Handle of device context */
504 UINT start, /* [in] Index of first entry to be retrieved */
505 UINT count, /* [in] Number of entries to be retrieved */
506 LPPALETTEENTRY entries) /* [out] Array receiving system-palette entries */
511 TRACE("hdc=%p,start=%i,count=%i\n", hdc,start,count);
513 if ((dc = get_dc_ptr( hdc )))
515 if (dc->funcs->pGetSystemPaletteEntries)
516 ret = dc->funcs->pGetSystemPaletteEntries( dc->physDev, start, count, entries );
517 release_dc_ptr( dc );
523 /***********************************************************************
524 * GetNearestPaletteIndex [GDI32.@]
526 * Gets palette index for color.
529 * Should index be initialized to CLR_INVALID instead of 0?
532 * Success: Index of entry in logical palette
533 * Failure: CLR_INVALID
535 UINT WINAPI GetNearestPaletteIndex(
536 HPALETTE hpalette, /* [in] Handle of logical color palette */
537 COLORREF color) /* [in] Color to be matched */
539 PALETTEOBJ* palObj = GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
544 int i, diff = 0x7fffffff;
546 PALETTEENTRY* entry = palObj->logpalette.palPalEntry;
548 for( i = 0; i < palObj->logpalette.palNumEntries && diff ; i++, entry++)
550 r = entry->peRed - GetRValue(color);
551 g = entry->peGreen - GetGValue(color);
552 b = entry->peBlue - GetBValue(color);
556 if( r < diff ) { index = i; diff = r; }
558 GDI_ReleaseObj( hpalette );
560 TRACE("(%p,%06x): returning %d\n", hpalette, color, index );
565 /***********************************************************************
566 * GetNearestColor [GDI32.@]
568 * Gets a system color to match.
571 * Success: Color from system palette that corresponds to given color
572 * Failure: CLR_INVALID
574 COLORREF WINAPI GetNearestColor(
575 HDC hdc, /* [in] Handle of device context */
576 COLORREF color) /* [in] Color to be matched */
578 unsigned char spec_type;
582 if (!(dc = get_dc_ptr( hdc ))) return CLR_INVALID;
584 if (dc->funcs->pGetNearestColor)
586 nearest = dc->funcs->pGetNearestColor( dc->physDev, color );
587 release_dc_ptr( dc );
591 if (!(GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE))
593 release_dc_ptr( dc );
597 spec_type = color >> 24;
598 if (spec_type == 1 || spec_type == 2)
600 /* we need logical palette for PALETTERGB and PALETTEINDEX colorrefs */
604 HPALETTE hpal = dc->hPalette ? dc->hPalette : GetStockObject( DEFAULT_PALETTE );
606 if (spec_type == 2) /* PALETTERGB */
607 index = GetNearestPaletteIndex( hpal, color );
608 else /* PALETTEINDEX */
609 index = LOWORD(color);
611 if (!GetPaletteEntries( hpal, index, 1, &entry ))
613 WARN("RGB(%x) : idx %d is out of bounds, assuming NULL\n", color, index );
614 if (!GetPaletteEntries( hpal, 0, 1, &entry ))
616 release_dc_ptr( dc );
620 color = RGB( entry.peRed, entry.peGreen, entry.peBlue );
622 nearest = color & 0x00ffffff;
623 release_dc_ptr( dc );
625 TRACE("(%06x): returning %06x\n", color, nearest );
630 /***********************************************************************
633 static INT PALETTE_GetObject( HGDIOBJ handle, INT count, LPVOID buffer )
635 PALETTEOBJ *palette = GDI_GetObjPtr( handle, PALETTE_MAGIC );
637 if (!palette) return 0;
641 if (count > sizeof(WORD)) count = sizeof(WORD);
642 memcpy( buffer, &palette->logpalette.palNumEntries, count );
644 else count = sizeof(WORD);
645 GDI_ReleaseObj( handle );
650 /***********************************************************************
651 * PALETTE_UnrealizeObject
653 static BOOL PALETTE_UnrealizeObject( HGDIOBJ handle )
655 PALETTEOBJ *palette = GDI_GetObjPtr( handle, PALETTE_MAGIC );
659 const DC_FUNCTIONS *funcs = palette->funcs;
660 palette->funcs = NULL;
661 GDI_ReleaseObj( handle );
662 if (funcs && funcs->pUnrealizePalette) funcs->pUnrealizePalette( handle );
665 if (InterlockedCompareExchangePointer( (void **)&hLastRealizedPalette, 0, handle ) == handle)
666 TRACE("unrealizing palette %p\n", handle);
672 /***********************************************************************
673 * PALETTE_DeleteObject
675 static BOOL PALETTE_DeleteObject( HGDIOBJ handle )
679 PALETTE_UnrealizeObject( handle );
680 if (!(obj = GDI_GetObjPtr( handle, PALETTE_MAGIC ))) return FALSE;
681 return GDI_FreeObject( handle, obj );
685 /***********************************************************************
686 * GDISelectPalette (Not a Windows API)
688 HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg)
693 TRACE("%p %p\n", hdc, hpal );
695 if (GetObjectType(hpal) != OBJ_PAL)
697 WARN("invalid selected palette %p\n",hpal);
700 if (!(dc = get_dc_ptr( hdc ))) return 0;
702 if (dc->funcs->pSelectPalette) hpal = dc->funcs->pSelectPalette( dc->physDev, hpal, FALSE );
706 if (!wBkg) hPrimaryPalette = hpal;
709 release_dc_ptr( dc );
714 /***********************************************************************
715 * GDIRealizePalette (Not a Windows API)
717 UINT WINAPI GDIRealizePalette( HDC hdc )
720 DC* dc = get_dc_ptr( hdc );
724 TRACE("%p...\n", hdc );
726 if( dc->hPalette == GetStockObject( DEFAULT_PALETTE ))
728 if (dc->funcs->pRealizeDefaultPalette)
729 realized = dc->funcs->pRealizeDefaultPalette( dc->physDev );
731 else if (InterlockedExchangePointer( (void **)&hLastRealizedPalette, dc->hPalette ) != dc->hPalette)
733 if (dc->funcs->pRealizePalette)
735 PALETTEOBJ *palPtr = GDI_GetObjPtr( dc->hPalette, PALETTE_MAGIC );
738 realized = dc->funcs->pRealizePalette( dc->physDev, dc->hPalette,
739 (dc->hPalette == hPrimaryPalette) );
740 palPtr->funcs = dc->funcs;
741 GDI_ReleaseObj( dc->hPalette );
745 else TRACE(" skipping (hLastRealizedPalette = %p)\n", hLastRealizedPalette);
747 release_dc_ptr( dc );
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 = get_dc_ptr( HDC_32(hdc) ))) return 0;
765 if (dc->funcs->pRealizeDefaultPalette) ret = dc->funcs->pRealizeDefaultPalette( dc->physDev );
766 release_dc_ptr( dc );
770 /***********************************************************************
771 * IsDCCurrentPalette (GDI.412)
773 BOOL16 WINAPI IsDCCurrentPalette16(HDC16 hDC)
775 DC *dc = get_dc_ptr( HDC_32(hDC) );
778 BOOL bRet = dc->hPalette == hPrimaryPalette;
779 release_dc_ptr( dc );
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 = (void *)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 (GDI32.@)
874 BOOL WINAPI SetMagicColors(HDC hdc, ULONG u1, ULONG u2)
876 FIXME("(%p 0x%08x 0x%08x): stub\n", hdc, u1, u2);