2 * Copyright 2009 Vincent Povirk for CodeWeavers
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
28 #include "wine/test.h"
30 static const char testbmp_24bpp
[] = {
31 /* BITMAPFILEHEADER */
33 50,0,0,0, /* file size */
34 0,0,0,0, /* reserved */
35 26,0,0,0, /* offset to bits */
36 /* BITMAPCOREHEADER */
37 12,0,0,0, /* header size */
44 255,0,0, 255,255,0, 0,0,
45 255,0,255, 255,255,255, 0,0
48 static void test_decode_24bpp(void)
50 IWICBitmapDecoder
*decoder
, *decoder2
;
51 IWICBitmapFrameDecode
*framedecode
;
52 IWICMetadataQueryReader
*queryreader
;
53 IWICColorContext
*colorcontext
;
54 IWICBitmapSource
*thumbnail
;
61 UINT count
=0, width
=0, height
=0;
63 BYTE imagedata
[36] = {1};
64 const BYTE expected_imagedata
[36] = {
65 255,0,255, 255,255,255,
70 hr
= CoCreateInstance(&CLSID_WICBmpDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
71 &IID_IWICBitmapDecoder
, (void**)&decoder
);
72 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
73 if (FAILED(hr
)) return;
75 hbmpdata
= GlobalAlloc(GMEM_MOVEABLE
, sizeof(testbmp_24bpp
));
76 ok(hbmpdata
!= 0, "GlobalAlloc failed\n");
79 bmpdata
= GlobalLock(hbmpdata
);
80 memcpy(bmpdata
, testbmp_24bpp
, sizeof(testbmp_24bpp
));
81 GlobalUnlock(hbmpdata
);
83 hr
= CreateStreamOnHGlobal(hbmpdata
, FALSE
, &bmpstream
);
84 ok(SUCCEEDED(hr
), "CreateStreamOnHGlobal failed, hr=%x\n", hr
);
87 hr
= IWICBitmapDecoder_Initialize(decoder
, bmpstream
, WICDecodeMetadataCacheOnLoad
);
88 ok(hr
== S_OK
, "Initialize failed, hr=%x\n", hr
);
90 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &guidresult
);
91 ok(SUCCEEDED(hr
), "GetContainerFormat failed, hr=%x\n", hr
);
92 ok(IsEqualGUID(&guidresult
, &GUID_ContainerFormatBmp
), "unexpected container format\n");
94 hr
= IWICBitmapDecoder_GetMetadataQueryReader(decoder
, &queryreader
);
95 ok(hr
== WINCODEC_ERR_UNSUPPORTEDOPERATION
, "expected WINCODEC_ERR_UNSUPPORTEDOPERATION, got %x\n", hr
);
97 hr
= IWICBitmapDecoder_GetColorContexts(decoder
, 1, &colorcontext
, &count
);
98 ok(hr
== WINCODEC_ERR_UNSUPPORTEDOPERATION
, "expected WINCODEC_ERR_UNSUPPORTEDOPERATION, got %x\n", hr
);
100 hr
= IWICBitmapDecoder_GetThumbnail(decoder
, &thumbnail
);
101 ok(hr
== WINCODEC_ERR_CODECNOTHUMBNAIL
, "expected WINCODEC_ERR_CODECNOTHUMBNAIL, got %x\n", hr
);
103 hr
= IWICBitmapDecoder_GetPreview(decoder
, &thumbnail
);
104 ok(hr
== WINCODEC_ERR_UNSUPPORTEDOPERATION
, "expected WINCODEC_ERR_UNSUPPORTEDOPERATION, got %x\n", hr
);
106 hr
= IWICBitmapDecoder_GetFrameCount(decoder
, &count
);
107 ok(SUCCEEDED(hr
), "GetFrameCount failed, hr=%x\n", hr
);
108 ok(count
== 1, "unexpected count %u\n", count
);
110 hr
= IWICBitmapDecoder_GetFrame(decoder
, 1, &framedecode
);
111 ok(hr
== E_INVALIDARG
|| hr
== WINCODEC_ERR_FRAMEMISSING
, "GetFrame returned %x\n", hr
);
113 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &framedecode
);
114 ok(SUCCEEDED(hr
), "GetFrame failed, hr=%x\n", hr
);
117 IWICImagingFactory
*factory
;
118 IWICPalette
*palette
;
120 hr
= IWICBitmapFrameDecode_GetSize(framedecode
, &width
, &height
);
121 ok(SUCCEEDED(hr
), "GetSize failed, hr=%x\n", hr
);
122 ok(width
== 2, "expected width=2, got %u\n", width
);
123 ok(height
== 3, "expected height=2, got %u\n", height
);
125 hr
= IWICBitmapFrameDecode_GetResolution(framedecode
, &dpiX
, &dpiY
);
126 ok(SUCCEEDED(hr
), "GetResolution failed, hr=%x\n", hr
);
127 ok(dpiX
== 96.0, "expected dpiX=96.0, got %f\n", dpiX
);
128 ok(dpiY
== 96.0, "expected dpiY=96.0, got %f\n", dpiY
);
130 hr
= IWICBitmapFrameDecode_GetPixelFormat(framedecode
, &guidresult
);
131 ok(SUCCEEDED(hr
), "GetPixelFormat failed, hr=%x\n", hr
);
132 ok(IsEqualGUID(&guidresult
, &GUID_WICPixelFormat24bppBGR
), "unexpected pixel format\n");
134 hr
= IWICBitmapFrameDecode_GetMetadataQueryReader(framedecode
, &queryreader
);
135 ok(hr
== WINCODEC_ERR_UNSUPPORTEDOPERATION
, "expected WINCODEC_ERR_UNSUPPORTEDOPERATION, got %x\n", hr
);
137 hr
= IWICBitmapFrameDecode_GetColorContexts(framedecode
, 1, &colorcontext
, &count
);
138 ok(hr
== WINCODEC_ERR_UNSUPPORTEDOPERATION
, "expected WINCODEC_ERR_UNSUPPORTEDOPERATION, got %x\n", hr
);
140 hr
= IWICBitmapFrameDecode_GetThumbnail(framedecode
, &thumbnail
);
141 ok(hr
== WINCODEC_ERR_CODECNOTHUMBNAIL
, "expected WINCODEC_ERR_CODECNOTHUMBNAIL, got %x\n", hr
);
143 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
144 &IID_IWICImagingFactory
, (void**)&factory
);
145 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
148 hr
= IWICImagingFactory_CreatePalette(factory
, &palette
);
149 ok(SUCCEEDED(hr
), "CreatePalette failed, hr=%x\n", hr
);
152 hr
= IWICBitmapDecoder_CopyPalette(decoder
, palette
);
153 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x\n", hr
);
155 hr
= IWICBitmapFrameDecode_CopyPalette(framedecode
, palette
);
156 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x\n", hr
);
158 IWICPalette_Release(palette
);
161 IWICImagingFactory_Release(factory
);
168 hr
= IWICBitmapFrameDecode_CopyPixels(framedecode
, &rc
, 6, sizeof(imagedata
), imagedata
);
169 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %x\n", hr
);
175 hr
= IWICBitmapFrameDecode_CopyPixels(framedecode
, &rc
, 6, sizeof(imagedata
), imagedata
);
176 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %x\n", hr
);
182 hr
= IWICBitmapFrameDecode_CopyPixels(framedecode
, &rc
, 4, sizeof(imagedata
), imagedata
);
183 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %x\n", hr
);
189 hr
= IWICBitmapFrameDecode_CopyPixels(framedecode
, &rc
, 4, 5, imagedata
);
190 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %x\n", hr
);
196 hr
= IWICBitmapFrameDecode_CopyPixels(framedecode
, &rc
, 6, sizeof(imagedata
), imagedata
);
197 ok(SUCCEEDED(hr
), "CopyPixels failed, hr=%x\n", hr
);
198 ok(!memcmp(imagedata
, expected_imagedata
, sizeof(imagedata
)), "unexpected image data\n");
200 IWICBitmapFrameDecode_Release(framedecode
);
203 /* cannot initialize twice */
204 hr
= IWICBitmapDecoder_Initialize(decoder
, bmpstream
, WICDecodeMetadataCacheOnLoad
);
205 ok(hr
== WINCODEC_ERR_WRONGSTATE
, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr
);
207 /* cannot querycapability after initialize */
208 hr
= IWICBitmapDecoder_QueryCapability(decoder
, bmpstream
, &capability
);
209 ok(hr
== WINCODEC_ERR_WRONGSTATE
, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr
);
211 hr
= CoCreateInstance(&CLSID_WICBmpDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
212 &IID_IWICBitmapDecoder
, (void**)&decoder2
);
213 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
216 hr
= IWICBitmapDecoder_QueryCapability(decoder2
, bmpstream
, &capability
);
217 ok(hr
== S_OK
, "QueryCapability failed, hr=%x\n", hr
);
218 ok(capability
== (WICBitmapDecoderCapabilityCanDecodeAllImages
),
219 "unexpected capabilities: %x\n", capability
);
221 /* cannot initialize after querycapability */
222 hr
= IWICBitmapDecoder_Initialize(decoder2
, bmpstream
, WICDecodeMetadataCacheOnLoad
);
223 ok(hr
== WINCODEC_ERR_WRONGSTATE
, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr
);
225 /* cannot querycapability twice */
226 hr
= IWICBitmapDecoder_QueryCapability(decoder2
, bmpstream
, &capability
);
227 ok(hr
== WINCODEC_ERR_WRONGSTATE
, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr
);
229 IWICBitmapDecoder_Release(decoder2
);
232 IStream_Release(bmpstream
);
235 GlobalFree(hbmpdata
);
238 IWICBitmapDecoder_Release(decoder
);
241 static const char testbmp_1bpp
[] = {
242 /* BITMAPFILEHEADER */
244 40,0,0,0, /* file size */
245 0,0,0,0, /* reserved */
246 32,0,0,0, /* offset to bits */
247 /* BITMAPCOREHEADER */
248 12,0,0,0, /* header size */
261 static void test_decode_1bpp(void)
263 IWICBitmapDecoder
*decoder
, *decoder2
;
264 IWICBitmapFrameDecode
*framedecode
;
271 UINT count
=0, width
=0, height
=0;
273 BYTE imagedata
[2] = {1};
274 const BYTE expected_imagedata
[2] = {0x80,0xc0};
275 WICColor palettedata
[2] = {1};
276 const WICColor expected_palettedata
[2] = {0xff0000ff,0xff00ff00};
279 hr
= CoCreateInstance(&CLSID_WICBmpDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
280 &IID_IWICBitmapDecoder
, (void**)&decoder
);
281 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
282 if (FAILED(hr
)) return;
284 hbmpdata
= GlobalAlloc(GMEM_MOVEABLE
, sizeof(testbmp_1bpp
));
285 ok(hbmpdata
!= 0, "GlobalAlloc failed\n");
288 bmpdata
= GlobalLock(hbmpdata
);
289 memcpy(bmpdata
, testbmp_1bpp
, sizeof(testbmp_1bpp
));
290 GlobalUnlock(hbmpdata
);
292 hr
= CreateStreamOnHGlobal(hbmpdata
, FALSE
, &bmpstream
);
293 ok(SUCCEEDED(hr
), "CreateStreamOnHGlobal failed, hr=%x\n", hr
);
296 hr
= IWICBitmapDecoder_Initialize(decoder
, bmpstream
, WICDecodeMetadataCacheOnLoad
);
297 ok(hr
== S_OK
, "Initialize failed, hr=%x\n", hr
);
299 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &guidresult
);
300 ok(SUCCEEDED(hr
), "GetContainerFormat failed, hr=%x\n", hr
);
301 ok(IsEqualGUID(&guidresult
, &GUID_ContainerFormatBmp
), "unexpected container format\n");
303 hr
= IWICBitmapDecoder_GetFrameCount(decoder
, &count
);
304 ok(SUCCEEDED(hr
), "GetFrameCount failed, hr=%x\n", hr
);
305 ok(count
== 1, "unexpected count %u\n", count
);
307 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &framedecode
);
308 ok(SUCCEEDED(hr
), "GetFrame failed, hr=%x\n", hr
);
311 IWICImagingFactory
*factory
;
312 IWICPalette
*palette
;
314 hr
= IWICBitmapFrameDecode_GetSize(framedecode
, &width
, &height
);
315 ok(SUCCEEDED(hr
), "GetSize failed, hr=%x\n", hr
);
316 ok(width
== 2, "expected width=2, got %u\n", width
);
317 ok(height
== 2, "expected height=2, got %u\n", height
);
319 hr
= IWICBitmapFrameDecode_GetResolution(framedecode
, &dpiX
, &dpiY
);
320 ok(SUCCEEDED(hr
), "GetResolution failed, hr=%x\n", hr
);
321 ok(dpiX
== 96.0, "expected dpiX=96.0, got %f\n", dpiX
);
322 ok(dpiY
== 96.0, "expected dpiY=96.0, got %f\n", dpiY
);
324 hr
= IWICBitmapFrameDecode_GetPixelFormat(framedecode
, &guidresult
);
325 ok(SUCCEEDED(hr
), "GetPixelFormat failed, hr=%x\n", hr
);
326 ok(IsEqualGUID(&guidresult
, &GUID_WICPixelFormat1bppIndexed
), "unexpected pixel format\n");
328 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
329 &IID_IWICImagingFactory
, (void**)&factory
);
330 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
333 hr
= IWICImagingFactory_CreatePalette(factory
, &palette
);
334 ok(SUCCEEDED(hr
), "CreatePalette failed, hr=%x\n", hr
);
337 hr
= IWICBitmapDecoder_CopyPalette(decoder
, palette
);
338 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x\n", hr
);
340 hr
= IWICBitmapFrameDecode_CopyPalette(framedecode
, palette
);
341 ok(SUCCEEDED(hr
), "CopyPalette failed, hr=%x\n", hr
);
343 hr
= IWICPalette_GetColorCount(palette
, &count
);
344 ok(SUCCEEDED(hr
), "GetColorCount failed, hr=%x\n", hr
);
345 ok(count
== 2, "expected count=2, got %u\n", count
);
347 hr
= IWICPalette_GetColors(palette
, 2, palettedata
, &count
);
348 ok(SUCCEEDED(hr
), "GetColorCount failed, hr=%x\n", hr
);
349 ok(count
== 2, "expected count=2, got %u\n", count
);
350 ok(!memcmp(palettedata
, expected_palettedata
, sizeof(palettedata
)), "unexpected palette data\n");
352 IWICPalette_Release(palette
);
355 IWICImagingFactory_Release(factory
);
362 hr
= IWICBitmapFrameDecode_CopyPixels(framedecode
, &rc
, 1, sizeof(imagedata
), imagedata
);
363 ok(SUCCEEDED(hr
), "CopyPixels failed, hr=%x\n", hr
);
364 ok(!memcmp(imagedata
, expected_imagedata
, sizeof(imagedata
)), "unexpected image data\n");
366 IWICBitmapFrameDecode_Release(framedecode
);
369 hr
= CoCreateInstance(&CLSID_WICBmpDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
370 &IID_IWICBitmapDecoder
, (void**)&decoder2
);
371 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
374 hr
= IWICBitmapDecoder_QueryCapability(decoder2
, bmpstream
, &capability
);
375 ok(hr
== S_OK
, "QueryCapability failed, hr=%x\n", hr
);
376 ok(capability
== (WICBitmapDecoderCapabilityCanDecodeAllImages
),
377 "unexpected capabilities: %x\n", capability
);
378 IWICBitmapDecoder_Release(decoder2
);
381 IStream_Release(bmpstream
);
384 GlobalFree(hbmpdata
);
387 IWICBitmapDecoder_Release(decoder
);
390 static const char testbmp_4bpp
[] = {
391 /* BITMAPFILEHEADER */
393 82,0,0,0, /* file size */
394 0,0,0,0, /* reserved */
395 74,0,0,0, /* offset to bits */
396 /* BITMAPINFOHEADER */
397 40,0,0,0, /* header size */
399 254,255,255,255, /* height = -2 */
402 0,0,0,0, /* compression = BI_RGB */
403 0,0,0,0, /* image size = 0 */
404 16,39,0,0, /* X pixels per meter = 10000 */
405 32,78,0,0, /* Y pixels per meter = 20000 */
406 5,0,0,0, /* colors used */
407 5,0,0,0, /* colors important */
419 static void test_decode_4bpp(void)
421 IWICBitmapDecoder
*decoder
, *decoder2
;
422 IWICBitmapFrameDecode
*framedecode
;
429 UINT count
=0, width
=0, height
=0;
431 BYTE imagedata
[2] = {1};
432 const BYTE expected_imagedata
[2] = {0x01,0x23};
433 WICColor palettedata
[5] = {1};
434 const WICColor expected_palettedata
[5] =
435 {0xff0000ff,0xff00ff00,0xffff0000,0xff800080,0xffffffff};
438 hr
= CoCreateInstance(&CLSID_WICBmpDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
439 &IID_IWICBitmapDecoder
, (void**)&decoder
);
440 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
441 if (FAILED(hr
)) return;
443 hbmpdata
= GlobalAlloc(GMEM_MOVEABLE
, sizeof(testbmp_4bpp
));
444 ok(hbmpdata
!= 0, "GlobalAlloc failed\n");
447 bmpdata
= GlobalLock(hbmpdata
);
448 memcpy(bmpdata
, testbmp_4bpp
, sizeof(testbmp_4bpp
));
449 GlobalUnlock(hbmpdata
);
451 hr
= CreateStreamOnHGlobal(hbmpdata
, FALSE
, &bmpstream
);
452 ok(SUCCEEDED(hr
), "CreateStreamOnHGlobal failed, hr=%x\n", hr
);
455 hr
= IWICBitmapDecoder_Initialize(decoder
, bmpstream
, WICDecodeMetadataCacheOnLoad
);
456 ok(hr
== S_OK
, "Initialize failed, hr=%x\n", hr
);
458 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &guidresult
);
459 ok(SUCCEEDED(hr
), "GetContainerFormat failed, hr=%x\n", hr
);
460 ok(IsEqualGUID(&guidresult
, &GUID_ContainerFormatBmp
), "unexpected container format\n");
462 hr
= IWICBitmapDecoder_GetFrameCount(decoder
, &count
);
463 ok(SUCCEEDED(hr
), "GetFrameCount failed, hr=%x\n", hr
);
464 ok(count
== 1, "unexpected count %u\n", count
);
466 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &framedecode
);
467 ok(SUCCEEDED(hr
), "GetFrame failed, hr=%x\n", hr
);
470 IWICImagingFactory
*factory
;
471 IWICPalette
*palette
;
473 hr
= IWICBitmapFrameDecode_GetSize(framedecode
, &width
, &height
);
474 ok(SUCCEEDED(hr
), "GetSize failed, hr=%x\n", hr
);
475 ok(width
== 2, "expected width=2, got %u\n", width
);
476 ok(height
== 2, "expected height=2, got %u\n", height
);
478 hr
= IWICBitmapFrameDecode_GetResolution(framedecode
, &dpiX
, &dpiY
);
479 ok(SUCCEEDED(hr
), "GetResolution failed, hr=%x\n", hr
);
480 ok(fabs(dpiX
- 254.0) < 0.01, "expected dpiX=96.0, got %f\n", dpiX
);
481 ok(fabs(dpiY
- 508.0) < 0.01, "expected dpiY=96.0, got %f\n", dpiY
);
483 hr
= IWICBitmapFrameDecode_GetPixelFormat(framedecode
, &guidresult
);
484 ok(SUCCEEDED(hr
), "GetPixelFormat failed, hr=%x\n", hr
);
485 ok(IsEqualGUID(&guidresult
, &GUID_WICPixelFormat4bppIndexed
), "unexpected pixel format\n");
487 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
488 &IID_IWICImagingFactory
, (void**)&factory
);
489 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
492 hr
= IWICImagingFactory_CreatePalette(factory
, &palette
);
493 ok(SUCCEEDED(hr
), "CreatePalette failed, hr=%x\n", hr
);
496 hr
= IWICBitmapDecoder_CopyPalette(decoder
, palette
);
497 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x\n", hr
);
499 hr
= IWICBitmapFrameDecode_CopyPalette(framedecode
, palette
);
500 ok(SUCCEEDED(hr
), "CopyPalette failed, hr=%x\n", hr
);
502 hr
= IWICPalette_GetColorCount(palette
, &count
);
503 ok(SUCCEEDED(hr
), "GetColorCount failed, hr=%x\n", hr
);
504 ok(count
== 5, "expected count=5, got %u\n", count
);
506 hr
= IWICPalette_GetColors(palette
, 5, palettedata
, &count
);
507 ok(SUCCEEDED(hr
), "GetColorCount failed, hr=%x\n", hr
);
508 ok(count
== 5, "expected count=5, got %u\n", count
);
509 ok(!memcmp(palettedata
, expected_palettedata
, sizeof(palettedata
)), "unexpected palette data\n");
511 IWICPalette_Release(palette
);
514 IWICImagingFactory_Release(factory
);
521 hr
= IWICBitmapFrameDecode_CopyPixels(framedecode
, &rc
, 1, sizeof(imagedata
), imagedata
);
522 ok(SUCCEEDED(hr
), "CopyPixels failed, hr=%x\n", hr
);
523 ok(!memcmp(imagedata
, expected_imagedata
, sizeof(imagedata
)), "unexpected image data\n");
525 IWICBitmapFrameDecode_Release(framedecode
);
528 hr
= CoCreateInstance(&CLSID_WICBmpDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
529 &IID_IWICBitmapDecoder
, (void**)&decoder2
);
530 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
533 hr
= IWICBitmapDecoder_QueryCapability(decoder2
, bmpstream
, &capability
);
534 ok(hr
== S_OK
, "QueryCapability failed, hr=%x\n", hr
);
535 ok(capability
== (WICBitmapDecoderCapabilityCanDecodeAllImages
),
536 "unexpected capabilities: %x\n", capability
);
537 IWICBitmapDecoder_Release(decoder2
);
540 IStream_Release(bmpstream
);
543 GlobalFree(hbmpdata
);
546 IWICBitmapDecoder_Release(decoder
);
549 static const char testbmp_rle8
[] = {
550 /* BITMAPFILEHEADER */
552 202,0,0,0, /* file size */
553 0,0,0,0, /* reserved */
554 122,0,0,0, /* offset to bits */
555 /* BITMAPINFOHEADER */
556 40,0,0,0, /* header size */
558 8,0,0,0, /* height */
561 1,0,0,0, /* compression = BI_RLE8 */
562 80,0,0,0, /* image size */
563 19,11,0,0, /* X pixels per meter */
564 19,11,0,0, /* Y pixels per meter */
565 17,0,0,0, /* colors used */
566 17,0,0,0, /* colors important */
586 4,15,0,4,11,9,9,0,0,0,4,14,0,4,3,10,10,7,0,0,4,13,0,4,3,10,10,7,0,0,4,12,0,4,0,1,1,11,0,0,0,4,16,2,16,2,4,4,0,0,0,4,2,16,2,16,4,5,0,0,0,4,16,2,16,2,4,6,0,0,0,4,2,16,2,16,4,8,0,1
589 static void test_decode_rle8(void)
591 IWICBitmapDecoder
*decoder
, *decoder2
;
592 IWICBitmapFrameDecode
*framedecode
;
599 UINT count
=0, width
=0, height
=0;
601 DWORD imagedata
[64] = {1};
602 const DWORD expected_imagedata
[64] = {
603 0x0000ff,0xffffff,0x0000ff,0xffffff,0xff0000,0xff0000,0xff0000,0xff0000,
604 0xffffff,0x0000ff,0xffffff,0x0000ff,0xee0000,0xee0000,0xee0000,0xee0000,
605 0x0000ff,0xffffff,0x0000ff,0xffffff,0xdd0000,0xdd0000,0xdd0000,0xdd0000,
606 0xffffff,0x0000ff,0xffffff,0x0000ff,0xcc0000,0xcc0000,0xcc0000,0xcc0000,
607 0x00cc00,0x00cc00,0x00cc00,0x00cc00,0x000000,0x111111,0x111111,0x555555,
608 0x00dd00,0x00dd00,0x00dd00,0x00dd00,0x222222,0xff00ff,0xff00ff,0x333333,
609 0x00ee00,0x00ee00,0x00ee00,0x00ee00,0x222222,0xff00ff,0xff00ff,0x333333,
610 0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x555555,0x444444,0x444444,0x000000};
611 WICColor palettedata
[17] = {1};
612 const WICColor expected_palettedata
[17] = {
613 0xff000000,0xff111111,0xff0000ff,0xff222222,0xffcc0000,0xffdd0000,
614 0xffee0000,0xff333333,0xffff0000,0xff444444,0xffff00ff,0xff555555,
615 0xff00cc00,0xff00dd00,0xff00ee00,0xff00ff00,0xffffffff};
618 hr
= CoCreateInstance(&CLSID_WICBmpDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
619 &IID_IWICBitmapDecoder
, (void**)&decoder
);
620 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
621 if (FAILED(hr
)) return;
623 hbmpdata
= GlobalAlloc(GMEM_MOVEABLE
, sizeof(testbmp_rle8
));
624 ok(hbmpdata
!= 0, "GlobalAlloc failed\n");
627 bmpdata
= GlobalLock(hbmpdata
);
628 memcpy(bmpdata
, testbmp_rle8
, sizeof(testbmp_rle8
));
629 GlobalUnlock(hbmpdata
);
631 hr
= CreateStreamOnHGlobal(hbmpdata
, FALSE
, &bmpstream
);
632 ok(SUCCEEDED(hr
), "CreateStreamOnHGlobal failed, hr=%x\n", hr
);
635 hr
= IWICBitmapDecoder_Initialize(decoder
, bmpstream
, WICDecodeMetadataCacheOnLoad
);
636 ok(hr
== S_OK
, "Initialize failed, hr=%x\n", hr
);
638 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &guidresult
);
639 ok(SUCCEEDED(hr
), "GetContainerFormat failed, hr=%x\n", hr
);
640 ok(IsEqualGUID(&guidresult
, &GUID_ContainerFormatBmp
), "unexpected container format\n");
642 hr
= IWICBitmapDecoder_GetFrameCount(decoder
, &count
);
643 ok(SUCCEEDED(hr
), "GetFrameCount failed, hr=%x\n", hr
);
644 ok(count
== 1, "unexpected count %u\n", count
);
646 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &framedecode
);
647 ok(SUCCEEDED(hr
), "GetFrame failed, hr=%x\n", hr
);
650 IWICImagingFactory
*factory
;
651 IWICPalette
*palette
;
653 hr
= IWICBitmapFrameDecode_GetSize(framedecode
, &width
, &height
);
654 ok(SUCCEEDED(hr
), "GetSize failed, hr=%x\n", hr
);
655 ok(width
== 8, "expected width=8, got %u\n", width
);
656 ok(height
== 8, "expected height=8, got %u\n", height
);
658 hr
= IWICBitmapFrameDecode_GetResolution(framedecode
, &dpiX
, &dpiY
);
659 ok(SUCCEEDED(hr
), "GetResolution failed, hr=%x\n", hr
);
660 ok(fabs(dpiX
- 72.0) < 0.01, "expected dpiX=96.0, got %f\n", dpiX
);
661 ok(fabs(dpiY
- 72.0) < 0.01, "expected dpiY=96.0, got %f\n", dpiY
);
663 hr
= IWICBitmapFrameDecode_GetPixelFormat(framedecode
, &guidresult
);
664 ok(SUCCEEDED(hr
), "GetPixelFormat failed, hr=%x\n", hr
);
665 ok(IsEqualGUID(&guidresult
, &GUID_WICPixelFormat32bppBGR
), "unexpected pixel format\n");
667 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
668 &IID_IWICImagingFactory
, (void**)&factory
);
669 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
672 hr
= IWICImagingFactory_CreatePalette(factory
, &palette
);
673 ok(SUCCEEDED(hr
), "CreatePalette failed, hr=%x\n", hr
);
676 hr
= IWICBitmapDecoder_CopyPalette(decoder
, palette
);
677 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x\n", hr
);
679 hr
= IWICBitmapFrameDecode_CopyPalette(framedecode
, palette
);
680 ok(SUCCEEDED(hr
), "CopyPalette failed, hr=%x\n", hr
);
682 hr
= IWICPalette_GetColorCount(palette
, &count
);
683 ok(SUCCEEDED(hr
), "GetColorCount failed, hr=%x\n", hr
);
684 ok(count
== 17, "expected count=17, got %u\n", count
);
686 hr
= IWICPalette_GetColors(palette
, 17, palettedata
, &count
);
687 ok(SUCCEEDED(hr
), "GetColorCount failed, hr=%x\n", hr
);
688 ok(count
== 17, "expected count=17, got %u\n", count
);
689 ok(!memcmp(palettedata
, expected_palettedata
, sizeof(palettedata
)), "unexpected palette data\n");
691 IWICPalette_Release(palette
);
694 IWICImagingFactory_Release(factory
);
701 hr
= IWICBitmapFrameDecode_CopyPixels(framedecode
, &rc
, 32, sizeof(imagedata
), (BYTE
*)imagedata
);
702 ok(SUCCEEDED(hr
), "CopyPixels failed, hr=%x\n", hr
);
703 ok(!memcmp(imagedata
, expected_imagedata
, sizeof(imagedata
)), "unexpected image data\n");
705 IWICBitmapFrameDecode_Release(framedecode
);
708 hr
= CoCreateInstance(&CLSID_WICBmpDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
709 &IID_IWICBitmapDecoder
, (void**)&decoder2
);
710 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
713 hr
= IWICBitmapDecoder_QueryCapability(decoder2
, bmpstream
, &capability
);
714 ok(hr
== S_OK
, "QueryCapability failed, hr=%x\n", hr
);
715 ok(capability
== (WICBitmapDecoderCapabilityCanDecodeAllImages
),
716 "unexpected capabilities: %x\n", capability
);
717 IWICBitmapDecoder_Release(decoder2
);
720 IStream_Release(bmpstream
);
723 GlobalFree(hbmpdata
);
726 IWICBitmapDecoder_Release(decoder
);
729 static const char testbmp_rle4
[] = {
730 /* BITMAPFILEHEADER */
732 142,0,0,0, /* file size */
733 0,0,0,0, /* reserved */
734 78,0,0,0, /* offset to bits */
735 /* BITMAPINFOHEADER */
736 40,0,0,0, /* header size */
738 8,0,0,0, /* height */
741 2,0,0,0, /* compression = BI_RLE4 */
742 64,0,0,0, /* image size */
743 19,11,0,0, /* X pixels per meter */
744 19,11,0,0, /* Y pixels per meter */
745 6,0,0,0, /* colors used */
746 6,0,0,0, /* colors important */
755 0,8,68,68,0,0,0,0,0,8,68,68,3,48,0,0,0,8,68,68,3,48,0,0,0,8,68,68,0,0,0,0,0,8,81,81,34,34,0,0,0,8,21,21,34,34,0,0,0,8,81,81,34,34,0,0,0,8,21,21,34,34,0,1
758 static void test_decode_rle4(void)
760 IWICBitmapDecoder
*decoder
, *decoder2
;
761 IWICBitmapFrameDecode
*framedecode
;
768 UINT count
=0, width
=0, height
=0;
770 DWORD imagedata
[64] = {1};
771 const DWORD expected_imagedata
[64] = {
772 0x0000ff,0xffffff,0x0000ff,0xffffff,0xff0000,0xff0000,0xff0000,0xff0000,
773 0xffffff,0x0000ff,0xffffff,0x0000ff,0xff0000,0xff0000,0xff0000,0xff0000,
774 0x0000ff,0xffffff,0x0000ff,0xffffff,0xff0000,0xff0000,0xff0000,0xff0000,
775 0xffffff,0x0000ff,0xffffff,0x0000ff,0xff0000,0xff0000,0xff0000,0xff0000,
776 0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x000000,0x000000,0x000000,0x000000,
777 0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x000000,0xff00ff,0xff00ff,0x000000,
778 0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x000000,0xff00ff,0xff00ff,0x000000,
779 0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x000000,0x000000,0x000000,0x000000};
780 WICColor palettedata
[6] = {1};
781 const WICColor expected_palettedata
[6] = {
782 0xff000000,0xff0000ff,0xffff0000,0xffff00ff,0xff00ff00,0xffffffff};
785 hr
= CoCreateInstance(&CLSID_WICBmpDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
786 &IID_IWICBitmapDecoder
, (void**)&decoder
);
787 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
788 if (FAILED(hr
)) return;
790 hbmpdata
= GlobalAlloc(GMEM_MOVEABLE
, sizeof(testbmp_rle4
));
791 ok(hbmpdata
!= 0, "GlobalAlloc failed\n");
794 bmpdata
= GlobalLock(hbmpdata
);
795 memcpy(bmpdata
, testbmp_rle4
, sizeof(testbmp_rle4
));
796 GlobalUnlock(hbmpdata
);
798 hr
= CreateStreamOnHGlobal(hbmpdata
, FALSE
, &bmpstream
);
799 ok(SUCCEEDED(hr
), "CreateStreamOnHGlobal failed, hr=%x\n", hr
);
802 hr
= IWICBitmapDecoder_Initialize(decoder
, bmpstream
, WICDecodeMetadataCacheOnLoad
);
803 ok(hr
== S_OK
, "Initialize failed, hr=%x\n", hr
);
805 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &guidresult
);
806 ok(SUCCEEDED(hr
), "GetContainerFormat failed, hr=%x\n", hr
);
807 ok(IsEqualGUID(&guidresult
, &GUID_ContainerFormatBmp
), "unexpected container format\n");
809 hr
= IWICBitmapDecoder_GetFrameCount(decoder
, &count
);
810 ok(SUCCEEDED(hr
), "GetFrameCount failed, hr=%x\n", hr
);
811 ok(count
== 1, "unexpected count %u\n", count
);
813 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &framedecode
);
814 ok(SUCCEEDED(hr
), "GetFrame failed, hr=%x\n", hr
);
817 IWICImagingFactory
*factory
;
818 IWICPalette
*palette
;
820 hr
= IWICBitmapFrameDecode_GetSize(framedecode
, &width
, &height
);
821 ok(SUCCEEDED(hr
), "GetSize failed, hr=%x\n", hr
);
822 ok(width
== 8, "expected width=8, got %u\n", width
);
823 ok(height
== 8, "expected height=8, got %u\n", height
);
825 hr
= IWICBitmapFrameDecode_GetResolution(framedecode
, &dpiX
, &dpiY
);
826 ok(SUCCEEDED(hr
), "GetResolution failed, hr=%x\n", hr
);
827 ok(fabs(dpiX
- 72.0) < 0.01, "expected dpiX=96.0, got %f\n", dpiX
);
828 ok(fabs(dpiY
- 72.0) < 0.01, "expected dpiY=96.0, got %f\n", dpiY
);
830 hr
= IWICBitmapFrameDecode_GetPixelFormat(framedecode
, &guidresult
);
831 ok(SUCCEEDED(hr
), "GetPixelFormat failed, hr=%x\n", hr
);
832 ok(IsEqualGUID(&guidresult
, &GUID_WICPixelFormat32bppBGR
), "unexpected pixel format\n");
834 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
835 &IID_IWICImagingFactory
, (void**)&factory
);
836 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
839 hr
= IWICImagingFactory_CreatePalette(factory
, &palette
);
840 ok(SUCCEEDED(hr
), "CreatePalette failed, hr=%x\n", hr
);
843 hr
= IWICBitmapDecoder_CopyPalette(decoder
, palette
);
844 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x\n", hr
);
846 hr
= IWICBitmapFrameDecode_CopyPalette(framedecode
, palette
);
847 ok(SUCCEEDED(hr
), "CopyPalette failed, hr=%x\n", hr
);
849 hr
= IWICPalette_GetColorCount(palette
, &count
);
850 ok(SUCCEEDED(hr
), "GetColorCount failed, hr=%x\n", hr
);
851 ok(count
== 6, "expected count=6, got %u\n", count
);
853 hr
= IWICPalette_GetColors(palette
, 6, palettedata
, &count
);
854 ok(SUCCEEDED(hr
), "GetColorCount failed, hr=%x\n", hr
);
855 ok(count
== 6, "expected count=6, got %u\n", count
);
856 ok(!memcmp(palettedata
, expected_palettedata
, sizeof(palettedata
)), "unexpected palette data\n");
858 IWICPalette_Release(palette
);
861 IWICImagingFactory_Release(factory
);
868 hr
= IWICBitmapFrameDecode_CopyPixels(framedecode
, &rc
, 32, sizeof(imagedata
), (BYTE
*)imagedata
);
869 ok(SUCCEEDED(hr
), "CopyPixels failed, hr=%x\n", hr
);
870 ok(!memcmp(imagedata
, expected_imagedata
, sizeof(imagedata
)), "unexpected image data\n");
872 IWICBitmapFrameDecode_Release(framedecode
);
875 hr
= CoCreateInstance(&CLSID_WICBmpDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
876 &IID_IWICBitmapDecoder
, (void**)&decoder2
);
877 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
880 hr
= IWICBitmapDecoder_QueryCapability(decoder2
, bmpstream
, &capability
);
881 ok(hr
== S_OK
, "QueryCapability failed, hr=%x\n", hr
);
882 ok(capability
== (WICBitmapDecoderCapabilityCanDecodeAllImages
),
883 "unexpected capabilities: %x\n", capability
);
884 IWICBitmapDecoder_Release(decoder2
);
887 IStream_Release(bmpstream
);
890 GlobalFree(hbmpdata
);
893 IWICBitmapDecoder_Release(decoder
);
896 static void test_componentinfo(void)
898 IWICImagingFactory
*factory
;
899 IWICComponentInfo
*info
;
900 IWICBitmapDecoderInfo
*decoderinfo
;
901 IWICBitmapDecoder
*decoder
;
903 WICBitmapPattern
*patterns
;
904 UINT pattern_count
, pattern_size
;
905 WICComponentType type
;
912 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
913 &IID_IWICImagingFactory
, (void**)&factory
);
914 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
917 hr
= IWICImagingFactory_CreateComponentInfo(factory
, &CLSID_WICBmpDecoder
, &info
);
918 ok(SUCCEEDED(hr
), "CreateComponentInfo failed, hr=%x\n", hr
);
921 hr
= IWICComponentInfo_GetComponentType(info
, &type
);
922 ok(SUCCEEDED(hr
), "GetComponentType failed, hr=%x\n", hr
);
923 ok(type
== WICDecoder
, "got %i, expected WICDecoder\n", type
);
925 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICBitmapDecoderInfo
, (void**)&decoderinfo
);
926 ok(SUCCEEDED(hr
), "QueryInterface failed, hr=%x\n", hr
);
931 hr
= IWICBitmapDecoderInfo_GetPatterns(decoderinfo
, 0, NULL
, &pattern_count
, &pattern_size
);
932 ok(SUCCEEDED(hr
), "GetPatterns failed, hr=%x\n", hr
);
933 ok(pattern_count
!= 0, "pattern count is 0\n");
934 ok(pattern_size
> pattern_count
* sizeof(WICBitmapPattern
), "size=%i, count=%i\n", pattern_size
, pattern_count
);
936 patterns
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, pattern_size
);
937 hr
= IWICBitmapDecoderInfo_GetPatterns(decoderinfo
, pattern_size
, patterns
, &pattern_count
, &pattern_size
);
938 ok(SUCCEEDED(hr
), "GetPatterns failed, hr=%x\n", hr
);
939 ok(pattern_count
!= 0, "pattern count is 0\n");
940 ok(pattern_size
> pattern_count
* sizeof(WICBitmapPattern
), "size=%i, count=%i\n", pattern_size
, pattern_count
);
941 ok(patterns
[0].Length
!= 0, "pattern length is 0\n");
942 ok(patterns
[0].Pattern
!= NULL
, "pattern is NULL\n");
943 ok(patterns
[0].Mask
!= NULL
, "mask is NULL\n");
946 hr
= IWICBitmapDecoderInfo_GetPatterns(decoderinfo
, pattern_size
, patterns
, &pattern_count
, &pattern_size
);
947 ok(hr
== WINCODEC_ERR_INSUFFICIENTBUFFER
, "GetPatterns returned %x, expected WINCODEC_ERR_INSUFFICIENTBUFFER\n", hr
);
949 HeapFree(GetProcessHeap(), 0, patterns
);
951 hr
= IWICBitmapDecoderInfo_CreateInstance(decoderinfo
, &decoder
);
952 ok(SUCCEEDED(hr
), "CreateInstance failed, hr=%x\n", hr
);
955 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &guidresult
);
956 ok(SUCCEEDED(hr
), "GetContainerFormat failed, hr=%x\n", hr
);
957 ok(IsEqualGUID(&guidresult
, &GUID_ContainerFormatBmp
), "unexpected container format\n");
959 IWICBitmapDecoder_Release(decoder
);
962 hbmpdata
= GlobalAlloc(GMEM_MOVEABLE
, sizeof(testbmp_rle4
));
963 ok(hbmpdata
!= 0, "GlobalAlloc failed\n");
966 bmpdata
= GlobalLock(hbmpdata
);
967 memcpy(bmpdata
, testbmp_rle4
, sizeof(testbmp_rle4
));
968 GlobalUnlock(hbmpdata
);
970 hr
= CreateStreamOnHGlobal(hbmpdata
, FALSE
, &bmpstream
);
971 ok(SUCCEEDED(hr
), "CreateStreamOnHGlobal failed, hr=%x\n", hr
);
975 hr
= IWICBitmapDecoderInfo_MatchesPattern(decoderinfo
, bmpstream
, &boolresult
);
976 ok(SUCCEEDED(hr
), "MatchesPattern failed, hr=%x\n", hr
);
977 ok(boolresult
, "pattern not matched\n");
979 IStream_Release(bmpstream
);
982 GlobalFree(hbmpdata
);
985 IWICBitmapDecoderInfo_Release(decoderinfo
);
988 IWICComponentInfo_Release(info
);
991 IWICImagingFactory_Release(factory
);
995 static void test_createfromstream(void)
997 IWICBitmapDecoder
*decoder
;
998 IWICImagingFactory
*factory
;
1005 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
1006 &IID_IWICImagingFactory
, (void**)&factory
);
1007 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
1008 if (FAILED(hr
)) return;
1010 hbmpdata
= GlobalAlloc(GMEM_MOVEABLE
, sizeof(testbmp_1bpp
));
1011 ok(hbmpdata
!= 0, "GlobalAlloc failed\n");
1014 bmpdata
= GlobalLock(hbmpdata
);
1015 memcpy(bmpdata
, testbmp_1bpp
, sizeof(testbmp_1bpp
));
1016 GlobalUnlock(hbmpdata
);
1018 hr
= CreateStreamOnHGlobal(hbmpdata
, FALSE
, &bmpstream
);
1019 ok(SUCCEEDED(hr
), "CreateStreamOnHGlobal failed, hr=%x\n", hr
);
1022 hr
= IWICImagingFactory_CreateDecoderFromStream(factory
, bmpstream
,
1023 NULL
, WICDecodeMetadataCacheOnDemand
, &decoder
);
1024 ok(SUCCEEDED(hr
), "CreateDecoderFromStream failed, hr=%x\n", hr
);
1027 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &guidresult
);
1028 ok(SUCCEEDED(hr
), "GetContainerFormat failed, hr=%x\n", hr
);
1029 ok(IsEqualGUID(&guidresult
, &GUID_ContainerFormatBmp
), "unexpected container format\n");
1031 IWICBitmapDecoder_Release(decoder
);
1034 IStream_Release(bmpstream
);
1037 GlobalFree(hbmpdata
);
1040 IWICImagingFactory_Release(factory
);
1043 /* 1x1 pixel gif, missing trailer */
1044 static unsigned char gifimage_notrailer
[] = {
1045 0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff,
1046 0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
1050 static void test_gif_notrailer(void)
1052 IWICBitmapDecoder
*decoder
;
1053 IWICImagingFactory
*factory
;
1055 IWICStream
*gifstream
;
1056 IWICBitmapFrameDecode
*framedecode
;
1059 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
1060 &IID_IWICImagingFactory
, (void**)&factory
);
1061 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
1062 if (FAILED(hr
)) return;
1064 hr
= IWICImagingFactory_CreateStream(factory
, &gifstream
);
1065 ok(hr
== S_OK
, "CreateStream failed, hr=%x\n", hr
);
1068 hr
= IWICStream_InitializeFromMemory(gifstream
, gifimage_notrailer
,
1069 sizeof(gifimage_notrailer
));
1070 ok(hr
== S_OK
, "InitializeFromMemory failed, hr=%x\n", hr
);
1074 hr
= CoCreateInstance(&CLSID_WICGifDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
1075 &IID_IWICBitmapDecoder
, (void**)&decoder
);
1076 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
1081 hr
= IWICBitmapDecoder_Initialize(decoder
, (IStream
*)gifstream
,
1082 WICDecodeMetadataCacheOnDemand
);
1083 ok(hr
== S_OK
, "Initialize failed, hr=%x\n", hr
);
1087 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &framedecode
);
1088 ok(hr
== S_OK
, "GetFrame failed, hr=%x\n", hr
);
1089 if (SUCCEEDED(hr
)) IWICBitmapFrameDecode_Release(framedecode
);
1094 hr
= IWICBitmapDecoder_GetFrameCount(decoder
, &framecount
);
1095 ok(hr
== S_OK
, "GetFrameCount failed, hr=%x\n", hr
);
1096 ok(framecount
== 1, "framecount=%u\n", framecount
);
1099 IWICBitmapDecoder_Release(decoder
);
1102 IWICStream_Release(gifstream
);
1105 IWICImagingFactory_Release(factory
);
1108 START_TEST(bmpformat
)
1110 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
1112 test_decode_24bpp();
1117 test_componentinfo();
1118 test_createfromstream();
1119 test_gif_notrailer();