[PATCH 9/9] gdiplus: Add pixel format test for transparent non-animated gif (try3)
Piotr Caban
piotr.caban at gmail.com
Thu Mar 12 06:00:03 CDT 2015
On 03/12/15 11:04, Dmitry Timoshkov wrote:
>>> Please add the tests similar to the animated case which checks pixel data,
>>> also add the tests for the palette to see that it actually has a trasparent
>>> color. Otherwise it's hard to see what is going on, and my skills of reading
>>> binary gif data becomes rusty with time.
Here's the test that you were asking about (it's generated on top of the
patches I've sent to wine-patches). The testbot results will be here:
https://newtestbot.winehq.org/JobDetails.pl?Key=12111
I'm going to send it to wine-patches when GIF composition patches are
in. It adds some changes to get_palette function because palette flags
are set incorrectly.
Thanks,
Piotr
-------------- next part --------------
>From baf071b73223b243e6f0312d2bb1abd59cca06ec Mon Sep 17 00:00:00 2001
From: Piotr Caban <piotr at codeweavers.com>
Date: Thu, 12 Mar 2015 11:43:06 +0100
Subject: [PATCH] gdiplus: Fixed palette flags setting
To: wine-patches <wine-patches at winehq.org>
---
dlls/gdiplus/image.c | 34 ++++++++++++++++++++++++----------
dlls/gdiplus/tests/image.c | 24 ++++++++++++++++++++++++
2 files changed, 48 insertions(+), 10 deletions(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 4bce334..8eb1419 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -87,22 +87,36 @@ static ColorPalette *get_palette(IWICBitmapFrameDecode *frame, WICBitmapPaletteT
}
if (hr == S_OK)
{
+ WICBitmapPaletteType type;
+ BOOL alpha;
UINT count;
- BOOL mono, gray;
-
- IWICPalette_IsBlackWhite(wic_palette, &mono);
- IWICPalette_IsGrayscale(wic_palette, &gray);
IWICPalette_GetColorCount(wic_palette, &count);
palette = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(UINT) + count * sizeof(ARGB));
IWICPalette_GetColors(wic_palette, count, palette->Entries, &palette->Count);
- if (mono)
- palette->Flags = 0;
- else if (gray)
- palette->Flags = PaletteFlagsGrayScale;
- else
- palette->Flags = PaletteFlagsHalftone;
+ IWICPalette_GetType(wic_palette, &type);
+ switch(type) {
+ case WICBitmapPaletteTypeFixedGray4:
+ case WICBitmapPaletteTypeFixedGray16:
+ case WICBitmapPaletteTypeFixedGray256:
+ palette->Flags = PaletteFlagsGrayScale;
+ break;
+ case WICBitmapPaletteTypeFixedHalftone8:
+ case WICBitmapPaletteTypeFixedHalftone27:
+ case WICBitmapPaletteTypeFixedHalftone64:
+ case WICBitmapPaletteTypeFixedHalftone125:
+ case WICBitmapPaletteTypeFixedHalftone216:
+ case WICBitmapPaletteTypeFixedHalftone252:
+ case WICBitmapPaletteTypeFixedHalftone256:
+ palette->Flags = PaletteFlagsHalftone;
+ break;
+ default:
+ palette->Flags = 0;
+ }
+ IWICPalette_HasAlpha(wic_palette, &alpha);
+ if(alpha)
+ palette->Flags |= PaletteFlagsHasAlpha;
}
IWICPalette_Release(wic_palette);
}
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 91f70b5..d5ebdd0 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -2487,6 +2487,9 @@ static void test_multiframegif(void)
GUID dimension;
PixelFormat pixel_format;
INT palette_size, i, j;
+ char palette_buf[256];
+ ColorPalette *palette;
+ ARGB *palette_entries;
/* Test frame functions with an animated GIF */
hglob = GlobalAlloc (0, sizeof(gifanimation));
@@ -2644,6 +2647,27 @@ static void test_multiframegif(void)
expect(Ok, stat);
expect(PixelFormat8bppIndexed, pixel_format);
+ stat = GdipBitmapGetPixel(bmp, 0, 0, &color);
+ expect(Ok, stat);
+ expect(0, color);
+
+ stat = GdipGetImagePaletteSize((GpImage*)bmp, &palette_size);
+ expect(Ok, stat);
+ ok(palette_size == sizeof(ColorPalette)+sizeof(ARGB),
+ "palette_size = %d\n", palette_size);
+
+ memset(palette_buf, 0xfe, sizeof(palette_buf));
+ palette = (ColorPalette*)palette_buf;
+ stat = GdipGetImagePalette((GpImage*)bmp, palette,
+ sizeof(ColorPalette)+sizeof(ARGB));
+ palette_entries = palette->Entries;
+ expect(Ok, stat);
+ ok(palette->Flags==PaletteFlagsHasAlpha,
+ "palette->Flags = %x\n", palette->Flags);
+ expect(2, palette->Count);
+ expect(0, palette_entries[0]);
+ expect(0xff000000, palette_entries[1]);
+
count = 12345;
stat = GdipImageGetFrameCount((GpImage*)bmp, &dimension, &count);
expect(Ok, stat);
--
2.0.5
More information about the wine-devel
mailing list