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"
24 DEFAULT_DEBUG_CHANNEL(palette
);
26 PALETTE_DRIVER
*PALETTE_Driver
= NULL
;
28 /* Pointers to USER implementation of SelectPalette/RealizePalette */
29 /* they will be patched by USER on startup */
30 FARPROC pfnSelectPalette
= NULL
;
31 FARPROC pfnRealizePalette
= NULL
;
33 static UINT SystemPaletteUse
= SYSPAL_STATIC
; /* currently not considered */
35 static HPALETTE16 hPrimaryPalette
= 0; /* used for WM_PALETTECHANGED */
36 static HPALETTE16 hLastRealizedPalette
= 0; /* UnrealizeObject() needs it */
39 /***********************************************************************
42 * Create the system palette.
44 HPALETTE16
PALETTE_Init(void)
50 const PALETTEENTRY
* __sysPalTemplate
= COLOR_GetSystemPaletteTemplate();
52 /* create default palette (20 system colors) */
54 palPtr
= HeapAlloc( GetProcessHeap(), 0,
55 sizeof(LOGPALETTE
) + (NB_RESERVED_COLORS
-1)*sizeof(PALETTEENTRY
));
56 if (!palPtr
) return FALSE
;
58 palPtr
->palVersion
= 0x300;
59 palPtr
->palNumEntries
= NB_RESERVED_COLORS
;
60 for( i
= 0; i
< NB_RESERVED_COLORS
; i
++ )
62 palPtr
->palPalEntry
[i
].peRed
= __sysPalTemplate
[i
].peRed
;
63 palPtr
->palPalEntry
[i
].peGreen
= __sysPalTemplate
[i
].peGreen
;
64 palPtr
->palPalEntry
[i
].peBlue
= __sysPalTemplate
[i
].peBlue
;
65 palPtr
->palPalEntry
[i
].peFlags
= 0;
67 hpalette
= CreatePalette16( palPtr
);
68 HeapFree( GetProcessHeap(), 0, palPtr
);
70 palObj
= (PALETTEOBJ
*) GDI_GetObjPtr( hpalette
, PALETTE_MAGIC
);
73 if (!(palObj
->mapping
= HeapAlloc( GetProcessHeap(), 0, sizeof(int) * 20 )))
74 ERR("Can not create palette mapping -- out of memory!\n");
75 GDI_ReleaseObj( hpalette
);
80 /***********************************************************************
81 * PALETTE_ValidateFlags
83 void PALETTE_ValidateFlags(PALETTEENTRY
* lpPalE
, int size
)
87 lpPalE
[i
].peFlags
= PC_SYS_USED
| (lpPalE
[i
].peFlags
& 0x07);
91 /***********************************************************************
92 * CreatePalette (GDI.360)
94 HPALETTE16 WINAPI
CreatePalette16( const LOGPALETTE
* palette
)
96 return CreatePalette( palette
);
100 /***********************************************************************
101 * CreatePalette [GDI32.@] Creates a logical color palette
104 * Success: Handle to logical palette
107 HPALETTE WINAPI
CreatePalette(
108 const LOGPALETTE
* palette
) /* [in] Pointer to logical color palette */
110 PALETTEOBJ
* palettePtr
;
114 if (!palette
) return 0;
115 TRACE("entries=%i\n", palette
->palNumEntries
);
117 size
= sizeof(LOGPALETTE
) + (palette
->palNumEntries
- 1) * sizeof(PALETTEENTRY
);
119 if (!(palettePtr
= GDI_AllocObject( size
+ sizeof(int*) +sizeof(GDIOBJHDR
),
120 PALETTE_MAGIC
, &hpalette
))) return 0;
121 memcpy( &palettePtr
->logpalette
, palette
, size
);
122 PALETTE_ValidateFlags(palettePtr
->logpalette
.palPalEntry
,
123 palettePtr
->logpalette
.palNumEntries
);
124 palettePtr
->mapping
= NULL
;
125 GDI_ReleaseObj( hpalette
);
127 TRACE(" returning %04x\n", hpalette
);
132 /***********************************************************************
133 * CreateHalftonePalette [GDI.529] Creates a halftone palette
136 * Success: Handle to logical halftone palette
139 HPALETTE16 WINAPI
CreateHalftonePalette16(
140 HDC16 hdc
) /* [in] Handle to device context */
142 return CreateHalftonePalette(hdc
);
146 /***********************************************************************
147 * CreateHalftonePalette [GDI32.@] Creates a halftone palette
150 * Success: Handle to logical halftone palette
153 * FIXME: not truly tested
155 HPALETTE WINAPI
CreateHalftonePalette(
156 HDC hdc
) /* [in] Handle to device context */
161 WORD NumberOfEntries
;
162 PALETTEENTRY aEntries
[256];
165 Palette
.Version
= 0x300;
166 Palette
.NumberOfEntries
= 256;
167 GetSystemPaletteEntries(hdc
, 0, 256, Palette
.aEntries
);
169 for (r
= 0; r
< 6; r
++) {
170 for (g
= 0; g
< 6; g
++) {
171 for (b
= 0; b
< 6; b
++) {
172 i
= r
+ g
*6 + b
*36 + 10;
173 Palette
.aEntries
[i
].peRed
= r
* 51;
174 Palette
.aEntries
[i
].peGreen
= g
* 51;
175 Palette
.aEntries
[i
].peBlue
= b
* 51;
180 for (i
= 216; i
< 246; i
++) {
181 int v
= (i
- 216) * 8;
182 Palette
.aEntries
[i
].peRed
= v
;
183 Palette
.aEntries
[i
].peGreen
= v
;
184 Palette
.aEntries
[i
].peBlue
= v
;
187 return CreatePalette((LOGPALETTE
*)&Palette
);
191 /***********************************************************************
192 * GetPaletteEntries (GDI.363)
194 UINT16 WINAPI
GetPaletteEntries16( HPALETTE16 hpalette
, UINT16 start
,
195 UINT16 count
, LPPALETTEENTRY entries
)
197 return GetPaletteEntries( hpalette
, start
, count
, entries
);
201 /***********************************************************************
202 * GetPaletteEntries [GDI32.@] Retrieves palette entries
205 * Success: Number of entries from logical palette
208 UINT WINAPI
GetPaletteEntries(
209 HPALETTE hpalette
, /* [in] Handle of logical palette */
210 UINT start
, /* [in] First entry to receive */
211 UINT count
, /* [in] Number of entries to receive */
212 LPPALETTEENTRY entries
) /* [out] Address of array receiving entries */
217 TRACE("hpal = %04x, count=%i\n", hpalette
, count
);
219 palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( hpalette
, PALETTE_MAGIC
);
220 if (!palPtr
) return 0;
222 numEntries
= palPtr
->logpalette
.palNumEntries
;
223 if (start
+count
> numEntries
) count
= numEntries
- start
;
226 if (start
>= numEntries
)
228 GDI_ReleaseObj( hpalette
);
231 memcpy( entries
, &palPtr
->logpalette
.palPalEntry
[start
],
232 count
* sizeof(PALETTEENTRY
) );
233 for( numEntries
= 0; numEntries
< count
; numEntries
++ )
234 if (entries
[numEntries
].peFlags
& 0xF0)
235 entries
[numEntries
].peFlags
= 0;
238 GDI_ReleaseObj( hpalette
);
243 /***********************************************************************
244 * SetPaletteEntries (GDI.364)
246 UINT16 WINAPI
SetPaletteEntries16( HPALETTE16 hpalette
, UINT16 start
,
247 UINT16 count
, LPPALETTEENTRY entries
)
249 return SetPaletteEntries( hpalette
, start
, count
, entries
);
253 /***********************************************************************
254 * SetPaletteEntries [GDI32.@] Sets color values for range in palette
257 * Success: Number of entries that were set
260 UINT WINAPI
SetPaletteEntries(
261 HPALETTE hpalette
, /* [in] Handle of logical palette */
262 UINT start
, /* [in] Index of first entry to set */
263 UINT count
, /* [in] Number of entries to set */
264 LPPALETTEENTRY entries
) /* [in] Address of array of structures */
269 TRACE("hpal=%04x,start=%i,count=%i\n",hpalette
,start
,count
);
271 palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( hpalette
, PALETTE_MAGIC
);
272 if (!palPtr
) return 0;
274 numEntries
= palPtr
->logpalette
.palNumEntries
;
275 if (start
>= numEntries
)
277 GDI_ReleaseObj( hpalette
);
280 if (start
+count
> numEntries
) count
= numEntries
- start
;
281 memcpy( &palPtr
->logpalette
.palPalEntry
[start
], entries
,
282 count
* sizeof(PALETTEENTRY
) );
283 PALETTE_ValidateFlags(palPtr
->logpalette
.palPalEntry
,
284 palPtr
->logpalette
.palNumEntries
);
285 HeapFree( GetProcessHeap(), 0, palPtr
->mapping
);
286 palPtr
->mapping
= NULL
;
287 GDI_ReleaseObj( hpalette
);
292 /***********************************************************************
293 * ResizePalette (GDI.368)
295 BOOL16 WINAPI
ResizePalette16( HPALETTE16 hPal
, UINT16 cEntries
)
297 return ResizePalette( hPal
, cEntries
);
301 /***********************************************************************
302 * ResizePalette [GDI32.@] Resizes logical palette
308 BOOL WINAPI
ResizePalette(
309 HPALETTE hPal
, /* [in] Handle of logical palette */
310 UINT cEntries
) /* [in] Number of entries in logical palette */
312 PALETTEOBJ
* palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( hPal
, PALETTE_MAGIC
);
313 UINT cPrevEnt
, prevVer
;
314 int prevsize
, size
= sizeof(LOGPALETTE
) + (cEntries
- 1) * sizeof(PALETTEENTRY
);
317 TRACE("hpal = %04x, prev = %i, new = %i\n",
318 hPal
, palPtr
? palPtr
->logpalette
.palNumEntries
: -1,
320 if( !palPtr
) return FALSE
;
321 cPrevEnt
= palPtr
->logpalette
.palNumEntries
;
322 prevVer
= palPtr
->logpalette
.palVersion
;
323 prevsize
= sizeof(LOGPALETTE
) + (cPrevEnt
- 1) * sizeof(PALETTEENTRY
) +
324 sizeof(int*) + sizeof(GDIOBJHDR
);
325 size
+= sizeof(int*) + sizeof(GDIOBJHDR
);
326 mapping
= palPtr
->mapping
;
328 if (!(palPtr
= GDI_ReallocObject( size
, hPal
, palPtr
))) return FALSE
;
332 int *newMap
= (int*) HeapReAlloc(GetProcessHeap(), 0,
333 mapping
, cEntries
* sizeof(int) );
336 ERR("Can not resize mapping -- out of memory!\n");
337 GDI_ReleaseObj( hPal
);
340 palPtr
->mapping
= newMap
;
343 if( cEntries
> cPrevEnt
)
346 memset(palPtr
->mapping
+ cPrevEnt
, 0, (cEntries
- cPrevEnt
)*sizeof(int));
347 memset( (BYTE
*)palPtr
+ prevsize
, 0, size
- prevsize
);
348 PALETTE_ValidateFlags((PALETTEENTRY
*)((BYTE
*)palPtr
+ prevsize
),
349 cEntries
- cPrevEnt
);
351 palPtr
->logpalette
.palNumEntries
= cEntries
;
352 palPtr
->logpalette
.palVersion
= prevVer
;
353 GDI_ReleaseObj( hPal
);
358 /***********************************************************************
359 * AnimatePalette (GDI.367)
361 void WINAPI
AnimatePalette16( HPALETTE16 hPal
, UINT16 StartIndex
,
362 UINT16 NumEntries
, const PALETTEENTRY
* PaletteColors
)
364 AnimatePalette( hPal
, StartIndex
, NumEntries
, PaletteColors
);
368 /***********************************************************************
369 * AnimatePalette [GDI32.@] Replaces entries in logical palette
376 * Should use existing mapping when animating a primary palette
378 BOOL WINAPI
AnimatePalette(
379 HPALETTE hPal
, /* [in] Handle to logical palette */
380 UINT StartIndex
, /* [in] First entry in palette */
381 UINT NumEntries
, /* [in] Count of entries in palette */
382 const PALETTEENTRY
* PaletteColors
) /* [in] Pointer to first replacement */
384 TRACE("%04x (%i - %i)\n", hPal
, StartIndex
,StartIndex
+NumEntries
);
386 if( hPal
!= GetStockObject(DEFAULT_PALETTE
) )
388 PALETTEOBJ
* palPtr
= (PALETTEOBJ
*)GDI_GetObjPtr(hPal
, PALETTE_MAGIC
);
389 if (!palPtr
) return FALSE
;
391 if( (StartIndex
+ NumEntries
) <= palPtr
->logpalette
.palNumEntries
)
394 for( u
= 0; u
< NumEntries
; u
++ )
395 palPtr
->logpalette
.palPalEntry
[u
+ StartIndex
] = PaletteColors
[u
];
397 pSetMapping(palPtr
, StartIndex
, NumEntries
,
398 hPal
!= hPrimaryPalette
);
399 GDI_ReleaseObj( hPal
);
402 GDI_ReleaseObj( hPal
);
408 /***********************************************************************
409 * SetSystemPaletteUse (GDI.373)
411 UINT16 WINAPI
SetSystemPaletteUse16( HDC16 hdc
, UINT16 use
)
413 return SetSystemPaletteUse( hdc
, use
);
417 /***********************************************************************
418 * SetSystemPaletteUse [GDI32.@]
421 * Success: Previous system palette
422 * Failure: SYSPAL_ERROR
424 UINT WINAPI
SetSystemPaletteUse(
425 HDC hdc
, /* [in] Handle of device context */
426 UINT use
) /* [in] Palette-usage flag */
428 UINT old
= SystemPaletteUse
;
429 FIXME("(%04x,%04x): stub\n", hdc
, use
);
430 SystemPaletteUse
= use
;
435 /***********************************************************************
436 * GetSystemPaletteUse (GDI.374)
438 UINT16 WINAPI
GetSystemPaletteUse16( HDC16 hdc
)
440 return SystemPaletteUse
;
444 /***********************************************************************
445 * GetSystemPaletteUse [GDI32.@] Gets state of system palette
448 * Current state of system palette
450 UINT WINAPI
GetSystemPaletteUse(
451 HDC hdc
) /* [in] Handle of device context */
453 return SystemPaletteUse
;
457 /***********************************************************************
458 * GetSystemPaletteEntries (GDI.375)
460 UINT16 WINAPI
GetSystemPaletteEntries16( HDC16 hdc
, UINT16 start
, UINT16 count
,
461 LPPALETTEENTRY entries
)
463 return GetSystemPaletteEntries( hdc
, start
, count
, entries
);
467 /***********************************************************************
468 * GetSystemPaletteEntries [GDI32.@] Gets range of palette entries
471 * Success: Number of entries retrieved from palette
474 UINT WINAPI
GetSystemPaletteEntries(
475 HDC hdc
, /* [in] Handle of device context */
476 UINT start
, /* [in] Index of first entry to be retrieved */
477 UINT count
, /* [in] Number of entries to be retrieved */
478 LPPALETTEENTRY entries
) /* [out] Array receiving system-palette entries */
483 TRACE("hdc=%04x,start=%i,count=%i\n", hdc
,start
,count
);
485 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
489 count
= dc
->devCaps
->sizePalette
;
493 if (start
>= dc
->devCaps
->sizePalette
)
499 if (start
+count
>= dc
->devCaps
->sizePalette
)
500 count
= dc
->devCaps
->sizePalette
- start
;
501 for (i
= 0; i
< count
; i
++)
503 *(COLORREF
*)(entries
+ i
) = COLOR_GetSystemPaletteEntry( start
+ i
);
505 TRACE("\tidx(%02x) -> RGB(%08lx)\n",
506 start
+ i
, *(COLORREF
*)(entries
+ i
) );
509 GDI_ReleaseObj( hdc
);
514 /***********************************************************************
515 * GetNearestPaletteIndex (GDI.370)
517 UINT16 WINAPI
GetNearestPaletteIndex16( HPALETTE16 hpalette
, COLORREF color
)
519 return GetNearestPaletteIndex( hpalette
, color
);
523 /***********************************************************************
524 * GetNearestPaletteIndex [GDI32.@] Gets palette index for color
527 * Should index be initialized to CLR_INVALID instead of 0?
530 * Success: Index of entry in logical palette
531 * Failure: CLR_INVALID
533 UINT WINAPI
GetNearestPaletteIndex(
534 HPALETTE hpalette
, /* [in] Handle of logical color palette */
535 COLORREF color
) /* [in] Color to be matched */
537 PALETTEOBJ
* palObj
= (PALETTEOBJ
*)GDI_GetObjPtr( hpalette
, PALETTE_MAGIC
);
542 index
= COLOR_PaletteLookupPixel(palObj
->logpalette
.palPalEntry
,
543 palObj
->logpalette
.palNumEntries
,
544 NULL
, color
, FALSE
);
546 GDI_ReleaseObj( hpalette
);
548 TRACE("(%04x,%06lx): returning %d\n", hpalette
, color
, index
);
553 /***********************************************************************
554 * GetNearestColor (GDI.154)
556 COLORREF WINAPI
GetNearestColor16( HDC16 hdc
, COLORREF color
)
558 return GetNearestColor( hdc
, color
);
562 /***********************************************************************
563 * GetNearestColor [GDI32.@] Gets a system color to match
566 * Success: Color from system palette that corresponds to given color
567 * Failure: CLR_INVALID
569 COLORREF WINAPI
GetNearestColor(
570 HDC hdc
, /* [in] Handle of device context */
571 COLORREF color
) /* [in] Color to be matched */
573 COLORREF nearest
= CLR_INVALID
;
577 if ( (dc
= DC_GetDCPtr( hdc
)) )
579 HPALETTE hpal
= (dc
->hPalette
)? dc
->hPalette
: GetStockObject( DEFAULT_PALETTE
);
580 palObj
= GDI_GetObjPtr( hpal
, PALETTE_MAGIC
);
582 GDI_ReleaseObj( hdc
);
586 nearest
= COLOR_LookupNearestColor( palObj
->logpalette
.palPalEntry
,
587 palObj
->logpalette
.palNumEntries
, color
);
588 GDI_ReleaseObj( hpal
);
589 GDI_ReleaseObj( hdc
);
592 TRACE("(%06lx): returning %06lx\n", color
, nearest
);
597 /***********************************************************************
600 int PALETTE_GetObject( PALETTEOBJ
* palette
, int count
, LPSTR buffer
)
602 if (count
> sizeof(WORD
)) count
= sizeof(WORD
);
603 memcpy( buffer
, &palette
->logpalette
.palNumEntries
, count
);
608 /***********************************************************************
609 * PALETTE_UnrealizeObject
611 BOOL
PALETTE_UnrealizeObject( HPALETTE16 hpalette
, PALETTEOBJ
*palette
)
613 if (palette
->mapping
)
615 HeapFree( GetProcessHeap(), 0, palette
->mapping
);
616 palette
->mapping
= NULL
;
618 if (hLastRealizedPalette
== hpalette
) hLastRealizedPalette
= 0;
623 /***********************************************************************
624 * PALETTE_DeleteObject
626 BOOL
PALETTE_DeleteObject( HPALETTE16 hpalette
, PALETTEOBJ
*palette
)
628 HeapFree( GetProcessHeap(), 0, palette
->mapping
);
629 if (hLastRealizedPalette
== hpalette
) hLastRealizedPalette
= 0;
630 return GDI_FreeObject( hpalette
, palette
);
634 /***********************************************************************
635 * GDISelectPalette (GDI.361)
637 HPALETTE16 WINAPI
GDISelectPalette16( HDC16 hdc
, HPALETTE16 hpal
, WORD wBkg
)
642 TRACE("%04x %04x\n", hdc
, hpal
);
644 if (GetObjectType(hpal
) != OBJ_PAL
)
646 WARN("invalid selected palette %04x\n",hpal
);
649 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
652 GDI_ReleaseObj( hdc
);
653 if (!wBkg
) hPrimaryPalette
= hpal
;
658 /***********************************************************************
659 * GDIRealizePalette (GDI.362)
661 UINT16 WINAPI
GDIRealizePalette16( HDC16 hdc
)
665 DC
* dc
= DC_GetDCPtr( hdc
);
669 TRACE("%04x...\n", hdc
);
671 if(dc
->hPalette
!= hLastRealizedPalette
)
673 if( dc
->hPalette
== GetStockObject( DEFAULT_PALETTE
)) {
674 realized
= RealizeDefaultPalette16( hdc
);
675 GDI_ReleaseObj( hdc
);
676 return (UINT16
)realized
;
680 palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( dc
->hPalette
, PALETTE_MAGIC
);
683 GDI_ReleaseObj( hdc
);
684 FIXME("invalid selected palette %04x\n",dc
->hPalette
);
688 realized
= PALETTE_Driver
->
689 pSetMapping(palPtr
,0,palPtr
->logpalette
.palNumEntries
,
690 (dc
->hPalette
!= hPrimaryPalette
) ||
691 (dc
->hPalette
== GetStockObject( DEFAULT_PALETTE
)));
692 hLastRealizedPalette
= dc
->hPalette
;
693 GDI_ReleaseObj( dc
->hPalette
);
695 else TRACE(" skipping (hLastRealizedPalette = %04x)\n",
696 hLastRealizedPalette
);
697 GDI_ReleaseObj( hdc
);
699 TRACE(" realized %i colors.\n", realized
);
700 return (UINT16
)realized
;
704 /***********************************************************************
705 * RealizeDefaultPalette (GDI.365)
707 UINT16 WINAPI
RealizeDefaultPalette16( HDC16 hdc
)
713 TRACE("%04x\n", hdc
);
715 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
717 if (!(dc
->flags
& DC_MEMORY
))
719 palPtr
= (PALETTEOBJ
*)GDI_GetObjPtr( GetStockObject(DEFAULT_PALETTE
), PALETTE_MAGIC
);
722 /* lookup is needed to account for SetSystemPaletteUse() stuff */
723 ret
= PALETTE_Driver
->pUpdateMapping(palPtr
);
724 GDI_ReleaseObj( GetStockObject(DEFAULT_PALETTE
) );
727 GDI_ReleaseObj( hdc
);
731 /***********************************************************************
732 * IsDCCurrentPalette (GDI.412)
734 BOOL16 WINAPI
IsDCCurrentPalette16(HDC16 hDC
)
736 DC
*dc
= DC_GetDCPtr( hDC
);
739 BOOL bRet
= dc
->hPalette
== hPrimaryPalette
;
740 GDI_ReleaseObj( hDC
);
747 /***********************************************************************
748 * SelectPalette [GDI32.@] Selects logical palette into DC
751 * Success: Previous logical palette
754 HPALETTE WINAPI
SelectPalette(
755 HDC hDC
, /* [in] Handle of device context */
756 HPALETTE hPal
, /* [in] Handle of logical color palette */
757 BOOL bForceBackground
) /* [in] Foreground/background mode */
759 return pfnSelectPalette( hDC
, hPal
, bForceBackground
);
763 /***********************************************************************
764 * RealizePalette [GDI32.@] Maps palette entries to system palette
767 * Success: Number of entries in logical palette
770 UINT WINAPI
RealizePalette(
771 HDC hDC
) /* [in] Handle of device context */
773 return pfnRealizePalette( hDC
);
777 typedef HWND
WINAPI (*WindowFromDC_funcptr
)( HDC
);
778 typedef BOOL
WINAPI (*RedrawWindow_funcptr
)( HWND
, const RECT
*, HRGN
, UINT
);
780 /**********************************************************************
781 * UpdateColors [GDI32.@] Remaps current colors to logical palette
787 BOOL WINAPI
UpdateColors(
788 HDC hDC
) /* [in] Handle of device context */
794 if (!(dc
= DC_GetDCPtr( hDC
))) return 0;
795 size
= dc
->devCaps
->sizePalette
;
796 GDI_ReleaseObj( hDC
);
798 mod
= GetModuleHandleA("user32.dll");
801 WindowFromDC_funcptr pWindowFromDC
= (WindowFromDC_funcptr
)GetProcAddress(mod
,"WindowFromDC");
804 HWND hWnd
= pWindowFromDC( hDC
);
806 /* Docs say that we have to remap current drawable pixel by pixel
807 * but it would take forever given the speed of XGet/PutPixel.
811 RedrawWindow_funcptr pRedrawWindow
= GetProcAddress( mod
, "RedrawWindow" );
812 if (pRedrawWindow
) pRedrawWindow( hWnd
, NULL
, 0, RDW_INVALIDATE
);
820 /**********************************************************************
821 * UpdateColors (DISPLAY.366)
822 * UpdateColors16 (GDI.366)
824 INT16 WINAPI
UpdateColors16( HDC16 hDC
)
831 /*********************************************************************
832 * SetMagicColors (GDI.606)
834 VOID WINAPI
SetMagicColors16(HDC16 hDC
, COLORREF color
, UINT16 index
)
836 FIXME("(hDC %04x, color %04x, index %04x): stub\n", hDC
, (int)color
, index
);
840 /**********************************************************************
841 * GetICMProfileA [GDI32.@]
843 * Returns the filename of the specified device context's color
844 * management profile, even if color management is not enabled
848 * TRUE if name copied succesfully OR lpszFilename is NULL
849 * FALSE if the buffer length pointed to by lpcbName is too small
852 * The buffer length pointed to by lpcbName is ALWAYS updated to
853 * the length required regardless of other actions this function
857 * How does Windows assign these? Some registry key?
860 #define WINEICM "winefake.icm" /* easy-to-identify fake filename */
862 /*********************************************************************/
864 BOOL WINAPI
GetICMProfileA(HDC hDC
, LPDWORD lpcbName
, LPSTR lpszFilename
)
868 FIXME("(%04x, %p, %p): partial stub\n", hDC
, lpcbName
, lpszFilename
);
870 callerLen
= *lpcbName
;
872 /* all 3 behaviors require the required buffer size to be set */
873 *lpcbName
= strlen(WINEICM
);
875 /* behavior 1: if lpszFilename is NULL, return size of string and no error */
876 if ((DWORD
)lpszFilename
== (DWORD
)0x00000000)
879 /* behavior 2: if buffer size too small, return size of string and error */
880 if (callerLen
< strlen(WINEICM
))
882 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
886 /* behavior 3: if buffer size OK and pointer not NULL, copy and return size */
887 strcpy(lpszFilename
, WINEICM
);