gdiplus: GdipCreateBitmapFromHBITMAP should use palette from the GDI bitmap.
This patch fixes painting bitmaps with bpp <= 8. Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b53e466794
commit
619ef41f33
|
@ -5106,6 +5106,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
|
||||||
GpStatus retval;
|
GpStatus retval;
|
||||||
PixelFormat format;
|
PixelFormat format;
|
||||||
BitmapData lockeddata;
|
BitmapData lockeddata;
|
||||||
|
char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
|
||||||
|
BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
|
||||||
|
|
||||||
TRACE("%p %p %p\n", hbm, hpal, bitmap);
|
TRACE("%p %p %p\n", hbm, hpal, bitmap);
|
||||||
|
|
||||||
|
@ -5155,8 +5157,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
|
||||||
if (retval == Ok)
|
if (retval == Ok)
|
||||||
{
|
{
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
|
|
||||||
BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
|
|
||||||
INT src_height;
|
INT src_height;
|
||||||
|
|
||||||
hdc = CreateCompatibleDC(NULL);
|
hdc = CreateCompatibleDC(NULL);
|
||||||
|
@ -5176,29 +5176,28 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
|
||||||
GdipBitmapUnlockBits(*bitmap, &lockeddata);
|
GdipBitmapUnlockBits(*bitmap, &lockeddata);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retval == Ok && hpal)
|
/* According to the tests hpal is ignored */
|
||||||
|
if (retval == Ok && pbmi->bmiHeader.biBitCount <= 8)
|
||||||
{
|
{
|
||||||
PALETTEENTRY entry[256];
|
ColorPalette *palette;
|
||||||
ColorPalette *palette=NULL;
|
|
||||||
int i, num_palette_entries;
|
int i, num_palette_entries;
|
||||||
|
|
||||||
num_palette_entries = GetPaletteEntries(hpal, 0, 256, entry);
|
num_palette_entries = pbmi->bmiHeader.biClrUsed;
|
||||||
if (!num_palette_entries)
|
if (!num_palette_entries)
|
||||||
retval = GenericError;
|
num_palette_entries = 1 << pbmi->bmiHeader.biBitCount;
|
||||||
|
|
||||||
palette = heap_alloc_zero(sizeof(ColorPalette) + sizeof(ARGB) * (num_palette_entries-1));
|
palette = heap_alloc_zero(sizeof(ColorPalette) + sizeof(ARGB) * (num_palette_entries-1));
|
||||||
if (!palette)
|
if (!palette)
|
||||||
retval = OutOfMemory;
|
retval = OutOfMemory;
|
||||||
|
else
|
||||||
if (retval == Ok)
|
|
||||||
{
|
{
|
||||||
palette->Flags = 0;
|
palette->Flags = 0;
|
||||||
palette->Count = num_palette_entries;
|
palette->Count = num_palette_entries;
|
||||||
|
|
||||||
for (i=0; i<num_palette_entries; i++)
|
for (i=0; i<num_palette_entries; i++)
|
||||||
{
|
{
|
||||||
palette->Entries[i] = 0xff000000 | entry[i].peRed << 16 |
|
palette->Entries[i] = 0xff000000 | pbmi->bmiColors[i].rgbRed << 16 |
|
||||||
entry[i].peGreen << 8 | entry[i].peBlue;
|
pbmi->bmiColors[i].rgbGreen << 8 | pbmi->bmiColors[i].rgbBlue;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = GdipSetImagePalette(&(*bitmap)->image, palette);
|
retval = GdipSetImagePalette(&(*bitmap)->image, palette);
|
||||||
|
|
Loading…
Reference in New Issue