Commit f6ef0205 authored by Jeff Smith's avatar Jeff Smith Committed by Alexandre Julliard

gdiplus: Set GIF frame delay and loop count properties correctly.

These properties are expected to be present even if frame count is 1.
parent ba564e2a
......@@ -3301,29 +3301,25 @@ static void gif_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UI
PropertyItem *transparent_idx = NULL, *loop = NULL, *palette = NULL;
IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
if (frame_count > 1)
delay = heap_alloc_zero(sizeof(*delay) + frame_count * sizeof(LONG));
if (delay)
{
delay = heap_alloc_zero(sizeof(*delay) + frame_count * sizeof(LONG));
if (delay)
{
LONG *value;
LONG *value;
delay->type = PropertyTagTypeLong;
delay->id = PropertyTagFrameDelay;
delay->length = frame_count * sizeof(LONG);
delay->value = delay + 1;
delay->type = PropertyTagTypeLong;
delay->id = PropertyTagFrameDelay;
delay->length = frame_count * sizeof(LONG);
delay->value = delay + 1;
value = delay->value;
value = delay->value;
for (i = 0; i < frame_count; i++)
for (i = 0; i < frame_count; i++)
{
hr = IWICBitmapDecoder_GetFrame(decoder, i, &frame);
if (hr == S_OK)
{
hr = IWICBitmapDecoder_GetFrame(decoder, i, &frame);
if (hr == S_OK)
{
value[i] = get_gif_frame_property(frame, &GUID_MetadataFormatGCE, L"Delay");
IWICBitmapFrameDecode_Release(frame);
}
else value[i] = 0;
value[i] = get_gif_frame_property(frame, &GUID_MetadataFormatGCE, L"Delay");
IWICBitmapFrameDecode_Release(frame);
}
}
}
......@@ -3342,7 +3338,7 @@ static void gif_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UI
if (!comment)
comment = get_gif_comment(reader);
if (frame_count > 1 && !loop)
if (!loop)
loop = get_gif_loopcount(reader);
if (!background)
......@@ -3358,7 +3354,7 @@ static void gif_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UI
IWICMetadataBlockReader_Release(block_reader);
}
if (frame_count > 1 && !loop)
if (!loop)
{
loop = heap_alloc_zero(sizeof(*loop) + sizeof(SHORT));
if (loop)
......
......@@ -3726,7 +3726,7 @@ static void test_image_properties(void)
status = GdipGetPropertyCount(image, &prop_count);
ok(status == Ok, "GdipGetPropertyCount error %d\n", status);
todo_wine_if(td[i].image_data == pngimage || td[i].image_data == jpgimage || td[i].image_data == gifimage)
todo_wine_if(td[i].image_data == pngimage || td[i].image_data == jpgimage)
ok(td[i].prop_count == prop_count || (td[i].prop_count2 != ~0 && td[i].prop_count2 == prop_count),
"expected property count %u or %u, got %u\n",
td[i].prop_count, td[i].prop_count2, prop_count);
......@@ -4859,6 +4859,12 @@ static const BYTE gif_2frame_no_pal[] = {
0x02,0x02,0x44,0x01,0x00, 0x3b
};
static const BYTE gif_no_pal[] = {
'G','I','F','8','7','a', 0x01,0x00, 0x01,0x00, 0x27, 0x02, 0x00,
0x2c, 0x00,0x00, 0x00,0x00, 0x01,0x00, 0x01,0x00, 0x01,
0x02,0x02,0x44,0x01,0x00, 0x3b
};
static void test_gif_properties(void)
{
static const struct property_test_data animatedgif_props[] =
......@@ -4882,6 +4888,11 @@ static void test_gif_properties(void)
{ PropertyTagTypeLong, PropertyTagFrameDelay, 8, { 10,0,0,0,20,0,0,0 } },
{ PropertyTagTypeShort, PropertyTagLoopCount, 2, { 1,0 } },
};
static const struct property_test_data gif_no_pal_props[] =
{
{ PropertyTagTypeLong, PropertyTagFrameDelay, 4, { 0,0,0,0 } },
{ PropertyTagTypeShort, PropertyTagLoopCount, 2, { 1,0 } },
};
static const struct test_data {
const BYTE *image_data;
......@@ -4895,6 +4906,7 @@ static void test_gif_properties(void)
giftest(animatedgif, animatedgif_props, 2),
giftest(gif_2frame_global_pal, gif_2frame_global_pal_props, 2),
giftest(gif_2frame_no_pal, gif_2frame_no_pal_props, 2),
giftest(gif_no_pal, gif_no_pal_props, 1),
#undef giftest
};
......
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