windowscodecs: Fix handling of a tRNS PNG chunk in the frame CopyPalette method.

This commit is contained in:
Dmitry Timoshkov 2013-03-08 13:18:06 +09:00 committed by Alexandre Julliard
parent 37b33a9de8
commit 18e76792a7
2 changed files with 6 additions and 13 deletions

View file

@ -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);

View file

@ -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);