2 * Copyright 2012 Dmitry Timoshkov
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define WIN32_NO_STATUS
24 #define COM_NO_WINDOWS_H
32 #include <wine/test.h>
34 HRESULT WINAPI
WICCreateImagingFactory_Proxy(UINT
, IWICImagingFactory
**);
36 static const char gif_global_palette
[] = {
37 /* LSD */'G','I','F','8','7','a',0x01,0x00,0x01,0x00,0xa1,0x02,0x00,
38 /* palette */0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,
39 /* GCE */0x21,0xf9,0x04,0x01,0x05,0x00,0x01,0x00, /* index 1 */
40 /* IMD */0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,
41 0x02,0x02,0x44,0x01,0x00,0x3b
44 /* frame 0, GCE transparent index 1
45 * frame 1, GCE transparent index 2
47 static const char gif_global_palette_2frames
[] = {
48 /* LSD */'G','I','F','8','9','a',0x01,0x00,0x01,0x00,0xa1,0x02,0x00,
49 /* palette */0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,
50 /* GCE */0x21,0xf9,0x04,0x01,0x05,0x00,0x01,0x00, /* index 1 */
51 /* IMD */0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,
52 0x02,0x02,0x44,0x01,0x00,
53 /* GCE */0x21,0xf9,0x04,0x01,0x05,0x00,0x02,0x00, /* index 2 */
54 /* IMD */0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,
55 0x02,0x02,0x44,0x01,0x00,0x3b
58 static const char gif_local_palette
[] = {
59 /* LSD */'G','I','F','8','7','a',0x01,0x00,0x01,0x00,0x27,0x02,0x00,
60 /* GCE */0x21,0xf9,0x04,0x01,0x05,0x00,0x01,0x00, /* index 1 */
61 /* IMD */0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,
62 /* palette */0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,
63 0x02,0x02,0x44,0x01,0x00,0x3b
66 /* Generated with ImageMagick:
67 * convert -delay 100 -size 2x2 xc:red \
68 * -dispose none -page +0+0 -size 2x1 xc:white \
71 static const char gif_frame_sizes
[] = {
72 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x02, 0x00,
73 0x02, 0x00, 0xf1, 0x00, 0x00, 0xff, 0x00, 0x00,
74 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
75 0x00, 0x21, 0xf9, 0x04, 0x00, 0x64, 0x00, 0x00,
76 0x00, 0x21, 0xff, 0x0b, 0x4e, 0x45, 0x54, 0x53,
77 0x43, 0x41, 0x50, 0x45, 0x32, 0x2e, 0x30, 0x03,
78 0x01, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
79 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x03,
80 0x44, 0x34, 0x05, 0x00, 0x21, 0xf9, 0x04, 0x04,
81 0x64, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
82 0x00, 0x02, 0x00, 0x01, 0x00, 0x80, 0xff, 0xff,
83 0xff, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x0a,
87 static IWICImagingFactory
*factory
;
89 static IStream
*create_stream(const void *image_data
, UINT image_size
)
96 hmem
= GlobalAlloc(0, image_size
);
97 data
= GlobalLock(hmem
);
98 memcpy(data
, image_data
, image_size
);
101 hr
= CreateStreamOnHGlobal(hmem
, TRUE
, &stream
);
102 ok(hr
== S_OK
, "CreateStreamOnHGlobal error %#x\n", hr
);
107 static IWICBitmapDecoder
*create_decoder(const void *image_data
, UINT image_size
)
110 IWICBitmapDecoder
*decoder
;
115 stream
= create_stream(image_data
, image_size
);
116 if (!stream
) return NULL
;
118 hr
= IWICImagingFactory_CreateDecoderFromStream(factory
, stream
, NULL
, 0, &decoder
);
119 ok(hr
== S_OK
, "CreateDecoderFromStream error %#x\n", hr
);
121 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &format
);
122 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
123 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
124 "wrong container format %s\n", wine_dbgstr_guid(&format
));
126 refcount
= IStream_Release(stream
);
127 ok(refcount
> 0, "expected stream refcount > 0\n");
132 static void test_global_gif_palette(void)
135 IWICBitmapDecoder
*decoder
;
136 IWICBitmapFrameDecode
*frame
;
137 IWICPalette
*palette
;
142 decoder
= create_decoder(gif_global_palette
, sizeof(gif_global_palette
));
143 ok(decoder
!= 0, "Failed to load GIF image data\n");
145 hr
= IWICImagingFactory_CreatePalette(factory
, &palette
);
146 ok(hr
== S_OK
, "CreatePalette error %#x\n", hr
);
149 hr
= IWICBitmapDecoder_CopyPalette(decoder
, palette
);
150 ok(hr
== S_OK
, "CopyPalette error %#x\n", hr
);
152 hr
= IWICPalette_GetColorCount(palette
, &count
);
153 ok(hr
== S_OK
, "GetColorCount error %#x\n", hr
);
154 ok(count
== 4, "expected 4, got %u\n", count
);
156 hr
= IWICPalette_GetColors(palette
, count
, color
, &ret
);
157 ok(hr
== S_OK
, "GetColors error %#x\n", hr
);
158 ok(ret
== count
, "expected %u, got %u\n", count
, ret
);
159 ok(color
[0] == 0xff010203, "expected 0xff010203, got %#x\n", color
[0]);
160 ok(color
[1] == 0x00040506, "expected 0x00040506, got %#x\n", color
[1]);
161 ok(color
[2] == 0xff070809, "expected 0xff070809, got %#x\n", color
[2]);
162 ok(color
[3] == 0xff0a0b0c, "expected 0xff0a0b0c, got %#x\n", color
[3]);
165 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &frame
);
166 ok(hr
== S_OK
, "GetFrame error %#x\n", hr
);
168 hr
= IWICBitmapFrameDecode_GetPixelFormat(frame
, &format
);
169 ok(hr
== S_OK
, "GetPixelFormat error %#x\n", hr
);
170 ok(IsEqualGUID(&format
, &GUID_WICPixelFormat8bppIndexed
),
171 "wrong pixel format %s\n", wine_dbgstr_guid(&format
));
173 hr
= IWICBitmapFrameDecode_CopyPalette(frame
, palette
);
174 ok(hr
== S_OK
, "CopyPalette error %#x\n", hr
);
176 hr
= IWICPalette_GetColorCount(palette
, &count
);
177 ok(hr
== S_OK
, "GetColorCount error %#x\n", hr
);
178 ok(count
== 4, "expected 4, got %u\n", count
);
180 hr
= IWICPalette_GetColors(palette
, count
, color
, &ret
);
181 ok(hr
== S_OK
, "GetColors error %#x\n", hr
);
182 ok(ret
== count
, "expected %u, got %u\n", count
, ret
);
183 ok(color
[0] == 0xff010203, "expected 0xff010203, got %#x\n", color
[0]);
184 ok(color
[1] == 0x00040506, "expected 0x00040506, got %#x\n", color
[1]);
185 ok(color
[2] == 0xff070809, "expected 0xff070809, got %#x\n", color
[2]);
186 ok(color
[3] == 0xff0a0b0c, "expected 0xff0a0b0c, got %#x\n", color
[3]);
188 IWICPalette_Release(palette
);
189 IWICBitmapFrameDecode_Release(frame
);
190 IWICBitmapDecoder_Release(decoder
);
193 static void test_global_gif_palette_2frames(void)
196 IWICBitmapDecoder
*decoder
;
197 IWICBitmapFrameDecode
*frame
;
198 IWICPalette
*palette
;
203 decoder
= create_decoder(gif_global_palette_2frames
, sizeof(gif_global_palette_2frames
));
204 ok(decoder
!= 0, "Failed to load GIF image data\n");
206 /* active frame 0, GCE transparent index 1 */
207 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &frame
);
208 ok(hr
== S_OK
, "GetFrame error %#x\n", hr
);
210 hr
= IWICImagingFactory_CreatePalette(factory
, &palette
);
211 ok(hr
== S_OK
, "CreatePalette error %#x\n", hr
);
214 hr
= IWICBitmapDecoder_CopyPalette(decoder
, palette
);
215 ok(hr
== S_OK
, "CopyPalette error %#x\n", hr
);
217 hr
= IWICPalette_GetColorCount(palette
, &count
);
218 ok(hr
== S_OK
, "GetColorCount error %#x\n", hr
);
219 ok(count
== 4, "expected 4, got %u\n", count
);
221 hr
= IWICPalette_GetColors(palette
, count
, color
, &ret
);
222 ok(hr
== S_OK
, "GetColors error %#x\n", hr
);
223 ok(ret
== count
, "expected %u, got %u\n", count
, ret
);
224 ok(color
[0] == 0xff010203, "expected 0xff010203, got %#x\n", color
[0]);
225 ok(color
[1] == 0x00040506, "expected 0x00040506, got %#x\n", color
[1]);
226 ok(color
[2] == 0xff070809, "expected 0xff070809, got %#x\n", color
[2]);
227 ok(color
[3] == 0xff0a0b0c, "expected 0xff0a0b0c, got %#x\n", color
[3]);
229 /* frame 0 palette */
230 hr
= IWICBitmapFrameDecode_GetPixelFormat(frame
, &format
);
231 ok(hr
== S_OK
, "GetPixelFormat error %#x\n", hr
);
232 ok(IsEqualGUID(&format
, &GUID_WICPixelFormat8bppIndexed
),
233 "wrong pixel format %s\n", wine_dbgstr_guid(&format
));
235 hr
= IWICBitmapFrameDecode_CopyPalette(frame
, palette
);
236 ok(hr
== S_OK
, "CopyPalette error %#x\n", hr
);
238 hr
= IWICPalette_GetColorCount(palette
, &count
);
239 ok(hr
== S_OK
, "GetColorCount error %#x\n", hr
);
240 ok(count
== 4, "expected 4, got %u\n", count
);
242 hr
= IWICPalette_GetColors(palette
, count
, color
, &ret
);
243 ok(hr
== S_OK
, "GetColors error %#x\n", hr
);
244 ok(ret
== count
, "expected %u, got %u\n", count
, ret
);
245 ok(color
[0] == 0xff010203, "expected 0xff010203, got %#x\n", color
[0]);
246 ok(color
[1] == 0x00040506, "expected 0x00040506, got %#x\n", color
[1]);
247 ok(color
[2] == 0xff070809, "expected 0xff070809, got %#x\n", color
[2]);
248 ok(color
[3] == 0xff0a0b0c, "expected 0xff0a0b0c, got %#x\n", color
[3]);
250 IWICBitmapFrameDecode_Release(frame
);
252 /* active frame 1, GCE transparent index 2 */
253 hr
= IWICBitmapDecoder_GetFrame(decoder
, 1, &frame
);
254 ok(hr
== S_OK
, "GetFrame error %#x\n", hr
);
257 hr
= IWICBitmapDecoder_CopyPalette(decoder
, palette
);
258 ok(hr
== S_OK
, "CopyPalette error %#x\n", hr
);
260 hr
= IWICPalette_GetColorCount(palette
, &count
);
261 ok(hr
== S_OK
, "GetColorCount error %#x\n", hr
);
262 ok(count
== 4, "expected 4, got %u\n", count
);
264 hr
= IWICPalette_GetColors(palette
, count
, color
, &ret
);
265 ok(hr
== S_OK
, "GetColors error %#x\n", hr
);
266 ok(ret
== count
, "expected %u, got %u\n", count
, ret
);
267 ok(color
[0] == 0xff010203, "expected 0xff010203, got %#x\n", color
[0]);
268 ok(color
[1] == 0xff040506 || broken(color
[1] == 0x00040506) /* XP */, "expected 0xff040506, got %#x\n", color
[1]);
269 ok(color
[2] == 0x00070809 || broken(color
[2] == 0xff070809) /* XP */, "expected 0x00070809, got %#x\n", color
[2]);
270 ok(color
[3] == 0xff0a0b0c, "expected 0xff0a0b0c, got %#x\n", color
[3]);
272 /* frame 1 palette */
273 hr
= IWICBitmapFrameDecode_GetPixelFormat(frame
, &format
);
274 ok(hr
== S_OK
, "GetPixelFormat error %#x\n", hr
);
275 ok(IsEqualGUID(&format
, &GUID_WICPixelFormat8bppIndexed
),
276 "wrong pixel format %s\n", wine_dbgstr_guid(&format
));
278 hr
= IWICBitmapFrameDecode_CopyPalette(frame
, palette
);
279 ok(hr
== S_OK
, "CopyPalette error %#x\n", hr
);
281 hr
= IWICPalette_GetColorCount(palette
, &count
);
282 ok(hr
== S_OK
, "GetColorCount error %#x\n", hr
);
283 ok(count
== 4, "expected 4, got %u\n", count
);
285 hr
= IWICPalette_GetColors(palette
, count
, color
, &ret
);
286 ok(hr
== S_OK
, "GetColors error %#x\n", hr
);
287 ok(ret
== count
, "expected %u, got %u\n", count
, ret
);
288 ok(color
[0] == 0xff010203, "expected 0xff010203, got %#x\n", color
[0]);
289 ok(color
[1] == 0xff040506, "expected 0xff040506, got %#x\n", color
[1]);
290 ok(color
[2] == 0x00070809, "expected 0x00070809, got %#x\n", color
[2]);
291 ok(color
[3] == 0xff0a0b0c, "expected 0xff0a0b0c, got %#x\n", color
[3]);
293 IWICPalette_Release(palette
);
294 IWICBitmapFrameDecode_Release(frame
);
295 IWICBitmapDecoder_Release(decoder
);
298 static void test_local_gif_palette(void)
301 IWICBitmapDecoder
*decoder
;
302 IWICBitmapFrameDecode
*frame
;
303 IWICPalette
*palette
;
304 WICBitmapPaletteType type
;
309 decoder
= create_decoder(gif_local_palette
, sizeof(gif_local_palette
));
310 ok(decoder
!= 0, "Failed to load GIF image data\n");
312 hr
= IWICImagingFactory_CreatePalette(factory
, &palette
);
313 ok(hr
== S_OK
, "CreatePalette error %#x\n", hr
);
316 hr
= IWICBitmapDecoder_CopyPalette(decoder
, palette
);
317 ok(hr
== S_OK
|| broken(hr
== WINCODEC_ERR_FRAMEMISSING
), "CopyPalette %#x\n", hr
);
321 hr
= IWICPalette_GetType(palette
, &type
);
322 ok(hr
== S_OK
, "GetType error %#x\n", hr
);
323 ok(type
== WICBitmapPaletteTypeCustom
, "expected WICBitmapPaletteTypeCustom, got %#x\n", type
);
325 hr
= IWICPalette_GetColorCount(palette
, &count
);
326 ok(hr
== S_OK
, "GetColorCount error %#x\n", hr
);
327 ok(count
== 256, "expected 256, got %u\n", count
);
329 hr
= IWICPalette_GetColors(palette
, count
, color
, &ret
);
330 ok(hr
== S_OK
, "GetColors error %#x\n", hr
);
331 ok(ret
== count
, "expected %u, got %u\n", count
, ret
);
332 ok(color
[0] == 0xff000000, "expected 0xff000000, got %#x\n", color
[0]);
333 ok(color
[1] == 0x00ffffff, "expected 0x00ffffff, got %#x\n", color
[1]);
335 for (i
= 2; i
< 256; i
++)
336 ok(color
[i
] == 0xff000000, "expected 0xff000000, got %#x\n", color
[i
]);
340 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &frame
);
341 ok(hr
== S_OK
, "GetFrame error %#x\n", hr
);
343 hr
= IWICBitmapFrameDecode_GetPixelFormat(frame
, &format
);
344 ok(hr
== S_OK
, "GetPixelFormat error %#x\n", hr
);
345 ok(IsEqualGUID(&format
, &GUID_WICPixelFormat8bppIndexed
),
346 "wrong pixel format %s\n", wine_dbgstr_guid(&format
));
348 hr
= IWICBitmapFrameDecode_CopyPalette(frame
, palette
);
349 ok(hr
== S_OK
, "CopyPalette error %#x\n", hr
);
351 hr
= IWICPalette_GetColorCount(palette
, &count
);
352 ok(hr
== S_OK
, "GetColorCount error %#x\n", hr
);
353 ok(count
== 4, "expected 4, got %u\n", count
);
356 hr
= IWICPalette_GetType(palette
, &type
);
357 ok(hr
== S_OK
, "GetType error %#x\n", hr
);
358 ok(type
== WICBitmapPaletteTypeCustom
, "expected WICBitmapPaletteTypeCustom, got %#x\n", type
);
360 hr
= IWICPalette_GetColors(palette
, count
, color
, &ret
);
361 ok(hr
== S_OK
, "GetColors error %#x\n", hr
);
362 ok(ret
== count
, "expected %u, got %u\n", count
, ret
);
363 ok(color
[0] == 0xff010203, "expected 0xff010203, got %#x\n", color
[0]);
364 ok(color
[1] == 0x00040506, "expected 0x00040506, got %#x\n", color
[1]);
365 ok(color
[2] == 0xff070809, "expected 0xff070809, got %#x\n", color
[2]);
366 ok(color
[3] == 0xff0a0b0c, "expected 0xff0a0b0c, got %#x\n", color
[3]);
368 IWICPalette_Release(palette
);
369 IWICBitmapFrameDecode_Release(frame
);
370 IWICBitmapDecoder_Release(decoder
);
373 static void test_gif_frame_sizes(void)
375 static const BYTE frame0
[] = {0, 1, 0xfe, 0xfe, 2, 3, 0xfe, 0xfe};
376 static const BYTE frame1
[] = {0, 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
378 IWICBitmapDecoder
*decoder
;
379 IWICBitmapFrameDecode
*frame
;
384 decoder
= create_decoder(gif_frame_sizes
, sizeof(gif_frame_sizes
));
385 ok(decoder
!= 0, "Failed to load GIF image data\n");
387 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &frame
);
388 ok(hr
== S_OK
, "GetFrame error %#x\n", hr
);
390 hr
= IWICBitmapFrameDecode_GetSize(frame
, &width
, &height
);
391 ok(hr
== S_OK
, "GetSize error %x\n", hr
);
392 ok(width
== 2, "width = %d\n", width
);
393 ok(height
== 2, "height = %d\n", height
);
395 memset(buf
, 0xfe, sizeof(buf
));
396 hr
= IWICBitmapFrameDecode_CopyPixels(frame
, NULL
, 4, sizeof(buf
), buf
);
397 ok(hr
== S_OK
, "CopyPixels error %x\n", hr
);
398 ok(!memcmp(buf
, frame0
, sizeof(buf
)), "buf = %x %x %x %x %x %x %x %x\n",
399 buf
[0], buf
[1], buf
[2], buf
[3], buf
[4], buf
[5], buf
[6], buf
[7]);
401 IWICBitmapFrameDecode_Release(frame
);
403 hr
= IWICBitmapDecoder_GetFrame(decoder
, 1, &frame
);
404 ok(hr
== S_OK
, "GetFrame error %#x\n", hr
);
406 hr
= IWICBitmapFrameDecode_GetSize(frame
, &width
, &height
);
407 ok(hr
== S_OK
, "GetSize error %x\n", hr
);
408 ok(width
== 2, "width = %d\n", width
);
409 ok(height
== 1, "height = %d\n", height
);
411 memset(buf
, 0xfe, sizeof(buf
));
412 hr
= IWICBitmapFrameDecode_CopyPixels(frame
, NULL
, 4, sizeof(buf
), buf
);
413 ok(hr
== S_OK
, "CopyPixels error %x\n", hr
);
414 ok(!memcmp(buf
, frame1
, sizeof(buf
)), "buf = %x %x %x %x %x %x %x %x\n",
415 buf
[0], buf
[1], buf
[2], buf
[3], buf
[4], buf
[5], buf
[6], buf
[7]);
417 IWICBitmapFrameDecode_Release(frame
);
419 IWICBitmapDecoder_Release(decoder
);
422 static const char gif_with_trailer_1
[] = {
423 /* LSD */'G','I','F','8','7','a',0x01,0x00,0x01,0x00,0x80,0x00,0x00,
424 /* palette */0xff,0xff,0xff,0xff,0xff,0xff,
425 /* IMD */0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,
426 /* image data */0x02,0x02,0x44,0x01,0x00,0x3b
428 static const char gif_with_trailer_2
[] = {
429 /* LSD */'G','I','F','8','7','a',0x01,0x00,0x01,0x00,0x00,0x00,0x00,
430 /* IMD */0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,
431 /* image data */0x02,0x02,0x44,0x3b
433 static const char gif_without_trailer_1
[] = {
434 /* LSD */'G','I','F','8','7','a',0x01,0x00,0x01,0x00,0x80,0x00,0x00,
435 /* palette */0xff,0xff,0xff,0xff,0xff,0xff,
436 /* IMD */0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,
437 /* image data */0x02,0x02,0x44,0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef
440 static const char gif_without_trailer_2
[] = {
441 /* LSD */'G','I','F','8','7','a',0x01,0x00,0x01,0x00,0x00,0x00,0x00,
442 /* IMD */0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,
443 /* image data */0x02,0x02,0x44,0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef
446 static void test_truncated_gif(void)
450 IWICBitmapDecoder
*decoder
;
453 stream
= create_stream(gif_with_trailer_1
, sizeof(gif_with_trailer_1
));
456 hr
= IWICImagingFactory_CreateDecoderFromStream(factory
, stream
, NULL
, 0, &decoder
);
457 ok(hr
== S_OK
, "CreateDecoderFromStream error %#x\n", hr
);
458 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &format
);
459 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
460 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
461 "wrong container format %s\n", wine_dbgstr_guid(&format
));
462 IWICBitmapDecoder_Release(decoder
);
463 IStream_Release(stream
);
465 stream
= create_stream(gif_with_trailer_2
, sizeof(gif_with_trailer_2
));
467 hr
= IWICImagingFactory_CreateDecoderFromStream(factory
, stream
, NULL
, 0, &decoder
);
468 ok(hr
== S_OK
, "CreateDecoderFromStream error %#x\n", hr
);
469 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &format
);
470 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
471 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
472 "wrong container format %s\n", wine_dbgstr_guid(&format
));
473 IWICBitmapDecoder_Release(decoder
);
474 IStream_Release(stream
);
476 stream
= create_stream(gif_without_trailer_1
, sizeof(gif_without_trailer_1
));
478 hr
= IWICImagingFactory_CreateDecoderFromStream(factory
, stream
, NULL
, 0, &decoder
);
479 ok(hr
== S_OK
, "CreateDecoderFromStream error %#x\n", hr
);
480 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &format
);
481 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
482 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
483 "wrong container format %s\n", wine_dbgstr_guid(&format
));
484 IWICBitmapDecoder_Release(decoder
);
485 IStream_Release(stream
);
487 stream
= create_stream(gif_without_trailer_2
, sizeof(gif_without_trailer_2
));
489 hr
= IWICImagingFactory_CreateDecoderFromStream(factory
, stream
, NULL
, 0, &decoder
);
490 ok(hr
== S_OK
, "CreateDecoderFromStream error %#x\n", hr
);
491 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &format
);
492 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
493 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
494 "wrong container format %s\n", wine_dbgstr_guid(&format
));
495 IWICBitmapDecoder_Release(decoder
);
496 IStream_Release(stream
);
499 START_TEST(gifformat
)
503 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
504 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
505 &IID_IWICImagingFactory
, (void **)&factory
);
506 ok(hr
== S_OK
, "CoCreateInstance error %#x\n", hr
);
507 if (FAILED(hr
)) return;
509 test_global_gif_palette();
510 test_global_gif_palette_2frames();
511 test_local_gif_palette();
512 test_gif_frame_sizes();
514 IWICImagingFactory_Release(factory
);
517 /* run the same tests with no COM initialization */
518 hr
= WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION
, &factory
);
519 ok(hr
== S_OK
, "WICCreateImagingFactory_Proxy error %#x\n", hr
);
521 test_global_gif_palette();
522 test_global_gif_palette_2frames();
523 test_local_gif_palette();
524 test_gif_frame_sizes();
525 test_truncated_gif();
527 IWICImagingFactory_Release(factory
);