Commit 59eef10f authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

gdiplus: Fixed palette flags setting.

parent d6e2b5b1
...@@ -87,22 +87,36 @@ static ColorPalette *get_palette(IWICBitmapFrameDecode *frame, WICBitmapPaletteT ...@@ -87,22 +87,36 @@ static ColorPalette *get_palette(IWICBitmapFrameDecode *frame, WICBitmapPaletteT
} }
if (hr == S_OK) if (hr == S_OK)
{ {
WICBitmapPaletteType type;
BOOL alpha;
UINT count; UINT count;
BOOL mono, gray;
IWICPalette_IsBlackWhite(wic_palette, &mono);
IWICPalette_IsGrayscale(wic_palette, &gray);
IWICPalette_GetColorCount(wic_palette, &count); IWICPalette_GetColorCount(wic_palette, &count);
palette = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(UINT) + count * sizeof(ARGB)); palette = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(UINT) + count * sizeof(ARGB));
IWICPalette_GetColors(wic_palette, count, palette->Entries, &palette->Count); IWICPalette_GetColors(wic_palette, count, palette->Entries, &palette->Count);
if (mono) IWICPalette_GetType(wic_palette, &type);
palette->Flags = 0; switch(type) {
else if (gray) case WICBitmapPaletteTypeFixedGray4:
palette->Flags = PaletteFlagsGrayScale; case WICBitmapPaletteTypeFixedGray16:
else case WICBitmapPaletteTypeFixedGray256:
palette->Flags = PaletteFlagsHalftone; 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); IWICPalette_Release(wic_palette);
} }
......
...@@ -2487,6 +2487,9 @@ static void test_multiframegif(void) ...@@ -2487,6 +2487,9 @@ static void test_multiframegif(void)
GUID dimension; GUID dimension;
PixelFormat pixel_format; PixelFormat pixel_format;
INT palette_size, i, j; INT palette_size, i, j;
char palette_buf[256];
ColorPalette *palette;
ARGB *palette_entries;
/* Test frame functions with an animated GIF */ /* Test frame functions with an animated GIF */
hglob = GlobalAlloc (0, sizeof(gifanimation)); hglob = GlobalAlloc (0, sizeof(gifanimation));
...@@ -2644,6 +2647,26 @@ static void test_multiframegif(void) ...@@ -2644,6 +2647,26 @@ static void test_multiframegif(void)
expect(Ok, stat); expect(Ok, stat);
expect(PixelFormat8bppIndexed, pixel_format); 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);
expect(PaletteFlagsHasAlpha, palette->Flags);
expect(2, palette->Count);
expect(0, palette_entries[0]);
expect(0xff000000, palette_entries[1]);
count = 12345; count = 12345;
stat = GdipImageGetFrameCount((GpImage*)bmp, &dimension, &count); stat = GdipImageGetFrameCount((GpImage*)bmp, &dimension, &count);
expect(Ok, stat); expect(Ok, stat);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment