Set the palette for image list DIBs that has 8 or less bits per

pixel.
This commit is contained in:
Filip Navara 2004-06-28 23:52:51 +00:00 committed by Alexandre Julliard
parent 41716ce9c1
commit 2d63dae1d9
1 changed files with 43 additions and 14 deletions

View File

@ -1112,7 +1112,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
/* /*
* Draw the initial image * Draw the initial image
*/ */
if(fStyle & ILD_MASK) { if (fStyle & ILD_MASK) {
if (himl->hbmMask) { if (himl->hbmMask) {
BitBlt(hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCCOPY); BitBlt(hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCCOPY);
} else { } else {
@ -2822,23 +2822,52 @@ static HBITMAP ImageList_CreateImage(HDC hdc, HIMAGELIST himl, UINT width, UINT
if ((ilc >= ILC_COLOR4 && ilc <= ILC_COLOR32) || ilc == ILC_COLOR) if ((ilc >= ILC_COLOR4 && ilc <= ILC_COLOR32) || ilc == ILC_COLOR)
{ {
VOID* bits; VOID* bits;
BITMAPINFO bmi; BITMAPINFO *bmi;
TRACE("Creating DIBSection: %d Bits per Pixel\n", himl->uBitsPixel); TRACE("Creating DIBSection: %d Bits per Pixel\n", himl->uBitsPixel);
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); if (himl->uBitsPixel <= ILC_COLOR8)
bmi.bmiHeader.biWidth = width; {
bmi.bmiHeader.biHeight = height; LPPALETTEENTRY pal;
bmi.bmiHeader.biPlanes = 1; ULONG i, colors;
bmi.bmiHeader.biBitCount = himl->uBitsPixel; BYTE temp;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter = 0;
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
hbmNewBitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &bits, 0, 0); colors = 1 << himl->uBitsPixel;
bmi = HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFOHEADER) +
sizeof(PALETTEENTRY) * colors);
pal = (LPPALETTEENTRY)bmi->bmiColors;
GetPaletteEntries(GetStockObject(DEFAULT_PALETTE), 0, colors, pal);
/* Swap colors returned by GetPaletteEntries so we can use them for
* CreateDIBSection call. */
for (i = 0; i < colors; i++)
{
temp = pal[i].peBlue;
bmi->bmiColors[i].rgbRed = pal[i].peRed;
bmi->bmiColors[i].rgbBlue = temp;
}
}
else
{
bmi = HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFOHEADER));
}
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi->bmiHeader.biWidth = width;
bmi->bmiHeader.biHeight = height;
bmi->bmiHeader.biPlanes = 1;
bmi->bmiHeader.biBitCount = himl->uBitsPixel;
bmi->bmiHeader.biCompression = BI_RGB;
bmi->bmiHeader.biSizeImage = 0;
bmi->bmiHeader.biXPelsPerMeter = 0;
bmi->bmiHeader.biYPelsPerMeter = 0;
bmi->bmiHeader.biClrUsed = 0;
bmi->bmiHeader.biClrImportant = 0;
hbmNewBitmap = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, &bits, 0, 0);
HeapFree(GetProcessHeap(), 0, bmi);
} }
else /*if (ilc == ILC_COLORDDB)*/ else /*if (ilc == ILC_COLORDDB)*/
{ {