- Create DIB section palettes with the number of colors mapped from the logical palette
- Validate logical palette access, set to black for invalid indices
- gdi32:palette test now succeeds
svn path=/trunk/; revision=44768
RGBQUAD *lpRGB;
HANDLE hSecure;
DWORD dsBitfields[3] = {0};
RGBQUAD *lpRGB;
HANDLE hSecure;
DWORD dsBitfields[3] = {0};
DPRINT("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
DPRINT("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
hSecure = (HANDLE)0x1; // HACK OF UNIMPLEMENTED KERNEL STUFF !!!!
if (usage == DIB_PAL_COLORS)
hSecure = (HANDLE)0x1; // HACK OF UNIMPLEMENTED KERNEL STUFF !!!!
if (usage == DIB_PAL_COLORS)
lpRGB = DIB_MapPaletteColors(dc, bmi);
lpRGB = DIB_MapPaletteColors(dc, bmi);
+ }
+ ColorCount = bi->biClrUsed;
+ if (ColorCount == 0)
+ {
+ ColorCount = 1 << bi->biBitCount;
+ }
/* Set dsBitfields values */
if (usage == DIB_PAL_COLORS || bi->biBitCount <= 8)
/* Set dsBitfields values */
if (usage == DIB_PAL_COLORS || bi->biBitCount <= 8)
bmp->biClrImportant = bi->biClrImportant;
if (bi->biClrUsed != 0)
bmp->biClrImportant = bi->biClrImportant;
if (bi->biClrUsed != 0)
- bmp->hDIBPalette = PALETTE_AllocPaletteIndexedRGB(bi->biClrUsed, lpRGB);
+ {
+ bmp->hDIBPalette = PALETTE_AllocPaletteIndexedRGB(ColorCount, lpRGB);
+ }
bmp->hDIBPalette = PALETTE_AllocPalette(PAL_BITFIELDS, 0, NULL,
dsBitfields[0],
dsBitfields[1],
dsBitfields[2]);
bmp->hDIBPalette = PALETTE_AllocPalette(PAL_BITFIELDS, 0, NULL,
dsBitfields[0],
dsBitfields[1],
dsBitfields[2]);
// Clean up in case of errors
if (!res || !bmp || !bm.bmBits)
// Clean up in case of errors
if (!res || !bmp || !bm.bmBits)
for (i = 0; i < nNumColors; i++)
{
for (i = 0; i < nNumColors; i++)
{
- lpRGB[i].rgbRed = palGDI->IndexedColors[*lpIndex].peRed;
- lpRGB[i].rgbGreen = palGDI->IndexedColors[*lpIndex].peGreen;
- lpRGB[i].rgbBlue = palGDI->IndexedColors[*lpIndex].peBlue;
+ if (*lpIndex < palGDI->NumColors)
+ {
+ lpRGB[i].rgbRed = palGDI->IndexedColors[*lpIndex].peRed;
+ lpRGB[i].rgbGreen = palGDI->IndexedColors[*lpIndex].peGreen;
+ lpRGB[i].rgbBlue = palGDI->IndexedColors[*lpIndex].peBlue;
+ }
+ else
+ {
+ lpRGB[i].rgbRed = 0;
+ lpRGB[i].rgbGreen = 0;
+ lpRGB[i].rgbBlue = 0;
+ }
lpRGB[i].rgbReserved = 0;
lpIndex++;
}
lpRGB[i].rgbReserved = 0;
lpIndex++;
}