ReactOS 0.4.17-dev-475-g46e69e6
palette.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32k subsystem
4 * PURPOSE: GDI Palette Functions
5 * FILE: win32ss/gdi/ntgdi/palette.c
6 * PROGRAMERS: Jason Filby
7 * Timo Kreuzer
8 */
9
10#include <win32k.h>
11
12#define NDEBUG
13#include <debug.h>
14
15#define PAL_SETPOWNER 0x8000
16#define MAX_PALCOLORS 65536
17
18static UINT SystemPaletteUse = SYSPAL_NOSTATIC; /* The program need save the pallete and restore it */
19
22
24{
25 // First 10 entries in the system palette
26 // Red Green Blue Flags
27 { 0x00, 0x00, 0x00, PC_SYS_USED },
28 { 0x80, 0x00, 0x00, PC_SYS_USED },
29 { 0x00, 0x80, 0x00, PC_SYS_USED },
30 { 0x80, 0x80, 0x00, PC_SYS_USED },
31 { 0x00, 0x00, 0x80, PC_SYS_USED },
32 { 0x80, 0x00, 0x80, PC_SYS_USED },
33 { 0x00, 0x80, 0x80, PC_SYS_USED },
34 { 0xc0, 0xc0, 0xc0, PC_SYS_USED },
35 { 0xc0, 0xdc, 0xc0, PC_SYS_USED },
36 { 0xa6, 0xca, 0xf0, PC_SYS_USED },
37
38 // ... c_min/2 dynamic colorcells
39 // ... gap (for sparse palettes)
40 // ... c_min/2 dynamic colorcells
41
42 { 0xff, 0xfb, 0xf0, PC_SYS_USED },
43 { 0xa0, 0xa0, 0xa4, PC_SYS_USED },
44 { 0x80, 0x80, 0x80, PC_SYS_USED },
45 { 0xff, 0x00, 0x00, PC_SYS_USED },
46 { 0x00, 0xff, 0x00, PC_SYS_USED },
47 { 0xff, 0xff, 0x00, PC_SYS_USED },
48 { 0x00, 0x00, 0xff, PC_SYS_USED },
49 { 0xff, 0x00, 0xff, PC_SYS_USED },
50 { 0x00, 0xff, 0xff, PC_SYS_USED },
51 { 0xff, 0xff, 0xff, PC_SYS_USED } // Last 10
52};
53
54unsigned short GetNumberOfBits(unsigned int dwMask)
55{
56 unsigned short wBits;
57 for (wBits = 0; dwMask; dwMask = dwMask & (dwMask - 1))
58 wBits++;
59 return wBits;
60}
61
62// Create the system palette
63CODE_SEG("INIT")
67{
68 // Create default palette (20 system colors)
70 20,
72 0, 0, 0);
75
76 /* palette_size = visual->map_entries; */
77
79 gpalRGB.RedMask = RGB(0xFF, 0x00, 0x00);
80 gpalRGB.GreenMask = RGB(0x00, 0xFF, 0x00);
81 gpalRGB.BlueMask = RGB(0x00, 0x00, 0xFF);
84
86 gpalBGR.RedMask = RGB(0x00, 0x00, 0xFF);
87 gpalBGR.GreenMask = RGB(0x00, 0xFF, 0x00);
88 gpalBGR.BlueMask = RGB(0xFF, 0x00, 0x00);
91
93 gpalRGB555.RedMask = 0x7C00;
94 gpalRGB555.GreenMask = 0x3E0;
95 gpalRGB555.BlueMask = 0x1F;
98
100 gpalRGB565.RedMask = 0xF800;
101 gpalRGB565.GreenMask = 0x7E0;
102 gpalRGB565.BlueMask = 0x1F;
105
109
110 /* Initialize default surface palettes */
121
122 return STATUS_SUCCESS;
123}
124
126{
127 int i = 0;
128 for (; i<size ; i++)
129 lpPalE[i].peFlags = PC_SYS_USED | (lpPalE[i].peFlags & 0x07);
130}
131
132
134NTAPI
137 _In_ ULONG cColors,
138 _In_opt_ const PALETTEENTRY* pEntries,
139 _In_ FLONG flRed,
140 _In_ FLONG flGreen,
141 _In_ FLONG flBlue)
142{
143 PPALETTE ppal;
144 ULONG fl = 0, cjSize = sizeof(PALETTE);
145
146 /* Check if the palette has entries */
147 if (iMode & PAL_INDEXED)
148 {
149 /* Check color count */
150 if ((cColors == 0) || (cColors > 1024)) return NULL;
151
152 /* Mark 2 color indexed palettes as monochrome */
153 if (cColors == 2) iMode |= PAL_MONOCHROME;
154
155 /* Allocate enough space for the palete entries */
156 cjSize += cColors * sizeof(PALETTEENTRY);
157 }
158 else
159 {
160 /* There are no palette entries */
161 cColors = 0;
162
163 /* We can use the lookaside list */
165 }
166
167 /* Allocate the object (without a handle!) */
169 if (!ppal)
170 {
171 return NULL;
172 }
173
174 /* Set mode, color count and entry pointer */
175 ppal->flFlags = iMode;
176 ppal->NumColors = cColors;
177 ppal->IndexedColors = ppal->apalColors;
178
179 /* Check what kind of palette this is */
180 if (iMode & PAL_INDEXED)
181 {
182 /* Check if we got a color array */
183 if (pEntries)
184 {
185 /* Copy the entries */
186 RtlCopyMemory(ppal->IndexedColors, pEntries, cColors * sizeof(pEntries[0]));
187 }
188 }
189 else if (iMode & PAL_BITFIELDS)
190 {
191 /* Copy the color masks */
192 ppal->RedMask = flRed;
193 ppal->GreenMask = flGreen;
194 ppal->BlueMask = flBlue;
195
196 /* Check what masks we have and set optimization flags */
197 if ((flRed == 0x7c00) && (flGreen == 0x3E0) && (flBlue == 0x1F))
198 ppal->flFlags |= PAL_RGB16_555;
199 else if ((flRed == 0xF800) && (flGreen == 0x7E0) && (flBlue == 0x1F))
200 ppal->flFlags |= PAL_RGB16_565;
201 else if ((flRed == 0xFF0000) && (flGreen == 0xFF00) && (flBlue == 0xFF))
202 ppal->flFlags |= PAL_BGR;
203 else if ((flRed == 0xFF) && (flGreen == 0xFF00) && (flBlue == 0xFF0000))
204 ppal->flFlags |= PAL_RGB;
205 }
206
207 return ppal;
208}
209
211NTAPI
214 _In_ ULONG cColors,
215 _In_opt_ const PALETTEENTRY* pEntries,
216 _In_ FLONG flRed,
217 _In_ FLONG flGreen,
218 _In_ FLONG flBlue)
219{
220 PPALETTE ppal;
221
222 /* Allocate the palette without a handle */
223 ppal = PALETTE_AllocPalette(iMode, cColors, pEntries, flRed, flGreen, flBlue);
224 if (!ppal) return NULL;
225
226 /* Insert the palette into the handle table */
228 {
229 DPRINT1("Could not insert palette into handle table.\n");
231 return NULL;
232 }
233
234 return ppal;
235}
236
237VOID
238NTAPI
240{
241 PPALETTE pPal = (PPALETTE)ObjectBody;
242 if (pPal->IndexedColors && pPal->IndexedColors != pPal->apalColors)
243 {
245 }
246}
247
248INT
251{
252 if (!lpBuffer)
253 {
254 return sizeof(WORD);
255 }
256
257 if ((UINT)cbCount < sizeof(WORD)) return 0;
258 *((WORD*)lpBuffer) = (WORD)ppal->NumColors;
259 return sizeof(WORD);
260}
261
262ULONG
263NTAPI
265{
266 ULONG ulDiff, ulColorDiff, ulMinimalDiff = 0xFFFFFF;
267 ULONG i, ulBestIndex = 0;
268 PALETTEENTRY peColor = *(PPALETTEENTRY)&iColor;
269 ASSERT(ppal->flFlags & PAL_INDEXED);
270
271 /* Loop all palette entries */
272 for (i = 0; i < ppal->NumColors; i++)
273 {
274 /* Calculate distance in the color cube */
275 ulDiff = peColor.peRed - ppal->IndexedColors[i].peRed;
276 ulColorDiff = ulDiff * ulDiff;
277 ulDiff = peColor.peGreen - ppal->IndexedColors[i].peGreen;
278 ulColorDiff += ulDiff * ulDiff;
279 ulDiff = peColor.peBlue - ppal->IndexedColors[i].peBlue;
280 ulColorDiff += ulDiff * ulDiff;
281
282 /* Check for a better match */
283 if (ulColorDiff < ulMinimalDiff)
284 {
285 ulBestIndex = i;
286 ulMinimalDiff = ulColorDiff;
287
288 /* Break on exact match */
289 if (ulMinimalDiff == 0) break;
290 }
291 }
292
293 return ulBestIndex;
294}
295
296ULONG
297NTAPI
299{
300 ULONG ulNewColor;
302
303 // FIXME: HACK, should be stored already
304 ppal->ulRedShift = CalculateShift(RGB(0xff,0,0), ppal->RedMask);
305 ppal->ulGreenShift = CalculateShift(RGB(0,0xff,0), ppal->GreenMask);
306 ppal->ulBlueShift = CalculateShift(RGB(0,0,0xff), ppal->BlueMask);
307
308 ulNewColor = _rotl(ulColor, ppal->ulRedShift) & ppal->RedMask;
309 ulNewColor |= _rotl(ulColor, ppal->ulGreenShift) & ppal->GreenMask;
310 ulNewColor |= _rotl(ulColor, ppal->ulBlueShift) & ppal->BlueMask;
311
312 return ulNewColor;
313}
314
315ULONG
316NTAPI
318{
319 if (ppal->flFlags & PAL_RGB)
320 return ulColor;
321 if (ppal->flFlags & PAL_BGR)
322 return RGB(GetBValue(ulColor), GetGValue(ulColor), GetRValue(ulColor));
323 if (ppal->flFlags & PAL_INDEXED) // Use fl & PALINDEXED
324 return PALETTE_ulGetNearestPaletteIndex(ppal, ulColor);
325 else
326 return PALETTE_ulGetNearestBitFieldsIndex(ppal, ulColor);
327}
328
329VOID
330NTAPI
332{
333 ASSERT(pulColors);
334
335 if (ppal->flFlags & PAL_INDEXED || ppal->flFlags & PAL_RGB)
336 {
337 pulColors[0] = RGB(0xFF, 0x00, 0x00);
338 pulColors[1] = RGB(0x00, 0xFF, 0x00);
339 pulColors[2] = RGB(0x00, 0x00, 0xFF);
340 }
341 else if (ppal->flFlags & PAL_BGR)
342 {
343 pulColors[0] = RGB(0x00, 0x00, 0xFF);
344 pulColors[1] = RGB(0x00, 0xFF, 0x00);
345 pulColors[2] = RGB(0xFF, 0x00, 0x00);
346 }
347 else if (ppal->flFlags & PAL_BITFIELDS)
348 {
349 pulColors[0] = ppal->RedMask;
350 pulColors[1] = ppal->GreenMask;
351 pulColors[2] = ppal->BlueMask;
352 }
353}
354
355VOID
358{
359 PPDEVOBJ ppdev = (PPDEVOBJ)PalGDI->hPDev;
360
361 if (!ppdev) return;
362
363 if (ppdev->flFlags & PDEV_GAMMARAMP_TABLE)
364 {
365 ULONG i;
366 PGAMMARAMP GammaRamp = (PGAMMARAMP)ppdev->pvGammaRamp;
367 for ( i = 0; i < Colors; i++)
368 {
369 PaletteEntry[i].peRed += GammaRamp->Red[i];
370 PaletteEntry[i].peGreen += GammaRamp->Green[i];
371 PaletteEntry[i].peBlue += GammaRamp->Blue[i];
372 }
373 }
374 return;
375}
376
379/*
380 * @implemented
381 */
382HPALETTE
385 ULONG iMode,
386 ULONG cColors,
387 ULONG *pulColors,
388 ULONG flRed,
389 ULONG flGreen,
390 ULONG flBlue)
391{
392 PPALETTE ppal;
393 HPALETTE hpal;
394
395 ppal = PALETTE_AllocPalette(iMode, cColors, (PPALETTEENTRY)pulColors, flRed, flGreen, flBlue);
396 if (!ppal) return NULL;
397
399 if (!hpal)
400 {
401 DPRINT1("Could not insert palette into handle table.\n");
403 return NULL;
404 }
405
407 return hpal;
408}
409
410/*
411 * @implemented
412 */
413BOOL
415EngDeletePalette(IN HPALETTE hpal)
416{
417 PPALETTE ppal;
418
419 ppal = PALETTE_ShareLockPalette(hpal);
420 if (!ppal) return FALSE;
421
423
424 return TRUE;
425}
426
427/*
428 * @implemented
429 */
430ULONG
433{
434 PALETTE *PalGDI;
435
436 PalGDI = (PALETTE*)PalObj;
437
438 if (Start >= PalGDI->NumColors)
439 return 0;
440
441 Colors = min(Colors, PalGDI->NumColors - Start);
442
443 /* NOTE: PaletteEntry ULONGs are in the same order as PALETTEENTRY. */
444 RtlCopyMemory(PaletteEntry, PalGDI->IndexedColors + Start, sizeof(ULONG) * Colors);
445
446 if (PalGDI->flFlags & PAL_GAMMACORRECTION)
447 ColorCorrection(PalGDI, (PPALETTEENTRY)PaletteEntry, Colors);
448
449 return Colors;
450}
451
452
455HPALETTE
456NTAPI
458 IN LPLOGPALETTE pLogPal,
460{
461 HPALETTE hpal = NULL;
462 PPALETTE ppal;
463
464 pLogPal->palNumEntries = cEntries;
466 cEntries,
467 pLogPal->palPalEntry,
468 0, 0, 0);
469
470 if (ppal != NULL)
471 {
473
474 hpal = ppal->BaseObject.hHmgr;
476 }
477
478 return hpal;
479}
480
481/*
482 * @implemented
483 */
484HPALETTE
487 IN LPLOGPALETTE plogpalUser,
489{
490 HPALETTE hpal = NULL;
491 PPALETTE ppal;
492 ULONG i, cjSize;
493
495 if (ppal == NULL)
496 {
497 return NULL;
498 }
499
500 cjSize = FIELD_OFFSET(LOGPALETTE, palPalEntry[cEntries]);
501
503 {
504 ProbeForRead(plogpalUser, cjSize, 1);
505
506 for (i = 0; i < cEntries; i++)
507 {
508 ppal->IndexedColors[i] = plogpalUser->palPalEntry[i];
509 }
510 }
512 {
514 _SEH2_YIELD(return NULL);
515 }
516 _SEH2_END;
517
519 hpal = ppal->BaseObject.hHmgr;
521
522 return hpal;
523}
524
525HPALETTE
528{
529 int i, r, g, b;
530 PALETTEENTRY PalEntries[256];
531 PPALETTE ppal;
532 PDC pdc;
533 HPALETTE hpal = NULL;
534 BOOL UseDefaultPalette = TRUE;
535
536 RtlZeroMemory(PalEntries, sizeof(PalEntries));
537
538 /* First and last ten entries are default ones */
539 for (i = 0; i < 10; i++)
540 {
541 PalEntries[i].peRed = g_sysPalTemplate[i].peRed;
542 PalEntries[i].peGreen = g_sysPalTemplate[i].peGreen;
543 PalEntries[i].peBlue = g_sysPalTemplate[i].peBlue;
544
545 PalEntries[246 + i].peRed = g_sysPalTemplate[10 + i].peRed;
546 PalEntries[246 + i].peGreen = g_sysPalTemplate[10 + i].peGreen;
547 PalEntries[246 + i].peBlue = g_sysPalTemplate[10 + i].peBlue;
548 }
549
550 if (hDC)
551 {
552 pdc = DC_LockDc(hDC);
553 if (!pdc)
554 {
556 return NULL;
557 }
558
559 ppal = PALETTE_ShareLockPalette(pdc->dclevel.hpal);
560 if (ppal)
561 {
562 if (ppal->flFlags & PAL_INDEXED)
563 {
564 UseDefaultPalette = FALSE;
565
566 /* FIXME: optimize the palette for the current palette */
568 }
569
571 }
572
573 DC_UnlockDc(pdc);
574 }
575
576 if (UseDefaultPalette)
577 {
578 for (r = 0; r < 6; r++)
579 {
580 for (g = 0; g < 6; g++)
581 {
582 for (b = 0; b < 6; b++)
583 {
584 i = r + g*6 + b*36 + 10;
585 PalEntries[i].peRed = r * 51;
586 PalEntries[i].peGreen = g * 51;
587 PalEntries[i].peBlue = b * 51;
588 }
589 }
590 }
591
592 for (i = 216; i < 246; i++)
593 {
594 int v = (i - 216) << 3;
595 PalEntries[i].peRed = v;
596 PalEntries[i].peGreen = v;
597 PalEntries[i].peBlue = v;
598 }
599 }
600
601 ppal = PALETTE_AllocPalWithHandle(PAL_INDEXED, 256, PalEntries, 0, 0, 0);
602 if (ppal)
603 {
604 hpal = ppal->BaseObject.hHmgr;
606 }
607
608 return hpal;
609}
610
611BOOL
614 HPALETTE hpal,
616{
617/* PALOBJ *palPtr = (PALOBJ*)AccessUserObject(hPal);
618 UINT cPrevEnt, prevVer;
619 INT prevsize, size = sizeof(LOGPALETTE) + (cEntries - 1) * sizeof(PALETTEENTRY);
620 XLATEOBJ *XlateObj = NULL;
621
622 if(!palPtr) return FALSE;
623 cPrevEnt = palPtr->logpalette->palNumEntries;
624 prevVer = palPtr->logpalette->palVersion;
625 prevsize = sizeof(LOGPALETTE) + (cPrevEnt - 1) * sizeof(PALETTEENTRY) + sizeof(int*) + sizeof(GDIOBJHDR);
626 size += sizeof(int*) + sizeof(GDIOBJHDR);
627 XlateObj = palPtr->logicalToSystem;
628
629 if (!(palPtr = GDI_ReallocObject(size, hPal, palPtr))) return FALSE;
630
631 if(XlateObj)
632 {
633 XLATEOBJ *NewXlateObj = (int*) HeapReAlloc(GetProcessHeap(), 0, XlateObj, cEntries * sizeof(int));
634 if(NewXlateObj == NULL)
635 {
636 ERR("Can not resize logicalToSystem -- out of memory!\n");
637 GDI_ReleaseObj( hPal );
638 return FALSE;
639 }
640 palPtr->logicalToSystem = NewXlateObj;
641 }
642
643 if(cEntries > cPrevEnt)
644 {
645 if(XlateObj) memset(palPtr->logicalToSystem + cPrevEnt, 0, (cEntries - cPrevEnt)*sizeof(int));
646 memset( (BYTE*)palPtr + prevsize, 0, size - prevsize );
647 PALETTE_ValidateFlags((PALETTEENTRY*)((BYTE*)palPtr + prevsize), cEntries - cPrevEnt );
648 }
649 palPtr->logpalette->palNumEntries = cEntries;
650 palPtr->logpalette->palVersion = prevVer;
651// GDI_ReleaseObj( hPal );
652 return TRUE; */
653
655 return FALSE;
656}
657
658BOOL
661 HDC hdc,
663{
665 return FALSE;
666}
667
668BOOL
671 HDC hdc,
673{
675 return FALSE;
676}
677
681 _In_ HDC hDC,
683{
684 COLORREF nearest = CLR_INVALID;
685 PDC dc;
686 EXLATEOBJ exlo;
687 PPALETTE ppal;
688
689 dc = DC_LockDc(hDC);
690
691 if(dc == NULL)
692 {
694 return CLR_INVALID;
695 }
696
698 if(dc->dclevel.pSurface == NULL)
699 ppal = gppalMono;
700 else
701 ppal = dc->dclevel.pSurface->ppal;
702
703 /* Translate the color to the DC format */
705
706 /* XLATE it back to RGB color space */
708 ppal,
709 &gpalRGB,
710 0,
711 RGB(0xff, 0xff, 0xff),
712 RGB(0, 0, 0));
713
714 nearest = XLATEOBJ_iXlate(&exlo.xlo, Color);
715
716 EXLATEOBJ_vCleanup(&exlo);
717
718 /* We're done */
720
721 return nearest;
722}
723
724UINT
727 HPALETTE hpal,
728 COLORREF crColor)
729{
731 UINT index = 0;
732
733 if (ppal)
734 {
735 if (ppal->flFlags & PAL_INDEXED)
736 {
737 /* Return closest match for the given RGB color */
739 }
740 // else SetLastError ?
742 }
743
744 return index;
745}
746
747UINT
750{
751 UINT realize = 0;
752 PDC pdc;
753 PALETTE *ppalSurf, *ppalDC;
754
755 pdc = DC_LockDc(hDC);
756 if (!pdc)
757 {
759 return 0;
760 }
761
762 if (!pdc->dclevel.pSurface)
763 {
764 goto cleanup;
765 }
766
767 if (pdc->dctype == DCTYPE_DIRECT)
768 {
769 static BOOL g_WarnedOnce = FALSE;
770 if (!g_WarnedOnce)
771 {
772 g_WarnedOnce = TRUE;
774 }
775 goto cleanup;
776 }
777
779 ppalSurf = pdc->dclevel.pSurface->ppal;
780 ppalDC = pdc->dclevel.ppal;
781
782 if (!(ppalSurf->flFlags & PAL_INDEXED))
783 {
784 // FIXME: Set error?
785 goto cleanup;
786 }
787
788 ASSERT(ppalDC->flFlags & PAL_INDEXED);
789
790 DPRINT1("RealizePalette unimplemented for %s\n",
791 (pdc->dctype == DCTYPE_MEMORY ? "memory managed DCs" : "device DCs"));
792
793cleanup:
794 DC_UnlockDc(pdc);
795 return realize;
796}
797
799IntAnimatePalette(HPALETTE hPal,
800 UINT StartIndex,
801 UINT NumEntries,
802 CONST PPALETTEENTRY PaletteColors)
803{
804 UINT ret = 0;
805
807 {
808 PPALETTE palPtr;
810 const PALETTEENTRY *pptr = PaletteColors;
811
812 palPtr = PALETTE_ShareLockPalette(hPal);
813 if (!palPtr) return FALSE;
814
815 pal_entries = palPtr->NumColors;
816 if (StartIndex >= pal_entries)
817 {
819 return FALSE;
820 }
821 if (StartIndex+NumEntries > pal_entries) NumEntries = pal_entries - StartIndex;
822
823 for (NumEntries += StartIndex; StartIndex < NumEntries; StartIndex++, pptr++)
824 {
825 /* According to MSDN, only animate PC_RESERVED colours */
826 if (palPtr->IndexedColors[StartIndex].peFlags & PC_RESERVED)
827 {
828 memcpy( &palPtr->IndexedColors[StartIndex], pptr,
829 sizeof(PALETTEENTRY) );
830 ret++;
831 PALETTE_ValidateFlags(&palPtr->IndexedColors[StartIndex], 1);
832 }
833 }
834
836
837#if 0
838/* FIXME: This is completely broken! We cannot call UserGetDesktopWindow
839 without first acquiring the USER lock. But the whole process here is
840 screwed anyway. Instead of messing with the desktop DC, we need to
841 check, whether the palette is associated with a PDEV and whether that
842 PDEV supports palette operations. Then we need to call pfnDrvSetPalette.
843 But since IntGdiRealizePalette() is not even implemented for direct DCs,
844 we can as well just do nothing, that will at least not ASSERT!
845 I leave the whole thing here, to scare people away, who want to "fix" it. */
846
847 /* Immediately apply the new palette if current window uses it */
848 Wnd = UserGetDesktopWindow();
849 hDC = UserGetWindowDC(Wnd);
850 dc = DC_LockDc(hDC);
851 if (NULL != dc)
852 {
853 if (dc->dclevel.hpal == hPal)
854 {
857 }
858 else
860 }
861 UserReleaseDC(Wnd,hDC, FALSE);
862#endif // 0
863 }
864 return ret;
865}
866
869 HPALETTE hpal,
870 UINT StartIndex,
873{
874 PPALETTE palGDI;
875 UINT numEntries;
876
877 palGDI = (PPALETTE) PALETTE_ShareLockPalette(hpal);
878 if (NULL == palGDI)
879 {
880 return 0;
881 }
882
883 numEntries = palGDI->NumColors;
884 if (NULL != pe)
885 {
886 if (numEntries < StartIndex + Entries)
887 {
888 Entries = numEntries - StartIndex;
889 }
890 if (numEntries <= StartIndex)
891 {
893 return 0;
894 }
895 memcpy(pe, palGDI->IndexedColors + StartIndex, Entries * sizeof(PALETTEENTRY));
896 }
897 else
898 {
899 Entries = numEntries;
900 }
901
903 return Entries;
904}
905
908 UINT StartIndex,
911{
912 PPALETTE palGDI = NULL;
913 PDC dc = NULL;
914 UINT EntriesSize = 0;
915 UINT Ret = 0;
916
917 if (Entries == 0)
918 {
920 return 0;
921 }
922
923 if (pe != NULL)
924 {
925 EntriesSize = Entries * sizeof(pe[0]);
926 if (Entries != EntriesSize / sizeof(pe[0]))
927 {
928 /* Integer overflow! */
930 return 0;
931 }
932 }
933
934 if (!(dc = DC_LockDc(hDC)))
935 {
937 return 0;
938 }
939
940 palGDI = PALETTE_ShareLockPalette(dc->dclevel.hpal);
941 if (palGDI != NULL)
942 {
943 if (pe != NULL)
944 {
945 if (StartIndex >= palGDI->NumColors)
946 Entries = 0;
947 else if (Entries > palGDI->NumColors - StartIndex)
948 Entries = palGDI->NumColors - StartIndex;
949
950 memcpy(pe,
951 palGDI->IndexedColors + StartIndex,
952 Entries * sizeof(pe[0]));
953
954 Ret = Entries;
955 }
956 else
957 {
958 Ret = dc->ppdev->gdiinfo.ulNumPalReg;
959 }
960 }
961
962 if (palGDI != NULL)
964
965 if (dc != NULL)
967
968 return Ret;
969}
970
971UINT
974 HPALETTE hpal,
975 UINT Start,
978{
979 PPALETTE palGDI;
980 ULONG numEntries;
981
982 if (GDI_HANDLE_IS_STOCKOBJ(hpal))
983 {
984 return 0;
985 }
986
987 palGDI = PALETTE_ShareLockPalette(hpal);
988 if (!palGDI) return 0;
989
990 numEntries = palGDI->NumColors;
991 if (Start >= numEntries)
992 {
994 return 0;
995 }
996 if (numEntries < Start + Entries)
997 {
998 Entries = numEntries - Start;
999 }
1000 memcpy(palGDI->IndexedColors + Start, pe, Entries * sizeof(PALETTEENTRY));
1002
1003 return Entries;
1004}
1005
1006ULONG
1009 HDC hdc,
1010 ULONG iStartIndex,
1012 RGBQUAD *prgbColors,
1013 BOOL bSet)
1014{
1015 PDC pdc;
1016 PSURFACE psurf;
1017 PPALETTE ppal = NULL;
1018 ULONG i, iEndIndex, iResult = 0;
1019
1020 /* Lock the DC */
1021 pdc = DC_LockDc(hdc);
1022 if (!pdc)
1023 {
1024 return 0;
1025 }
1026
1027 /* Get the surface from the DC */
1028 psurf = pdc->dclevel.pSurface;
1029
1030 /* Check if we have the default surface */
1031 if (psurf == NULL)
1032 {
1033 /* Use a mono palette */
1034 if (!bSet)
1035 ppal = gppalMono;
1036 }
1037 else if (psurf->SurfObj.iType == STYPE_BITMAP)
1038 {
1039 /* Get the palette of the surface */
1040 ppal = psurf->ppal;
1041 }
1042
1043 /* Check if this is an indexed palette and the range is ok */
1044 if (ppal && (ppal->flFlags & PAL_INDEXED) &&
1045 (iStartIndex < ppal->NumColors))
1046 {
1047 /* Calculate the end of the operation */
1048 iEndIndex = min(iStartIndex + cEntries, ppal->NumColors);
1049
1050 /* Check what operation to perform */
1051 if (bSet)
1052 {
1053 /* Loop all colors and set the palette entries */
1054 for (i = iStartIndex; i < iEndIndex; i++, prgbColors++)
1055 {
1056 ppal->IndexedColors[i].peRed = prgbColors->rgbRed;
1057 ppal->IndexedColors[i].peGreen = prgbColors->rgbGreen;
1058 ppal->IndexedColors[i].peBlue = prgbColors->rgbBlue;
1059 }
1060
1061 /* Mark the dc brushes invalid */
1062 pdc->pdcattr->ulDirty_ |= DIRTY_FILL|DIRTY_LINE|
1064 }
1065 else
1066 {
1067 /* Loop all colors and get the palette entries */
1068 for (i = iStartIndex; i < iEndIndex; i++, prgbColors++)
1069 {
1070 prgbColors->rgbRed = ppal->IndexedColors[i].peRed;
1071 prgbColors->rgbGreen = ppal->IndexedColors[i].peGreen;
1072 prgbColors->rgbBlue = ppal->IndexedColors[i].peBlue;
1073 prgbColors->rgbReserved = 0;
1074 }
1075 }
1076
1077 /* Calculate how many entries were modified */
1078 iResult = iEndIndex - iStartIndex;
1079 }
1080
1081 /* Unlock the DC */
1082 DC_UnlockDc(pdc);
1083
1084 return iResult;
1085}
1086
1088LONG
1091 _In_ HGDIOBJ hObj,
1094 _When_(bInbound!=0, _In_reads_bytes_(cEntries*sizeof(PALETTEENTRY)))
1095 _When_(bInbound==0, _Out_writes_bytes_(cEntries*sizeof(PALETTEENTRY))) LPVOID pUnsafeEntries,
1096 _In_ DWORD iFunc,
1097 _In_ BOOL bInbound)
1098{
1099 LONG ret;
1100 LPVOID pEntries = NULL;
1101 SIZE_T cjSize;
1102
1103 if (pUnsafeEntries)
1104 {
1105 if (cEntries == 0)
1106 return 0;
1107
1108 cjSize = cEntries * sizeof(PALETTEENTRY);
1110 if (!pEntries)
1111 return 0;
1112
1113 if (bInbound)
1114 {
1115 _SEH2_TRY
1116 {
1117 ProbeForRead(pUnsafeEntries, cjSize, 1);
1118 memcpy(pEntries, pUnsafeEntries, cjSize);
1119 }
1121 {
1122 ExFreePoolWithTag(pEntries, TAG_PALETTE);
1123 _SEH2_YIELD(return 0);
1124 }
1125 _SEH2_END
1126 }
1127 else
1128 {
1129 /* Zero it out, so we don't accidentally leak kernel data */
1130 RtlZeroMemory(pEntries, cjSize);
1131 }
1132 }
1133
1134 ret = 0;
1135 switch(iFunc)
1136 {
1137 case GdiPalAnimate:
1138 if (pEntries)
1139 ret = IntAnimatePalette((HPALETTE)hObj, iStart, cEntries, (CONST PPALETTEENTRY)pEntries);
1140 break;
1141
1142 case GdiPalSetEntries:
1143 if (pEntries)
1144 ret = IntSetPaletteEntries((HPALETTE)hObj, iStart, cEntries, (CONST LPPALETTEENTRY)pEntries);
1145 break;
1146
1147 case GdiPalGetEntries:
1148 ret = IntGetPaletteEntries((HPALETTE)hObj, iStart, cEntries, (LPPALETTEENTRY)pEntries);
1149 break;
1150
1153 break;
1154
1156 if (pEntries)
1157 ret = GreGetSetColorTable((HDC)hObj, iStart, cEntries, (RGBQUAD*)pEntries, TRUE);
1158 break;
1159
1161 if (pEntries)
1162 ret = GreGetSetColorTable((HDC)hObj, iStart, cEntries, (RGBQUAD*)pEntries, FALSE);
1163 break;
1164 }
1165
1166 if (pEntries)
1167 {
1168 if (!bInbound && (ret > 0))
1169 {
1170 cjSize = min(cEntries, ret) * sizeof(PALETTEENTRY);
1171 _SEH2_TRY
1172 {
1173 ProbeForWrite(pUnsafeEntries, cjSize, 1);
1174 memcpy(pUnsafeEntries, pEntries, cjSize);
1175 }
1177 {
1178 ret = 0;
1179 }
1180 _SEH2_END
1181 }
1182 ExFreePoolWithTag(pEntries, TAG_PALETTE);
1183 }
1184
1185 return ret;
1186}
1187
1190{
1191 UINT old = SystemPaletteUse;
1192
1193 /* Device doesn't support colour palettes */
1195 return SYSPAL_ERROR;
1196 }
1197
1198 switch (Usage)
1199 {
1200 case SYSPAL_NOSTATIC:
1201 case SYSPAL_NOSTATIC256:
1202 case SYSPAL_STATIC:
1204 break;
1205
1206 default:
1207 old=SYSPAL_ERROR;
1208 break;
1209 }
1210
1211 return old;
1212}
1213
1214UINT
1217{
1218 return SystemPaletteUse;
1219}
1220
1221BOOL
1224{
1225 PWND Wnd;
1226 BOOL calledFromUser, ret;
1228
1229 calledFromUser = UserIsEntered();
1230
1231 if (!calledFromUser){
1233 }
1234
1236 if (Wnd == NULL)
1237 {
1239
1240 if (!calledFromUser){
1241 UserLeave();
1242 }
1243
1244 return FALSE;
1245 }
1246
1247 UserRefObjectCo(Wnd, &Ref);
1249 UserDerefObjectCo(Wnd);
1250
1251 if (!calledFromUser){
1252 UserLeave();
1253 }
1254
1255 return ret;
1256}
1257
1258BOOL
1261{
1262 BOOL Ret = FALSE;
1263 PPALETTE palGDI;
1264
1265 if ( !hgdiobj ||
1266 GDI_HANDLE_IS_STOCKOBJ(hgdiobj) ||
1268 return Ret;
1269
1270 palGDI = PALETTE_ShareLockPalette(hgdiobj);
1271 if (!palGDI) return FALSE;
1272
1273 // FIXME!!
1274 // Need to do something!!!
1275 // Zero out Current and Old Translated pointers?
1276 //
1277 Ret = TRUE;
1279 return Ret;
1280}
1281
1283HPALETTE
1287 _In_ ULONG cColors,
1288 _In_ ULONG *pulColors,
1289 _In_ FLONG flRed,
1290 _In_ FLONG flGreen,
1291 _In_ FLONG flBlue)
1292{
1293 HPALETTE hPal = NULL;
1294 ULONG *pulcSafe, ulColors[WINDDI_MAXSETPALETTECOLORS];
1295
1296 if ( cColors > MAX_PALCOLORS ) return NULL;
1297
1298 if ( cColors <= WINDDI_MAXSETPALETTECOLORS )
1299 {
1300 pulcSafe = ulColors;
1301 }
1302 else
1303 {
1304 pulcSafe = ExAllocatePoolWithTag(PagedPool, cColors * sizeof(ULONG), GDITAG_UMPD );
1305 }
1306
1307 _SEH2_TRY
1308 {
1309 ProbeForRead( pulColors, cColors * sizeof(ULONG), 1);
1310 RtlCopyMemory( pulcSafe, pulColors, cColors * sizeof(ULONG) );
1311 }
1313 {
1315 if ( cColors > WINDDI_MAXSETPALETTECOLORS ) ExFreePoolWithTag( pulcSafe, GDITAG_UMPD );
1316 _SEH2_YIELD(return hPal);
1317 }
1318 _SEH2_END;
1319
1320 hPal = EngCreatePalette( iMode/*|PAL_SETPOWNER*/, cColors, pulcSafe, flRed, flGreen, flBlue );
1321
1322 if ( cColors > WINDDI_MAXSETPALETTECOLORS ) ExFreePoolWithTag( pulcSafe, GDITAG_UMPD );
1323
1324 return hPal;
1325}
1326
1328BOOL
1331 _In_ HPALETTE hPal)
1332{
1333 return EngDeletePalette(hPal);
1334}
1335
1336/* EOF */
static HDC hDC
Definition: 3dtext.c:33
#define CODE_SEG(...)
Colors
Definition: ansiprsr.h:4
LONG NTSTATUS
Definition: precomp.h:26
#define index(s, c)
Definition: various.h:29
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
#define PC_SYS_USED
Definition: color.h:3
HDC dc
Definition: cylfrac.c:34
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
@ DCTYPE_DIRECT
Definition: dc.h:41
@ DCTYPE_MEMORY
Definition: dc.h:42
ULONG TranslateCOLORREF(PDC pdc, COLORREF crColor)
Definition: dcutil.c:869
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
HWND FASTCALL IntWindowFromDC(HDC hDc)
Definition: windc.c:894
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define APIENTRY
Definition: api.h:79
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
static void cleanup(void)
Definition: main.c:1335
_ACRTIMP unsigned int __cdecl _rotl(unsigned int, int)
Definition: intrin_arm.h:392
#define RGB(r, g, b)
Definition: precomp.h:67
#define GetBValue(quad)
Definition: precomp.h:71
#define GetGValue(quad)
Definition: precomp.h:70
ULONG RGBQUAD
Definition: precomp.h:47
#define GetRValue(quad)
Definition: precomp.h:69
return ret
Definition: mutex.c:146
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
return pTarget Start()
#define GDI_OBJECT_TYPE_PALETTE
Definition: gdi.h:49
#define GDI_HANDLE_IS_TYPE(h, t)
Definition: gdi.h:34
#define GDI_HANDLE_IS_STOCKOBJ(h)
Definition: gdi.h:37
@ BASEFLAG_LOOKASIDE
Definition: gdiobj.h:58
const GLdouble * v
Definition: gl.h:2040
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean g
Definition: glext.h:6204
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: sysinfo.c:13
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:384
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define b
Definition: ke_i.h:79
if(dx< 0)
Definition: linetemp.h:194
struct _PDEVOBJ * PPDEVOBJ
Definition: mdevobj.h:6
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static const ENTRY Entries[]
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static int cbCount
Definition: fiber.c:54
#define min(a, b)
Definition: monoChain.cc:55
_Out_ LPWSTR lpBuffer
Definition: netsh.h:68
#define _In_reads_bytes_(s)
Definition: no_sal2.h:170
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define _Out_writes_bytes_(s)
Definition: no_sal2.h:178
#define _When_(c, a)
Definition: no_sal2.h:38
#define FASTCALL
Definition: nt_native.h:50
unsigned long FLONG
Definition: ntbasedef.h:378
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define DIRTY_FILL
Definition: ntgdihdl.h:123
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
#define DIRTY_TEXT
Definition: ntgdihdl.h:125
#define DIRTY_LINE
Definition: ntgdihdl.h:124
#define DIRTY_BACKGROUND
Definition: ntgdihdl.h:126
@ GdiPalSetColorTable
Definition: ntgdityp.h:32
@ GdiPalGetColorTable
Definition: ntgdityp.h:33
@ GdiPalSetEntries
Definition: ntgdityp.h:29
@ GdiPalAnimate
Definition: ntgdityp.h:28
@ GdiPalGetEntries
Definition: ntgdityp.h:30
@ GdiPalGetSystemEntries
Definition: ntgdityp.h:31
@ GDIObjType_PAL_TYPE
Definition: ntgdityp.h:128
BOOL FASTCALL UserIsEntered(VOID)
Definition: ntuser.c:225
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:43
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
@ PAL_MONOCHROME
Definition: palettemodel.h:17
@ PDEV_GAMMARAMP_TABLE
Definition: pdevobj.h:17
#define CONST
Definition: pedump.c:81
long LONG
Definition: pedump.c:60
__kernel_entry W32KAPI BOOL APIENTRY NtGdiUpdateColors(_In_ HDC hdc)
__kernel_entry W32KAPI INT APIENTRY NtGdiGetDeviceCaps(_In_ HDC hdc, _In_ INT i)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiResizePalette(_In_ HPALETTE hpal, _In_ UINT cEntry)
__kernel_entry W32KAPI HPALETTE APIENTRY NtGdiCreatePaletteInternal(_In_reads_bytes_(cEntries *4+4) LPLOGPALETTE pLogPal, _In_ UINT cEntries)
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiGetStockObject(_In_ INT iObject)
__kernel_entry W32KAPI LONG APIENTRY NtGdiDoPalette(_In_ HGDIOBJ hObj, _In_ WORD iStart, _In_ WORD cEntries, _When_(bInbound!=0, _In_reads_bytes_(cEntries *sizeof(PALETTEENTRY))) _When_(bInbound==0, _Out_writes_bytes_(cEntries *sizeof(PALETTEENTRY))) LPVOID pEntries, _In_ DWORD iFunc, _In_ BOOL bInbound)
Definition: palette.c:1090
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:207
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define __kernel_entry
Definition: specstrings.h:355
Definition: polytest.cpp:41
USHORT BaseFlags
Definition: gdiobj.h:46
ULONG ulShareCount
Definition: gdiobj.h:42
XLATEOBJ xlo
Definition: xlateobj.h:21
WORD Red[256]
Definition: winddi.h:775
WORD Blue[256]
Definition: winddi.h:777
WORD Green[256]
Definition: winddi.h:776
ULONG BlueMask
Definition: palette.h:45
HDEV hPDev
Definition: palette.h:49
ULONG GreenMask
Definition: palette.h:44
BASEOBJECT BaseObject
Definition: palette.h:36
ULONG NumColors
Definition: palette.h:41
ULONG ulGreenShift
Definition: palette.h:47
PALETTEENTRY * IndexedColors
Definition: palette.h:42
PALETTEENTRY apalColors[0]
Definition: palette.h:50
FLONG flFlags
Definition: palette.h:40
ULONG ulBlueShift
Definition: palette.h:48
ULONG ulRedShift
Definition: palette.h:46
ULONG RedMask
Definition: palette.h:43
FLONG flFlags
Definition: pdevobj.h:87
PVOID pvGammaRamp
Definition: pdevobj.h:106
SURFOBJ SurfObj
Definition: surface.h:8
struct _PALETTE *const ppal
Definition: surface.h:11
USHORT iType
Definition: winddi.h:1216
Definition: object.h:4
Definition: ntuser.h:694
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
int pal_entries[256]
Definition: uimain.c:52
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:897
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:123
HDC FASTCALL UserGetWindowDC(PWND Wnd)
Definition: windc.c:947
INT FASTCALL UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
Definition: windc.c:918
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:30
#define NB_RESERVED_COLORS
Definition: palette.c:7
VOID NTAPI GDIOBJ_vFreeObject(POBJ pobj)
Definition: gdiobj.c:603
HGDIOBJ NTAPI GDIOBJ_hInsertObject(POBJ pobj, ULONG ulOwner)
Definition: gdiobj.c:919
POBJ NTAPI GDIOBJ_AllocateObject(UCHAR objt, ULONG cjSize, FLONG fl)
Definition: gdiobj.c:569
VOID NTAPI GDIOBJ_vDeleteObject(POBJ pobj)
Definition: gdiobj.c:1118
VOID NTAPI GDIOBJ_vReferenceObjectByPointer(POBJ pobj)
Definition: gdiobj.c:741
ULONG APIENTRY GreGetSetColorTable(HDC hdc, ULONG iStartIndex, ULONG cEntries, RGBQUAD *prgbColors, BOOL bSet)
Definition: palette.c:1008
COLORREF APIENTRY NtGdiGetNearestColor(_In_ HDC hDC, _In_ COLORREF Color)
Definition: palette.c:680
const PALETTEENTRY g_sysPalTemplate[NB_RESERVED_COLORS]
Definition: palette.c:23
UINT APIENTRY IntGetPaletteEntries(HPALETTE hpal, UINT StartIndex, UINT Entries, LPPALETTEENTRY pe)
Definition: palette.c:868
VOID FASTCALL PALETTE_ValidateFlags(PALETTEENTRY *lpPalE, INT size)
Definition: palette.c:125
unsigned short GetNumberOfBits(unsigned int dwMask)
Definition: palette.c:54
BOOL APIENTRY NtGdiSetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT pca)
Definition: palette.c:670
INT FASTCALL PALETTE_GetObject(PPALETTE ppal, INT cbCount, LPLOGBRUSH lpBuffer)
Definition: palette.c:250
BOOL APIENTRY NtGdiUnrealizeObject(HGDIOBJ hgdiobj)
Definition: palette.c:1260
VOID NTAPI PALETTE_vCleanup(PVOID ObjectBody)
Definition: palette.c:239
PPALETTE appalSurfaceDefault[11]
Definition: palette.c:21
ULONG NTAPI PALETTE_ulGetNearestBitFieldsIndex(PALETTE *ppal, ULONG ulColor)
Definition: palette.c:298
__kernel_entry BOOL APIENTRY NtGdiEngDeletePalette(_In_ HPALETTE hPal)
Definition: palette.c:1330
PALETTE * gppalMono
Definition: palette.c:20
UINT FASTCALL IntGdiRealizePalette(HDC hDC)
Definition: palette.c:749
#define MAX_PALCOLORS
Definition: palette.c:16
PPALETTE NTAPI PALETTE_AllocPalWithHandle(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:212
HPALETTE NTAPI GreCreatePaletteInternal(IN LPLOGPALETTE pLogPal, IN UINT cEntries)
Definition: palette.c:457
VOID FASTCALL ColorCorrection(PPALETTE PalGDI, PPALETTEENTRY PaletteEntry, ULONG Colors)
Definition: palette.c:357
PPALETTE NTAPI PALETTE_AllocPalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:135
NTSTATUS NTAPI InitPaletteImpl(VOID)
Definition: palette.c:66
HPALETTE APIENTRY NtGdiCreateHalftonePalette(HDC hDC)
Definition: palette.c:527
static UINT SystemPaletteUse
Definition: palette.c:18
BOOL APIENTRY NtGdiGetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT pca)
Definition: palette.c:660
UINT APIENTRY NtGdiSetSystemPaletteUse(HDC hDC, UINT Usage)
Definition: palette.c:1189
UINT APIENTRY IntSetPaletteEntries(HPALETTE hpal, UINT Start, UINT Entries, CONST LPPALETTEENTRY pe)
Definition: palette.c:973
PALETTE gpalRGB555
Definition: palette.c:20
UINT APIENTRY IntGetSystemPaletteEntries(HDC hDC, UINT StartIndex, UINT Entries, LPPALETTEENTRY pe)
Definition: palette.c:907
PALETTE gpalRGB
Definition: palette.c:20
ULONG NTAPI PALETTE_ulGetNearestIndex(PALETTE *ppal, ULONG ulColor)
Definition: palette.c:317
UINT APIENTRY IntAnimatePalette(HPALETTE hPal, UINT StartIndex, UINT NumEntries, CONST PPALETTEENTRY PaletteColors)
Definition: palette.c:799
PALETTE * gppalDefault
Definition: palette.c:20
PALETTE gpalBGR
Definition: palette.c:20
UINT APIENTRY NtGdiGetSystemPaletteUse(HDC hDC)
Definition: palette.c:1216
UINT APIENTRY NtGdiGetNearestPaletteIndex(HPALETTE hpal, COLORREF crColor)
Definition: palette.c:726
VOID NTAPI PALETTE_vGetBitMasks(PPALETTE ppal, PULONG pulColors)
Definition: palette.c:331
PALETTE gpalRGB565
Definition: palette.c:20
__kernel_entry HPALETTE APIENTRY NtGdiEngCreatePalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_ ULONG *pulColors, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:1285
ULONG NTAPI PALETTE_ulGetNearestPaletteIndex(PALETTE *ppal, ULONG iColor)
Definition: palette.c:264
struct _PALETTE * PPALETTE
struct _PALETTE PALETTE
#define PALETTE_UnlockPalette(pPalette)
Definition: palette.h:56
FORCEINLINE VOID PALETTE_vSetRGBColorForIndex(PPALETTE ppal, ULONG ulIndex, COLORREF crColor)
Definition: palette.h:152
@ PAL_RGB16_565
Definition: palette.h:28
@ PAL_RGB16_555
Definition: palette.h:27
@ PAL_GAMMACORRECTION
Definition: palette.h:29
FORCEINLINE ULONG CalculateShift(ULONG ulMask1, ULONG ulMask2)
Definition: palette.h:130
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1408
#define TAG_PALETTE
Definition: tags.h:26
#define GDITAG_UMPD
Definition: tags.h:175
#define BMF_16BPP
Definition: winddi.h:358
#define BMF_8BPP
Definition: winddi.h:357
struct _GAMMARAMP * PGAMMARAMP
#define STYPE_BITMAP
Definition: winddi.h:1175
#define PAL_RGB
Definition: winddi.h:1563
_In_ FLONG fl
Definition: winddi.h:1279
#define BMF_1BPP
Definition: winddi.h:355
#define PAL_BITFIELDS
Definition: winddi.h:1562
ENGAPI ULONG APIENTRY XLATEOBJ_iXlate(_In_ XLATEOBJ *pxlo, _In_ ULONG iColor)
Definition: xlateobj.c:909
_Inout_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_opt_ COLORADJUSTMENT * pca
Definition: winddi.h:3779
#define BMF_PNG
Definition: winddi.h:364
_In_ ULONG iMode
Definition: winddi.h:3520
ENGAPI BOOL APIENTRY EngDeletePalette(_In_ _Post_ptr_invalid_ HPALETTE hpal)
#define BMF_24BPP
Definition: winddi.h:359
#define BMF_32BPP
Definition: winddi.h:360
#define PAL_BGR
Definition: winddi.h:1564
ENGAPI ULONG APIENTRY PALOBJ_cGetColors(_In_ PALOBJ *ppalo, _In_ ULONG iStart, _In_ ULONG cColors, _Out_writes_(cColors) ULONG *pulColors)
#define WINDDI_MAXSETPALETTECOLORS
Definition: winddi.h:4006
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:21
#define PAL_INDEXED
Definition: winddi.h:1561
_In_ ULONG cjSize
Definition: winddi.h:3634
#define BMF_8RLE
Definition: winddi.h:362
#define BMF_4RLE
Definition: winddi.h:361
#define BMF_4BPP
Definition: winddi.h:356
_Must_inspect_result_ ENGAPI HPALETTE APIENTRY EngCreatePalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_ ULONG *pulColors, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
#define BMF_JPEG
Definition: winddi.h:363
DWORD COLORREF
Definition: windef.h:100
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:1226
#define PC_RESERVED
Definition: wingdi.h:882
#define RASTERCAPS
Definition: wingdi.h:745
#define SYSPAL_ERROR
Definition: wingdi.h:927
struct tagPALETTEENTRY PALETTEENTRY
#define DEFAULT_PALETTE
Definition: wingdi.h:913
struct tagPALETTEENTRY * PPALETTEENTRY
#define CLR_INVALID
Definition: wingdi.h:883
#define SYSPAL_STATIC
Definition: wingdi.h:926
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:4067
_In_ UINT iStart
Definition: wingdi.h:4066
#define SYSPAL_NOSTATIC
Definition: wingdi.h:925
#define SYSPAL_NOSTATIC256
Definition: wingdi.h:21
#define RC_PALETTE
Definition: wingdi.h:790
#define RDW_INVALIDATE
Definition: winuser.h:1225
VOID NTAPI EXLATEOBJ_vInitialize(_Out_ PEXLATEOBJ pexlo, _In_opt_ PALETTE *ppalSrc, _In_opt_ PALETTE *ppalDst, _In_ COLORREF crSrcBackColor, _In_ COLORREF crDstBackColor, _In_ COLORREF crDstForeColor)
Definition: xlateobj.c:491
VOID NTAPI EXLATEOBJ_vCleanup(_Inout_ PEXLATEOBJ pexlo)
Definition: xlateobj.c:894
_In_ ULONG iColor
Definition: xlateobj.h:17