mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
77 lines
2.9 KiB
Diff
77 lines
2.9 KiB
Diff
From fdde823d2213a71de08a7d96827b6657b7d8bfd8 Mon Sep 17 00:00:00 2001
|
|
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
|
Date: Thu, 19 Dec 2019 12:49:07 +0800
|
|
Subject: [PATCH 1/3] 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>
|
|
---
|
|
dlls/gdiplus/image.c | 21 ++++++++++-----------
|
|
1 file changed, 10 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
|
|
index c3e538d6dba..aed931dd7df 100644
|
|
--- a/dlls/gdiplus/image.c
|
|
+++ b/dlls/gdiplus/image.c
|
|
@@ -5111,6 +5111,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
|
|
GpStatus retval;
|
|
PixelFormat format;
|
|
BitmapData lockeddata;
|
|
+ char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
|
|
+ BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
|
|
|
|
TRACE("%p %p %p\n", hbm, hpal, bitmap);
|
|
|
|
@@ -5160,8 +5162,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
|
|
if (retval == Ok)
|
|
{
|
|
HDC hdc;
|
|
- char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
|
|
- BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
|
|
INT src_height;
|
|
|
|
hdc = CreateCompatibleDC(NULL);
|
|
@@ -5181,29 +5181,28 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
|
|
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=NULL;
|
|
+ ColorPalette *palette;
|
|
int i, num_palette_entries;
|
|
|
|
- num_palette_entries = GetPaletteEntries(hpal, 0, 256, entry);
|
|
+ num_palette_entries = pbmi->bmiHeader.biClrUsed;
|
|
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));
|
|
if (!palette)
|
|
retval = OutOfMemory;
|
|
-
|
|
- if (retval == Ok)
|
|
+ else
|
|
{
|
|
palette->Flags = 0;
|
|
palette->Count = num_palette_entries;
|
|
|
|
for (i=0; i<num_palette_entries; i++)
|
|
{
|
|
- palette->Entries[i] = 0xff000000 | entry[i].peRed << 16 |
|
|
- entry[i].peGreen << 8 | entry[i].peBlue;
|
|
+ palette->Entries[i] = 0xff000000 | pbmi->bmiColors[i].rgbRed << 16 |
|
|
+ pbmi->bmiColors[i].rgbGreen << 8 | pbmi->bmiColors[i].rgbBlue;
|
|
}
|
|
|
|
retval = GdipSetImagePalette(&(*bitmap)->image, palette);
|
|
--
|
|
2.24.0
|
|
|