Module: wine Branch: master Commit: ba564e2abaafcb4bcc3428b67bab5e7f9091cb4d URL: https://gitlab.winehq.org/wine/wine/-/commit/ba564e2abaafcb4bcc3428b67bab5e7...
Author: Jeff Smith whydoubt@gmail.com Date: Sat Jul 15 14:44:24 2023 -0500
gdiplus: Expose GIF background index property only when global color table present.
---
dlls/gdiplus/image.c | 11 +++++++---- dlls/gdiplus/tests/image.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 4ba6b1efd95..a1ad60ecce3 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -3171,11 +3171,14 @@ static PropertyItem *get_gif_loopcount(IWICMetadataReader *reader)
static PropertyItem *get_gif_background(IWICMetadataReader *reader) { - PropertyItem *background; + PropertyItem *background = NULL;
- background = get_property(reader, &GUID_MetadataFormatLSD, L"BackgroundColorIndex"); - if (background) - background->id = PropertyTagIndexBackground; + if (get_bool_property(reader, &GUID_MetadataFormatLSD, L"GlobalColorTableFlag")) + { + background = get_property(reader, &GUID_MetadataFormatLSD, L"BackgroundColorIndex"); + if (background) + background->id = PropertyTagIndexBackground; + }
return background; } diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index 750042bb5c3..4dd39f914b9 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -4838,6 +4838,27 @@ static const BYTE animatedgif[] = { 0x21,0x01,0x0C,'p','l','a','i','n','t','e','x','t',' ','#','2',0x00,0x3B };
+static const BYTE gif_2frame_global_pal[] = { +'G','I','F','8','7','a', 0x01,0x00, 0x01,0x00, 0xa1, 0x02, 0x00, +0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c, +0x21,0xF9,0x04, 0x00,0x0A,0x00,0x08, 0x00, +0x2c, 0x00,0x00, 0x00,0x00, 0x01,0x00, 0x01,0x00, 0x01, +0x02,0x02,0x44,0x01,0x00, +0x21,0xF9,0x04, 0x00,0x14,0x00,0x08, 0x00, +0x2c, 0x00,0x00, 0x00,0x00, 0x01,0x00, 0x01,0x00, 0x01, +0x02,0x02,0x44,0x01,0x00, 0x3b +}; + +static const BYTE gif_2frame_no_pal[] = { +'G','I','F','8','7','a', 0x01,0x00, 0x01,0x00, 0x21, 0x02, 0x00, +0x21,0xF9,0x04, 0x00,0x0A,0x00,0x08, 0x00, +0x2c, 0x00,0x00, 0x00,0x00, 0x01,0x00, 0x01,0x00, 0x01, +0x02,0x02,0x44,0x01,0x00, +0x21,0xF9,0x04, 0x00,0x14,0x00,0x08, 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[] = @@ -4849,6 +4870,18 @@ static void test_gif_properties(void) { PropertyTagTypeByte, PropertyTagIndexBackground, 1, { 2 } }, { PropertyTagTypeByte, PropertyTagIndexTransparent, 1, { 8 } } }; + static const struct property_test_data gif_2frame_global_pal_props[] = + { + { PropertyTagTypeLong, PropertyTagFrameDelay, 8, { 10,0,0,0,20,0,0,0 } }, + { PropertyTagTypeShort, PropertyTagLoopCount, 2, { 1,0 } }, + { PropertyTagTypeByte, PropertyTagGlobalPalette, 12, { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c } }, + { PropertyTagTypeByte, PropertyTagIndexBackground, 1, { 2 } }, + }; + static const struct property_test_data gif_2frame_no_pal_props[] = + { + { PropertyTagTypeLong, PropertyTagFrameDelay, 8, { 10,0,0,0,20,0,0,0 } }, + { PropertyTagTypeShort, PropertyTagLoopCount, 2, { 1,0 } }, + };
static const struct test_data { const BYTE *image_data; @@ -4860,6 +4893,8 @@ static void test_gif_properties(void) { #define giftest(img, prop, frames) { img, sizeof(img), prop, ARRAY_SIZE(prop), frames } 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), #undef giftest };