Module: wine Branch: master Commit: 18e76792a76291c7a8211b6daa433ba6532c840f URL: http://source.winehq.org/git/wine.git/?a=commit;h=18e76792a76291c7a8211b6daa...
Author: Dmitry Timoshkov dmitry@baikal.ru Date: Fri Mar 8 13:18:06 2013 +0900
windowscodecs: Fix handling of a tRNS PNG chunk in the frame CopyPalette method.
---
dlls/windowscodecs/pngformat.c | 17 ++++++----------- dlls/windowscodecs/tests/pngformat.c | 2 -- 2 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c index 2f6a9e3..1708580 100644 --- a/dlls/windowscodecs/pngformat.c +++ b/dlls/windowscodecs/pngformat.c @@ -798,7 +798,7 @@ static HRESULT WINAPI PngDecoder_Frame_CopyPalette(IWICBitmapFrameDecode *iface, png_colorp png_palette; int num_palette; WICColor palette[256]; - png_bytep trans; + png_bytep trans_alpha; int num_trans; png_color_16p trans_values; int i; @@ -822,23 +822,18 @@ static HRESULT WINAPI PngDecoder_Frame_CopyPalette(IWICBitmapFrameDecode *iface, goto end; }
+ ret = ppng_get_tRNS(This->png_ptr, This->info_ptr, &trans_alpha, &num_trans, &trans_values); + if (!ret) num_trans = 0; + for (i=0; i<num_palette; i++) { - palette[i] = (0xff000000| + BYTE alpha = (i < num_trans) ? trans_alpha[i] : 0xff; + palette[i] = (alpha << 24 | png_palette[i].red << 16| png_palette[i].green << 8| png_palette[i].blue); }
- ret = ppng_get_tRNS(This->png_ptr, This->info_ptr, &trans, &num_trans, &trans_values); - if (ret) - { - for (i=0; i<num_trans; i++) - { - palette[trans[i]] = 0x00000000; - } - } - end:
LeaveCriticalSection(&This->lock); diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c index 61c56b3..a222ebc 100644 --- a/dlls/windowscodecs/tests/pngformat.c +++ b/dlls/windowscodecs/tests/pngformat.c @@ -577,9 +577,7 @@ static void test_png_palette(void) hr = IWICPalette_GetColors(palette, 256, color, &ret); ok(hr == S_OK, "GetColors error %#x\n", hr); ok(ret == count, "expected %u, got %u\n", count, ret); -todo_wine ok(color[0] == 0xff010203, "expected 0xff010203, got %#x\n", color[0]); -todo_wine ok(color[1] == 0x00040506, "expected 0x00040506, got %#x\n", color[1]);
IWICPalette_Release(palette);