1 #undef WIN32_LEAN_AND_MEAN
4 #include <win32k/bitmaps.h>
5 #include <win32k/debug.h>
6 #include "../eng/handle.h"
7 #include <ntos/minmax.h>
8 #include <include/inteng.h>
11 #include <win32k/debug1.h>
13 UINT STDCALL
W32kSetDIBColorTable(HDC hDC
,
16 CONST RGBQUAD
*Colors
)
19 PALETTEENTRY
* palEntry
;
23 if (!(dc
= (PDC
)AccessUserObject(hDC
))) return 0;
25 if (!(palette
= (PPALOBJ
)AccessUserObject(dc
->DevInfo
->hpalDefault
)))
27 // GDI_ReleaseObj( hdc );
31 // Transfer color info
33 if (dc
->w
.bitsPerPixel
<= 8) {
34 palEntry
= palette
->logpalette
->palPalEntry
+ StartIndex
;
35 if (StartIndex
+ Entries
> (1 << dc
->w
.bitsPerPixel
))
36 Entries
= (1 << dc
->w
.bitsPerPixel
) - StartIndex
;
38 if (StartIndex
+ Entries
> palette
->logpalette
->palNumEntries
)
39 Entries
= palette
->logpalette
->palNumEntries
- StartIndex
;
41 for (end
= Colors
+ Entries
; Colors
< end
; palEntry
++, Colors
++)
43 palEntry
->peRed
= Colors
->rgbRed
;
44 palEntry
->peGreen
= Colors
->rgbGreen
;
45 palEntry
->peBlue
= Colors
->rgbBlue
;
51 // GDI_ReleaseObj(dc->DevInfo->hpalDefault);
52 // GDI_ReleaseObj(hdc);
57 // Converts a DIB to a device-dependent bitmap
58 INT STDCALL
W32kSetDIBits(HDC hDC
,
63 CONST BITMAPINFO
*bmi
,
68 HBITMAP SourceBitmap
, DestBitmap
;
71 PSURFOBJ DestSurf
, SourceSurf
;
79 HPALETTE DDB_Palette
, DIB_Palette
;
80 ULONG DDB_Palette_Type
, DIB_Palette_Type
;
82 INT scanDirection
= 1, DIBWidth
;
85 if (!(dc
= DC_HandleToPtr(hDC
)))
88 if (!(bitmap
= (BITMAPOBJ
*)GDIOBJ_LockObj(hBitmap
, GO_BITMAP_MAGIC
)))
95 if (ColorUse
== DIB_PAL_COLORS
)
96 lpRGB
= DIB_MapPaletteColors(hDC
, bmi
);
98 lpRGB
= &bmi
->bmiColors
[0];
100 // Create a temporary surface for the destination bitmap
101 DestBitmap
= BitmapToSurf(bitmap
);
103 DestSurf
= (PSURFOBJ
) AccessUserObject( DestBitmap
);
104 DestGDI
= (PSURFGDI
) AccessInternalObject( DestBitmap
);
106 // Create source surface
107 SourceSize
.cx
= bmi
->bmiHeader
.biWidth
;
108 SourceSize
.cy
= abs(bmi
->bmiHeader
.biHeight
);
110 // Determine width of DIB
111 DIBWidth
= DIB_GetDIBWidthBytes(SourceSize
.cx
, bmi
->bmiHeader
.biBitCount
);
113 // Determine DIB Vertical Orientation
114 if(bmi
->bmiHeader
.biHeight
> 0)
117 vBits
+= DIBWidth
* bmi
->bmiHeader
.biHeight
- DIBWidth
;
120 SourceBitmap
= EngCreateBitmap(SourceSize
,
121 DIBWidth
* scanDirection
,
122 BitmapFormat(bmi
->bmiHeader
.biBitCount
, bmi
->bmiHeader
.biCompression
),
125 SourceSurf
= (PSURFOBJ
)AccessUserObject(SourceBitmap
);
127 // Destination palette obtained from the hDC
128 hDCPalette
= (PPALGDI
)AccessInternalObject(dc
->DevInfo
->hpalDefault
);
129 DDB_Palette_Type
= hDCPalette
->Mode
;
130 DDB_Palette
= dc
->DevInfo
->hpalDefault
;
132 // Source palette obtained from the BITMAPINFO
133 DIB_Palette
= BuildDIBPalette(bmi
, &DIB_Palette_Type
);
135 // Determine XLATEOBJ for color translation
136 XlateObj
= IntEngCreateXlate(DDB_Palette_Type
, DIB_Palette_Type
, DDB_Palette
, DIB_Palette
);
142 // Determine destination rectangle
145 DestRect
.right
= SourceSize
.cx
;
146 DestRect
.bottom
= SourceSize
.cy
;
148 copyBitsResult
= EngCopyBits(DestSurf
, SourceSurf
, NULL
, XlateObj
, &DestRect
, &ZeroPoint
);
150 // If it succeeded, return number of scanlines copies
151 if(copyBitsResult
== TRUE
)
153 result
= SourceSize
.cy
- 1;
157 EngDeleteXlate(XlateObj
);
158 EngDeletePalette(DIB_Palette
);
159 EngDeleteSurface(SourceBitmap
);
160 EngDeleteSurface(DestBitmap
);
162 // if (ColorUse == DIB_PAL_COLORS)
163 // WinFree((LPSTR)lpRGB);
165 // GDI_ReleaseObj(hBitmap); unlock?
166 GDIOBJ_UnlockObj(hBitmap
, GO_BITMAP_MAGIC
);
172 INT STDCALL
W32kSetDIBitsToDevice(HDC hDC
,
182 CONST BITMAPINFO
*bmi
,
188 UINT STDCALL
W32kGetDIBColorTable(HDC hDC
,
196 // Converts a device-dependent bitmap to a DIB
197 INT STDCALL
W32kGetDIBits(HDC hDC
,
208 INT STDCALL
W32kStretchDIBits(HDC hDC
,
218 CONST BITMAPINFO
*BitsInfo
,
225 LONG STDCALL
W32kGetBitmapBits(HBITMAP hBitmap
,
232 bmp
= BITMAPOBJ_HandleToPtr (hBitmap
);
238 /* If the bits vector is null, the function should return the read size */
241 return bmp
->bitmap
.bmWidthBytes
* bmp
->bitmap
.bmHeight
;
246 DPRINT ("(%ld): Negative number of bytes passed???\n", Count
);
250 /* Only get entire lines */
251 height
= Count
/ bmp
->bitmap
.bmWidthBytes
;
252 if (height
> bmp
->bitmap
.bmHeight
)
254 height
= bmp
->bitmap
.bmHeight
;
256 Count
= height
* bmp
->bitmap
.bmWidthBytes
;
259 DPRINT("Less then one entire line requested\n");
263 DPRINT("(%08x, %ld, %p) %dx%d %d colors fetched height: %ld\n",
264 hBitmap
, Count
, Bits
, bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
265 1 << bmp
->bitmap
.bmBitsPixel
, height
);
267 /* FIXME: Call DDI CopyBits here if available */
270 DPRINT("Calling device specific BitmapBits\n");
271 if(bmp
->DDBitmap
->funcs
->pBitmapBits
)
273 ret
= bmp
->DDBitmap
->funcs
->pBitmapBits(hbitmap
, bits
, count
,
278 ERR_(bitmap
)("BitmapBits == NULL??\n");
285 if(!bmp
->bitmap
.bmBits
)
287 DPRINT ("Bitmap is empty\n");
292 memcpy(Bits
, bmp
->bitmap
.bmBits
, Count
);
300 // The CreateDIBitmap function creates a device-dependent bitmap (DDB) from a DIB and, optionally, sets the bitmap bits
301 // The DDB that is created will be whatever bit depth your reference DC is
302 HBITMAP STDCALL
W32kCreateDIBitmap(HDC hdc
, const BITMAPINFOHEADER
*header
,
303 DWORD init
, LPCVOID bits
, const BITMAPINFO
*data
,
313 if (DIB_GetBitmapInfo( header
, &width
, &height
, &bpp
, &compr
) == -1) return 0;
314 if (height
< 0) height
= -height
;
316 // Check if we should create a monochrome or color bitmap. We create a monochrome bitmap only if it has exactly 2
317 // colors, which are black followed by white, nothing else. In all other cases, we create a color bitmap.
319 if (bpp
!= 1) fColor
= TRUE
;
320 else if ((coloruse
!= DIB_RGB_COLORS
) ||
321 (init
!= CBM_INIT
) || !data
) fColor
= FALSE
;
324 if (data
->bmiHeader
.biSize
== sizeof(BITMAPINFOHEADER
))
326 RGBQUAD
*rgb
= data
->bmiColors
;
327 DWORD col
= RGB( rgb
->rgbRed
, rgb
->rgbGreen
, rgb
->rgbBlue
);
329 // Check if the first color of the colormap is black
330 if ((col
== RGB(0, 0, 0)))
333 col
= RGB( rgb
->rgbRed
, rgb
->rgbGreen
, rgb
->rgbBlue
);
335 // If the second color is white, create a monochrome bitmap
336 fColor
= (col
!= RGB(0xff,0xff,0xff));
340 else if (data
->bmiHeader
.biSize
== sizeof(BITMAPCOREHEADER
))
342 RGBTRIPLE
*rgb
= ((BITMAPCOREINFO
*)data
)->bmciColors
;
343 DWORD col
= RGB( rgb
->rgbtRed
, rgb
->rgbtGreen
, rgb
->rgbtBlue
);
345 if ((col
== RGB(0,0,0)))
348 col
= RGB( rgb
->rgbtRed
, rgb
->rgbtGreen
, rgb
->rgbtBlue
);
349 fColor
= (col
!= RGB(0xff,0xff,0xff));
355 DPRINT("(%ld): wrong size for data\n", data
->bmiHeader
.biSize
);
360 // Now create the bitmap
364 // If we are using indexed colors, then we need to create a bitmap that is compatible with the palette
365 if(coloruse
== DIB_PAL_COLORS
)
367 handle
= W32kCreateCompatibleBitmap(hdc
, width
, height
);
369 else if(coloruse
== DIB_RGB_COLORS
) {
370 handle
= W32kCreateBitmap(width
, height
, 1, 24, NULL
);
373 else handle
= W32kCreateBitmap(width
, height
, 1, 1, NULL
);
375 if (!handle
) return 0;
377 if (init
== CBM_INIT
)
379 W32kSetDIBits(hdc
, handle
, 0, height
, bits
, data
, coloruse
);
385 HBITMAP STDCALL
W32kCreateDIBSection(HDC hDC
,
386 CONST BITMAPINFO
*bmi
,
394 BOOL bDesktopDC
= FALSE
;
396 // If the reference hdc is null, take the desktop dc
399 hDC
= W32kCreateCompatableDC(0);
403 if ((dc
= DC_HandleToPtr(hDC
)))
405 hbitmap
= DIB_CreateDIBSection(dc
, bmi
, Usage
, Bits
, hSection
, dwOffset
, 0);
415 HBITMAP
DIB_CreateDIBSection(
416 PDC dc
, BITMAPINFO
*bmi
, UINT usage
,
417 LPVOID
*bits
, HANDLE section
,
418 DWORD offset
, DWORD ovr_pitch
)
421 BITMAPOBJ
*bmp
= NULL
;
422 DIBSECTION
*dib
= NULL
;
424 // Fill BITMAP32 structure with DIB data
425 BITMAPINFOHEADER
*bi
= &bmi
->bmiHeader
;
426 INT effHeight
, totalSize
;
430 DPRINT("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
431 bi
->biWidth
, bi
->biHeight
, bi
->biPlanes
, bi
->biBitCount
,
432 bi
->biSizeImage
, bi
->biClrUsed
, usage
== DIB_PAL_COLORS
? "PAL" : "RGB");
434 effHeight
= bi
->biHeight
>= 0 ? bi
->biHeight
: -bi
->biHeight
;
436 bm
.bmWidth
= bi
->biWidth
;
437 bm
.bmHeight
= effHeight
;
438 bm
.bmWidthBytes
= ovr_pitch
? ovr_pitch
: DIB_GetDIBWidthBytes(bm
.bmWidth
, bi
->biBitCount
);
440 bm
.bmPlanes
= bi
->biPlanes
;
441 bm
.bmBitsPixel
= bi
->biBitCount
;
444 // Get storage location for DIB bits. Only use biSizeImage if it's valid and
445 // we're dealing with a compressed bitmap. Otherwise, use width * height.
446 totalSize
= bi
->biSizeImage
&& bi
->biCompression
!= BI_RGB
447 ? bi
->biSizeImage
: bm
.bmWidthBytes
* effHeight
;
450 /* bm.bmBits = MapViewOfFile(section, FILE_MAP_ALL_ACCESS,
451 0L, offset, totalSize); */
452 DPRINT("DIB_CreateDIBSection: Cannot yet handle section DIBs\n");
453 else if (ovr_pitch
&& offset
)
454 bm
.bmBits
= (LPVOID
) offset
;
457 bm
.bmBits
= EngAllocUserMem(totalSize
, 0);
460 /* bm.bmBits = ExAllocatePool(NonPagedPool, totalSize); */
462 if(usage
== DIB_PAL_COLORS
) memcpy(bmi
->bmiColors
, (UINT
*)DIB_MapPaletteColors(dc
, bmi
), sizeof(UINT
*));
464 // Allocate Memory for DIB and fill structure
467 dib
= ExAllocatePool(PagedPool
, sizeof(DIBSECTION
));
468 RtlZeroMemory(dib
, sizeof(DIBSECTION
));
475 dib
->dsBmih
.biSizeImage
= totalSize
;
477 /* Set dsBitfields values */
478 if ( usage
== DIB_PAL_COLORS
|| bi
->biBitCount
<= 8)
480 dib
->dsBitfields
[0] = dib
->dsBitfields
[1] = dib
->dsBitfields
[2] = 0;
482 else switch(bi
->biBitCount
)
485 dib
->dsBitfields
[0] = (bi
->biCompression
== BI_BITFIELDS
) ? *(DWORD
*)bmi
->bmiColors
: 0x7c00;
486 dib
->dsBitfields
[1] = (bi
->biCompression
== BI_BITFIELDS
) ? *((DWORD
*)bmi
->bmiColors
+ 1) : 0x03e0;
487 dib
->dsBitfields
[2] = (bi
->biCompression
== BI_BITFIELDS
) ? *((DWORD
*)bmi
->bmiColors
+ 2) : 0x001f;
491 dib
->dsBitfields
[0] = 0xff;
492 dib
->dsBitfields
[1] = 0xff00;
493 dib
->dsBitfields
[2] = 0xff0000;
497 dib
->dsBitfields
[0] = (bi
->biCompression
== BI_BITFIELDS
) ? *(DWORD
*)bmi
->bmiColors
: 0xff;
498 dib
->dsBitfields
[1] = (bi
->biCompression
== BI_BITFIELDS
) ? *((DWORD
*)bmi
->bmiColors
+ 1) : 0xff00;
499 dib
->dsBitfields
[2] = (bi
->biCompression
== BI_BITFIELDS
) ? *((DWORD
*)bmi
->bmiColors
+ 2) : 0xff0000;
502 dib
->dshSection
= section
;
503 dib
->dsOffset
= offset
;
506 // Create Device Dependent Bitmap and add DIB pointer
509 res
= W32kCreateDIBitmap(dc
->hSelf
, bi
, 0, NULL
, bmi
, usage
);
512 bmp
= BITMAPOBJ_HandleToPtr (res
);
515 bmp
->dib
= (DIBSECTION
*) dib
;
519 /* WINE NOTE: WINE makes use of a colormap, which is a color translation table between the DIB and the X physical
520 device. Obviously, this is left out of the ReactOS implementation. Instead, we call
521 W32kSetDIBColorTable. */
522 if(bi
->biBitCount
== 1) { Entries
= 2; } else
523 if(bi
->biBitCount
== 4) { Entries
= 16; } else
524 if(bi
->biBitCount
== 8) { Entries
= 256; }
526 bmp
->ColorMap
= ExAllocatePool(NonPagedPool
, sizeof(RGBQUAD
)*Entries
);
527 RtlCopyMemory(bmp
->ColorMap
, bmi
->bmiColors
, sizeof(RGBQUAD
)*Entries
);
530 // Clean up in case of errors
531 if (!res
|| !bmp
|| !dib
|| !bm
.bmBits
)
533 DPRINT("got an error res=%08x, bmp=%p, dib=%p, bm.bmBits=%p\n", res
, bmp
, dib
, bm
.bmBits
);
537 UnmapViewOfFile(bm.bmBits), bm.bmBits = NULL;
539 VirtualFree(bm.bmBits, 0L, MEM_RELEASE), bm.bmBits = NULL;
542 if (dib
) { ExFreePool(dib
); dib
= NULL
; }
543 if (bmp
) { bmp
= NULL
; }
544 if (res
) { GDIOBJ_FreeObj(res
, GO_BITMAP_MAGIC
, GDIOBJFLAG_DEFAULT
); res
= 0; }
547 // Install fault handler, if possible
550 if (VIRTUAL_SetFaultHandler(bm.bmBits, DIB_FaultHandler, (LPVOID)res))
552 if (section || offset)
554 DIB_DoProtectDIBSection( bmp, PAGE_READWRITE );
555 if (dib) dib->status = DIB_AppMod;
559 DIB_DoProtectDIBSection( bmp, PAGE_READONLY );
560 if (dib) dib->status = DIB_InSync;
566 BITMAPOBJ_ReleasePtr(res
);
568 // Return BITMAP handle and storage location
569 if (bm
.bmBits
&& bits
) *bits
= bm
.bmBits
;
574 /***********************************************************************
575 * DIB_GetDIBWidthBytes
577 * Return the width of a DIB bitmap in bytes. DIB bitmap data is 32-bit aligned.
578 * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/struc/src/str01.htm
579 * 11/16/1999 (RJJ) lifted from wine
581 int DIB_GetDIBWidthBytes(int width
, int depth
)
587 case 1: words
= (width
+ 31) / 32; break;
588 case 4: words
= (width
+ 7) / 8; break;
589 case 8: words
= (width
+ 3) / 4; break;
591 case 16: words
= (width
+ 1) / 2; break;
592 case 24: words
= (width
* 3 + 3)/4; break;
595 DPRINT("(%d): Unsupported depth\n", depth
);
603 /***********************************************************************
604 * DIB_GetDIBImageBytes
606 * Return the number of bytes used to hold the image in a DIB bitmap.
607 * 11/16/1999 (RJJ) lifted from wine
610 int DIB_GetDIBImageBytes (int width
, int height
, int depth
)
612 return DIB_GetDIBWidthBytes( width
, depth
) * (height
< 0 ? -height
: height
);
615 /***********************************************************************
618 * Return the size of the bitmap info structure including color table.
619 * 11/16/1999 (RJJ) lifted from wine
622 int DIB_BitmapInfoSize (const BITMAPINFO
* info
, WORD coloruse
)
626 if (info
->bmiHeader
.biSize
== sizeof(BITMAPCOREHEADER
))
628 BITMAPCOREHEADER
*core
= (BITMAPCOREHEADER
*)info
;
629 colors
= (core
->bcBitCount
<= 8) ? 1 << core
->bcBitCount
: 0;
630 return sizeof(BITMAPCOREHEADER
) + colors
* ((coloruse
== DIB_RGB_COLORS
) ? sizeof(RGBTRIPLE
) : sizeof(WORD
));
632 else /* assume BITMAPINFOHEADER */
634 colors
= info
->bmiHeader
.biClrUsed
;
635 if (!colors
&& (info
->bmiHeader
.biBitCount
<= 8)) colors
= 1 << info
->bmiHeader
.biBitCount
;
636 return sizeof(BITMAPINFOHEADER
) + colors
* ((coloruse
== DIB_RGB_COLORS
) ? sizeof(RGBQUAD
) : sizeof(WORD
));
640 int DIB_GetBitmapInfo( const BITMAPINFOHEADER
*header
, DWORD
*width
,
641 int *height
, WORD
*bpp
, WORD
*compr
)
643 if (header
->biSize
== sizeof(BITMAPINFOHEADER
))
645 *width
= header
->biWidth
;
646 *height
= header
->biHeight
;
647 *bpp
= header
->biBitCount
;
648 *compr
= header
->biCompression
;
651 if (header
->biSize
== sizeof(BITMAPCOREHEADER
))
653 BITMAPCOREHEADER
*core
= (BITMAPCOREHEADER
*)header
;
654 *width
= core
->bcWidth
;
655 *height
= core
->bcHeight
;
656 *bpp
= core
->bcBitCount
;
660 DPRINT("(%ld): wrong size for header\n", header
->biSize
);
664 // Converts a Device Independent Bitmap (DIB) to a Device Dependant Bitmap (DDB)
665 // The specified Device Context (DC) defines what the DIB should be converted to
666 PBITMAPOBJ
DIBtoDDB(HGLOBAL hPackedDIB
, HDC hdc
) // FIXME: This should be removed. All references to this function should
667 // change to W32kSetDIBits
670 PBITMAPOBJ pBmp
= NULL
;
674 // Get a pointer to the packed DIB's data
675 // pPackedDIB = (LPBYTE)GlobalLock(hPackedDIB);
678 pbits
= (dib
+ DIB_BitmapInfoSize(&dib
->dsBmih
, DIB_RGB_COLORS
));
680 // Create a DDB from the DIB
681 hBmp
= W32kCreateDIBitmap(hdc
, &dib
->dsBmih
, CBM_INIT
, (LPVOID
)pbits
, &dib
->dsBmih
, DIB_RGB_COLORS
);
683 // GlobalUnlock(hPackedDIB);
685 // Retrieve the internal Pixmap from the DDB
686 pBmp
= (BITMAPOBJ
*)GDIOBJ_LockObj(hBmp
, GO_BITMAP_MAGIC
);
691 RGBQUAD
*DIB_MapPaletteColors(PDC dc
, LPBITMAPINFO lpbmi
)
698 palObj
= AccessUserObject(dc
->DevInfo
->hpalDefault
);
700 if (palObj
== NULL
) {
701 // RELEASEDCINFO(hDC);
705 nNumColors
= 1 << lpbmi
->bmiHeader
.biBitCount
;
706 if (lpbmi
->bmiHeader
.biClrUsed
)
707 nNumColors
= min(nNumColors
, lpbmi
->bmiHeader
.biClrUsed
);
709 lpRGB
= (RGBQUAD
*)ExAllocatePool(NonPagedPool
, sizeof(RGBQUAD
) * nNumColors
);
710 lpIndex
= (DWORD
*)&lpbmi
->bmiColors
[0];
712 for (i
=0; i
<nNumColors
; i
++) {
713 lpRGB
[i
].rgbRed
= palObj
->logpalette
->palPalEntry
[*lpIndex
].peRed
;
714 lpRGB
[i
].rgbGreen
= palObj
->logpalette
->palPalEntry
[*lpIndex
].peGreen
;
715 lpRGB
[i
].rgbBlue
= palObj
->logpalette
->palPalEntry
[*lpIndex
].peBlue
;
718 // RELEASEDCINFO(hDC);
719 // RELEASEPALETTEINFO(hPalette);
723 PALETTEENTRY
*DIBColorTableToPaletteEntries(PALETTEENTRY
*palEntries
, const RGBQUAD
*DIBColorTable
, ULONG ColorCount
)
727 for(i
=0; i
<ColorCount
; i
++)
729 palEntries
->peRed
= DIBColorTable
->rgbRed
;
730 palEntries
->peGreen
= DIBColorTable
->rgbGreen
;
731 palEntries
->peBlue
= DIBColorTable
->rgbBlue
;
737 HPALETTE
BuildDIBPalette(BITMAPINFO
*bmi
, PINT paletteType
)
741 PALETTEENTRY
*palEntries
;
744 // Determine Bits Per Pixel
745 bits
= bmi
->bmiHeader
.biBitCount
;
747 // Determine paletteType from Bits Per Pixel
750 *paletteType
= PAL_INDEXED
;
754 *paletteType
= PAL_BITFIELDS
;
756 *paletteType
= PAL_RGB
; // Would it be BGR, considering the BGR nature of the DIB color table?
759 if (bmi
->bmiHeader
.biClrUsed
== 0 &&
760 bmi
->bmiHeader
.biBitCount
<= 8)
762 ColorCount
= 1 << bmi
->bmiHeader
.biBitCount
;
766 ColorCount
= bmi
->bmiHeader
.biClrUsed
;
769 palEntries
= ExAllocatePool(NonPagedPool
, sizeof(PALETTEENTRY
)*ColorCount
);
770 DIBColorTableToPaletteEntries(palEntries
, bmi
->bmiColors
, ColorCount
);
771 hPal
= EngCreatePalette(*paletteType
, ColorCount
, palEntries
, 0, 0, 0);
772 ExFreePool(palEntries
);