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 "wincodecsdk.h"
29 #include "wine/test.h"
31 static const char testbmp_24bpp[] = {
32 /* BITMAPFILEHEADER */
34 50,0,0,0, /* file size */
35 0,0,0,0, /* reserved */
36 26,0,0,0, /* offset to bits */
37 /* BITMAPCOREHEADER */
38 12,0,0,0, /* header size */
45 255,0,0, 255,255,0, 0,0,
46 255,0,255, 255,255,255, 0,0
49 static void test_decode_24bpp(void)
51 IWICBitmapDecoder *decoder, *decoder2;
52 IWICBitmapFrameDecode *framedecode;
53 IWICMetadataQueryReader *queryreader;
54 IWICColorContext *colorcontext;
55 IWICBitmapSource *thumbnail;
62 UINT count=0, width=0, height=0;
64 BYTE imagedata[36] = {1};
65 const BYTE expected_imagedata[36] = {
66 255,0,255, 255,255,255,
71 hr = CoCreateInstance(&CLSID_WICBmpDecoder, NULL, CLSCTX_INPROC_SERVER,
72 &IID_IWICBitmapDecoder, (void**)&decoder);
73 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
74 if (FAILED(hr)) return;
76 hbmpdata = GlobalAlloc(GMEM_MOVEABLE, sizeof(testbmp_24bpp));
77 ok(hbmpdata != 0, "GlobalAlloc failed\n");
80 bmpdata = GlobalLock(hbmpdata);
81 memcpy(bmpdata, testbmp_24bpp, sizeof(testbmp_24bpp));
82 GlobalUnlock(hbmpdata);
84 hr = CreateStreamOnHGlobal(hbmpdata, FALSE, &bmpstream);
85 ok(SUCCEEDED(hr), "CreateStreamOnHGlobal failed, hr=%x\n", hr);
88 hr = IWICBitmapDecoder_Initialize(decoder, bmpstream, WICDecodeMetadataCacheOnLoad);
89 ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
91 hr = IWICBitmapDecoder_GetContainerFormat(decoder, &guidresult);
92 ok(SUCCEEDED(hr), "GetContainerFormat failed, hr=%x\n", hr);
93 ok(IsEqualGUID(&guidresult, &GUID_ContainerFormatBmp), "unexpected container format\n");
95 hr = IWICBitmapDecoder_GetMetadataQueryReader(decoder, &queryreader);
96 ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "expected WINCODEC_ERR_UNSUPPORTEDOPERATION, got %x\n", hr);
98 hr = IWICBitmapDecoder_GetColorContexts(decoder, 1, &colorcontext, &count);
99 ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "expected WINCODEC_ERR_UNSUPPORTEDOPERATION, got %x\n", hr);
101 hr = IWICBitmapDecoder_GetThumbnail(decoder, &thumbnail);
102 ok(hr == WINCODEC_ERR_CODECNOTHUMBNAIL, "expected WINCODEC_ERR_CODECNOTHUMBNAIL, got %x\n", hr);
104 hr = IWICBitmapDecoder_GetPreview(decoder, &thumbnail);
105 ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "expected WINCODEC_ERR_UNSUPPORTEDOPERATION, got %x\n", hr);
107 hr = IWICBitmapDecoder_GetFrameCount(decoder, &count);
108 ok(SUCCEEDED(hr), "GetFrameCount failed, hr=%x\n", hr);
109 ok(count == 1, "unexpected count %u\n", count);
111 hr = IWICBitmapDecoder_GetFrame(decoder, 1, &framedecode);
112 ok(hr == E_INVALIDARG || hr == WINCODEC_ERR_FRAMEMISSING, "GetFrame returned %x\n", hr);
114 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
115 ok(SUCCEEDED(hr), "GetFrame failed, hr=%x\n", hr);
118 IWICImagingFactory *factory;
119 IWICPalette *palette;
121 hr = IWICBitmapFrameDecode_GetSize(framedecode, &width, &height);
122 ok(SUCCEEDED(hr), "GetSize failed, hr=%x\n", hr);
123 ok(width == 2, "expected width=2, got %u\n", width);
124 ok(height == 3, "expected height=2, got %u\n", height);
126 hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY);
127 ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr);
128 ok(dpiX == 96.0, "expected dpiX=96.0, got %f\n", dpiX);
129 ok(dpiY == 96.0, "expected dpiY=96.0, got %f\n", dpiY);
131 hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &guidresult);
132 ok(SUCCEEDED(hr), "GetPixelFormat failed, hr=%x\n", hr);
133 ok(IsEqualGUID(&guidresult, &GUID_WICPixelFormat24bppBGR), "unexpected pixel format\n");
135 hr = IWICBitmapFrameDecode_GetMetadataQueryReader(framedecode, &queryreader);
136 ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "expected WINCODEC_ERR_UNSUPPORTEDOPERATION, got %x\n", hr);
138 hr = IWICBitmapFrameDecode_GetColorContexts(framedecode, 1, &colorcontext, &count);
139 ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "expected WINCODEC_ERR_UNSUPPORTEDOPERATION, got %x\n", hr);
141 hr = IWICBitmapFrameDecode_GetThumbnail(framedecode, &thumbnail);
142 ok(hr == WINCODEC_ERR_CODECNOTHUMBNAIL, "expected WINCODEC_ERR_CODECNOTHUMBNAIL, got %x\n", hr);
144 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
145 &IID_IWICImagingFactory, (void**)&factory);
146 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
149 hr = IWICImagingFactory_CreatePalette(factory, &palette);
150 ok(SUCCEEDED(hr), "CreatePalette failed, hr=%x\n", hr);
153 hr = IWICBitmapDecoder_CopyPalette(decoder, palette);
154 ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x\n", hr);
156 hr = IWICBitmapFrameDecode_CopyPalette(framedecode, palette);
157 ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x\n", hr);
159 IWICPalette_Release(palette);
162 IWICImagingFactory_Release(factory);
169 hr = IWICBitmapFrameDecode_CopyPixels(framedecode, &rc, 6, sizeof(imagedata), imagedata);
170 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
176 hr = IWICBitmapFrameDecode_CopyPixels(framedecode, &rc, 6, sizeof(imagedata), imagedata);
177 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
183 hr = IWICBitmapFrameDecode_CopyPixels(framedecode, &rc, 4, sizeof(imagedata), imagedata);
184 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
190 hr = IWICBitmapFrameDecode_CopyPixels(framedecode, &rc, 4, 5, imagedata);
191 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
197 hr = IWICBitmapFrameDecode_CopyPixels(framedecode, &rc, 6, sizeof(imagedata), imagedata);
198 ok(SUCCEEDED(hr), "CopyPixels failed, hr=%x\n", hr);
199 ok(!memcmp(imagedata, expected_imagedata, sizeof(imagedata)), "unexpected image data\n");
201 hr = IWICBitmapFrameDecode_CopyPixels(framedecode, NULL, 6, sizeof(imagedata), imagedata);
202 ok(SUCCEEDED(hr), "CopyPixels(rect=NULL) failed, hr=%x\n", hr);
203 ok(!memcmp(imagedata, expected_imagedata, sizeof(imagedata)), "unexpected image data\n");
205 IWICBitmapFrameDecode_Release(framedecode);
208 /* cannot initialize twice */
209 hr = IWICBitmapDecoder_Initialize(decoder, bmpstream, WICDecodeMetadataCacheOnLoad);
210 ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr);
212 /* cannot querycapability after initialize */
213 hr = IWICBitmapDecoder_QueryCapability(decoder, bmpstream, &capability);
214 ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr);
216 hr = CoCreateInstance(&CLSID_WICBmpDecoder, NULL, CLSCTX_INPROC_SERVER,
217 &IID_IWICBitmapDecoder, (void**)&decoder2);
218 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
221 hr = IWICBitmapDecoder_QueryCapability(decoder2, bmpstream, &capability);
222 ok(hr == S_OK, "QueryCapability failed, hr=%x\n", hr);
223 ok(capability == (WICBitmapDecoderCapabilityCanDecodeAllImages),
224 "unexpected capabilities: %x\n", capability);
226 /* cannot initialize after querycapability */
227 hr = IWICBitmapDecoder_Initialize(decoder2, bmpstream, WICDecodeMetadataCacheOnLoad);
228 ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr);
230 /* cannot querycapability twice */
231 hr = IWICBitmapDecoder_QueryCapability(decoder2, bmpstream, &capability);
232 ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr);
234 IWICBitmapDecoder_Release(decoder2);
237 IStream_Release(bmpstream);
240 GlobalFree(hbmpdata);
243 IWICBitmapDecoder_Release(decoder);
246 static const char testbmp_1bpp[] = {
247 /* BITMAPFILEHEADER */
249 40,0,0,0, /* file size */
250 0,0,0,0, /* reserved */
251 32,0,0,0, /* offset to bits */
252 /* BITMAPCOREHEADER */
253 12,0,0,0, /* header size */
266 static void test_decode_1bpp(void)
268 IWICBitmapDecoder *decoder, *decoder2;
269 IWICBitmapFrameDecode *framedecode;
276 UINT count=0, width=0, height=0;
278 BYTE imagedata[2] = {1};
279 const BYTE expected_imagedata[2] = {0x80,0xc0};
280 WICColor palettedata[2] = {1};
281 const WICColor expected_palettedata[2] = {0xff0000ff,0xff00ff00};
284 hr = CoCreateInstance(&CLSID_WICBmpDecoder, NULL, CLSCTX_INPROC_SERVER,
285 &IID_IWICBitmapDecoder, (void**)&decoder);
286 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
287 if (FAILED(hr)) return;
289 hbmpdata = GlobalAlloc(GMEM_MOVEABLE, sizeof(testbmp_1bpp));
290 ok(hbmpdata != 0, "GlobalAlloc failed\n");
293 bmpdata = GlobalLock(hbmpdata);
294 memcpy(bmpdata, testbmp_1bpp, sizeof(testbmp_1bpp));
295 GlobalUnlock(hbmpdata);
297 hr = CreateStreamOnHGlobal(hbmpdata, FALSE, &bmpstream);
298 ok(SUCCEEDED(hr), "CreateStreamOnHGlobal failed, hr=%x\n", hr);
301 hr = IWICBitmapDecoder_Initialize(decoder, bmpstream, WICDecodeMetadataCacheOnLoad);
302 ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
304 hr = IWICBitmapDecoder_GetContainerFormat(decoder, &guidresult);
305 ok(SUCCEEDED(hr), "GetContainerFormat failed, hr=%x\n", hr);
306 ok(IsEqualGUID(&guidresult, &GUID_ContainerFormatBmp), "unexpected container format\n");
308 hr = IWICBitmapDecoder_GetFrameCount(decoder, &count);
309 ok(SUCCEEDED(hr), "GetFrameCount failed, hr=%x\n", hr);
310 ok(count == 1, "unexpected count %u\n", count);
312 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
313 ok(SUCCEEDED(hr), "GetFrame failed, hr=%x\n", hr);
316 IWICImagingFactory *factory;
317 IWICPalette *palette;
319 hr = IWICBitmapFrameDecode_GetSize(framedecode, &width, &height);
320 ok(SUCCEEDED(hr), "GetSize failed, hr=%x\n", hr);
321 ok(width == 2, "expected width=2, got %u\n", width);
322 ok(height == 2, "expected height=2, got %u\n", height);
324 hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY);
325 ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr);
326 ok(dpiX == 96.0, "expected dpiX=96.0, got %f\n", dpiX);
327 ok(dpiY == 96.0, "expected dpiY=96.0, got %f\n", dpiY);
329 hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &guidresult);
330 ok(SUCCEEDED(hr), "GetPixelFormat failed, hr=%x\n", hr);
331 ok(IsEqualGUID(&guidresult, &GUID_WICPixelFormat1bppIndexed), "unexpected pixel format\n");
333 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
334 &IID_IWICImagingFactory, (void**)&factory);
335 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
338 hr = IWICImagingFactory_CreatePalette(factory, &palette);
339 ok(SUCCEEDED(hr), "CreatePalette failed, hr=%x\n", hr);
342 hr = IWICBitmapDecoder_CopyPalette(decoder, palette);
343 ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x\n", hr);
345 hr = IWICBitmapFrameDecode_CopyPalette(framedecode, palette);
346 ok(SUCCEEDED(hr), "CopyPalette failed, hr=%x\n", hr);
348 hr = IWICPalette_GetColorCount(palette, &count);
349 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
350 ok(count == 2, "expected count=2, got %u\n", count);
352 hr = IWICPalette_GetColors(palette, 2, palettedata, &count);
353 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
354 ok(count == 2, "expected count=2, got %u\n", count);
355 ok(!memcmp(palettedata, expected_palettedata, sizeof(palettedata)), "unexpected palette data\n");
357 IWICPalette_Release(palette);
360 IWICImagingFactory_Release(factory);
367 hr = IWICBitmapFrameDecode_CopyPixels(framedecode, &rc, 1, sizeof(imagedata), imagedata);
368 ok(SUCCEEDED(hr), "CopyPixels failed, hr=%x\n", hr);
369 ok(!memcmp(imagedata, expected_imagedata, sizeof(imagedata)), "unexpected image data\n");
371 IWICBitmapFrameDecode_Release(framedecode);
374 hr = CoCreateInstance(&CLSID_WICBmpDecoder, NULL, CLSCTX_INPROC_SERVER,
375 &IID_IWICBitmapDecoder, (void**)&decoder2);
376 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
379 hr = IWICBitmapDecoder_QueryCapability(decoder2, bmpstream, &capability);
380 ok(hr == S_OK, "QueryCapability failed, hr=%x\n", hr);
381 ok(capability == (WICBitmapDecoderCapabilityCanDecodeAllImages),
382 "unexpected capabilities: %x\n", capability);
383 IWICBitmapDecoder_Release(decoder2);
386 IStream_Release(bmpstream);
389 GlobalFree(hbmpdata);
392 IWICBitmapDecoder_Release(decoder);
395 static const char testbmp_4bpp[] = {
396 /* BITMAPFILEHEADER */
398 82,0,0,0, /* file size */
399 0,0,0,0, /* reserved */
400 74,0,0,0, /* offset to bits */
401 /* BITMAPINFOHEADER */
402 40,0,0,0, /* header size */
404 254,255,255,255, /* height = -2 */
407 0,0,0,0, /* compression = BI_RGB */
408 0,0,0,0, /* image size = 0 */
409 16,39,0,0, /* X pixels per meter = 10000 */
410 32,78,0,0, /* Y pixels per meter = 20000 */
411 5,0,0,0, /* colors used */
412 5,0,0,0, /* colors important */
424 static void test_decode_4bpp(void)
426 IWICBitmapDecoder *decoder, *decoder2;
427 IWICBitmapFrameDecode *framedecode;
434 UINT count=0, width=0, height=0;
436 BYTE imagedata[2] = {1};
437 const BYTE expected_imagedata[2] = {0x01,0x23};
438 WICColor palettedata[5] = {1};
439 const WICColor expected_palettedata[5] =
440 {0xff0000ff,0xff00ff00,0xffff0000,0xff800080,0xffffffff};
443 hr = CoCreateInstance(&CLSID_WICBmpDecoder, NULL, CLSCTX_INPROC_SERVER,
444 &IID_IWICBitmapDecoder, (void**)&decoder);
445 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
446 if (FAILED(hr)) return;
448 hbmpdata = GlobalAlloc(GMEM_MOVEABLE, sizeof(testbmp_4bpp));
449 ok(hbmpdata != 0, "GlobalAlloc failed\n");
452 bmpdata = GlobalLock(hbmpdata);
453 memcpy(bmpdata, testbmp_4bpp, sizeof(testbmp_4bpp));
454 GlobalUnlock(hbmpdata);
456 hr = CreateStreamOnHGlobal(hbmpdata, FALSE, &bmpstream);
457 ok(SUCCEEDED(hr), "CreateStreamOnHGlobal failed, hr=%x\n", hr);
460 hr = IWICBitmapDecoder_Initialize(decoder, bmpstream, WICDecodeMetadataCacheOnLoad);
461 ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
463 hr = IWICBitmapDecoder_GetContainerFormat(decoder, &guidresult);
464 ok(SUCCEEDED(hr), "GetContainerFormat failed, hr=%x\n", hr);
465 ok(IsEqualGUID(&guidresult, &GUID_ContainerFormatBmp), "unexpected container format\n");
467 hr = IWICBitmapDecoder_GetFrameCount(decoder, &count);
468 ok(SUCCEEDED(hr), "GetFrameCount failed, hr=%x\n", hr);
469 ok(count == 1, "unexpected count %u\n", count);
471 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
472 ok(SUCCEEDED(hr), "GetFrame failed, hr=%x\n", hr);
475 IWICImagingFactory *factory;
476 IWICPalette *palette;
478 hr = IWICBitmapFrameDecode_GetSize(framedecode, &width, &height);
479 ok(SUCCEEDED(hr), "GetSize failed, hr=%x\n", hr);
480 ok(width == 2, "expected width=2, got %u\n", width);
481 ok(height == 2, "expected height=2, got %u\n", height);
483 hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY);
484 ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr);
485 ok(fabs(dpiX - 254.0) < 0.01, "expected dpiX=96.0, got %f\n", dpiX);
486 ok(fabs(dpiY - 508.0) < 0.01, "expected dpiY=96.0, got %f\n", dpiY);
488 hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &guidresult);
489 ok(SUCCEEDED(hr), "GetPixelFormat failed, hr=%x\n", hr);
490 ok(IsEqualGUID(&guidresult, &GUID_WICPixelFormat4bppIndexed), "unexpected pixel format\n");
492 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
493 &IID_IWICImagingFactory, (void**)&factory);
494 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
497 hr = IWICImagingFactory_CreatePalette(factory, &palette);
498 ok(SUCCEEDED(hr), "CreatePalette failed, hr=%x\n", hr);
501 hr = IWICBitmapDecoder_CopyPalette(decoder, palette);
502 ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x\n", hr);
504 hr = IWICBitmapFrameDecode_CopyPalette(framedecode, palette);
505 ok(SUCCEEDED(hr), "CopyPalette failed, hr=%x\n", hr);
507 hr = IWICPalette_GetColorCount(palette, &count);
508 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
509 ok(count == 5, "expected count=5, got %u\n", count);
511 hr = IWICPalette_GetColors(palette, 5, palettedata, &count);
512 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
513 ok(count == 5, "expected count=5, got %u\n", count);
514 ok(!memcmp(palettedata, expected_palettedata, sizeof(palettedata)), "unexpected palette data\n");
516 IWICPalette_Release(palette);
519 IWICImagingFactory_Release(factory);
526 hr = IWICBitmapFrameDecode_CopyPixels(framedecode, &rc, 1, sizeof(imagedata), imagedata);
527 ok(SUCCEEDED(hr), "CopyPixels failed, hr=%x\n", hr);
528 ok(!memcmp(imagedata, expected_imagedata, sizeof(imagedata)), "unexpected image data\n");
530 IWICBitmapFrameDecode_Release(framedecode);
533 hr = CoCreateInstance(&CLSID_WICBmpDecoder, NULL, CLSCTX_INPROC_SERVER,
534 &IID_IWICBitmapDecoder, (void**)&decoder2);
535 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
538 hr = IWICBitmapDecoder_QueryCapability(decoder2, bmpstream, &capability);
539 ok(hr == S_OK, "QueryCapability failed, hr=%x\n", hr);
540 ok(capability == (WICBitmapDecoderCapabilityCanDecodeAllImages),
541 "unexpected capabilities: %x\n", capability);
542 IWICBitmapDecoder_Release(decoder2);
545 IStream_Release(bmpstream);
548 GlobalFree(hbmpdata);
551 IWICBitmapDecoder_Release(decoder);
554 static const char testbmp_rle8[] = {
555 /* BITMAPFILEHEADER */
557 202,0,0,0, /* file size */
558 0,0,0,0, /* reserved */
559 122,0,0,0, /* offset to bits */
560 /* BITMAPINFOHEADER */
561 40,0,0,0, /* header size */
563 8,0,0,0, /* height */
566 1,0,0,0, /* compression = BI_RLE8 */
567 80,0,0,0, /* image size */
568 19,11,0,0, /* X pixels per meter */
569 19,11,0,0, /* Y pixels per meter */
570 17,0,0,0, /* colors used */
571 17,0,0,0, /* colors important */
591 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
594 static void test_decode_rle8(void)
596 IWICBitmapDecoder *decoder, *decoder2;
597 IWICBitmapFrameDecode *framedecode;
604 UINT count=0, width=0, height=0;
606 DWORD imagedata[64] = {1};
607 const DWORD expected_imagedata[64] = {
608 0x0000ff,0xffffff,0x0000ff,0xffffff,0xff0000,0xff0000,0xff0000,0xff0000,
609 0xffffff,0x0000ff,0xffffff,0x0000ff,0xee0000,0xee0000,0xee0000,0xee0000,
610 0x0000ff,0xffffff,0x0000ff,0xffffff,0xdd0000,0xdd0000,0xdd0000,0xdd0000,
611 0xffffff,0x0000ff,0xffffff,0x0000ff,0xcc0000,0xcc0000,0xcc0000,0xcc0000,
612 0x00cc00,0x00cc00,0x00cc00,0x00cc00,0x000000,0x111111,0x111111,0x555555,
613 0x00dd00,0x00dd00,0x00dd00,0x00dd00,0x222222,0xff00ff,0xff00ff,0x333333,
614 0x00ee00,0x00ee00,0x00ee00,0x00ee00,0x222222,0xff00ff,0xff00ff,0x333333,
615 0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x555555,0x444444,0x444444,0x000000};
616 WICColor palettedata[17] = {1};
617 const WICColor expected_palettedata[17] = {
618 0xff000000,0xff111111,0xff0000ff,0xff222222,0xffcc0000,0xffdd0000,
619 0xffee0000,0xff333333,0xffff0000,0xff444444,0xffff00ff,0xff555555,
620 0xff00cc00,0xff00dd00,0xff00ee00,0xff00ff00,0xffffffff};
623 hr = CoCreateInstance(&CLSID_WICBmpDecoder, NULL, CLSCTX_INPROC_SERVER,
624 &IID_IWICBitmapDecoder, (void**)&decoder);
625 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
626 if (FAILED(hr)) return;
628 hbmpdata = GlobalAlloc(GMEM_MOVEABLE, sizeof(testbmp_rle8));
629 ok(hbmpdata != 0, "GlobalAlloc failed\n");
632 bmpdata = GlobalLock(hbmpdata);
633 memcpy(bmpdata, testbmp_rle8, sizeof(testbmp_rle8));
634 GlobalUnlock(hbmpdata);
636 hr = CreateStreamOnHGlobal(hbmpdata, FALSE, &bmpstream);
637 ok(SUCCEEDED(hr), "CreateStreamOnHGlobal failed, hr=%x\n", hr);
640 hr = IWICBitmapDecoder_Initialize(decoder, bmpstream, WICDecodeMetadataCacheOnLoad);
641 ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
643 hr = IWICBitmapDecoder_GetContainerFormat(decoder, &guidresult);
644 ok(SUCCEEDED(hr), "GetContainerFormat failed, hr=%x\n", hr);
645 ok(IsEqualGUID(&guidresult, &GUID_ContainerFormatBmp), "unexpected container format\n");
647 hr = IWICBitmapDecoder_GetFrameCount(decoder, &count);
648 ok(SUCCEEDED(hr), "GetFrameCount failed, hr=%x\n", hr);
649 ok(count == 1, "unexpected count %u\n", count);
651 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
652 ok(SUCCEEDED(hr), "GetFrame failed, hr=%x\n", hr);
655 IWICImagingFactory *factory;
656 IWICPalette *palette;
658 hr = IWICBitmapFrameDecode_GetSize(framedecode, &width, &height);
659 ok(SUCCEEDED(hr), "GetSize failed, hr=%x\n", hr);
660 ok(width == 8, "expected width=8, got %u\n", width);
661 ok(height == 8, "expected height=8, got %u\n", height);
663 hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY);
664 ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr);
665 ok(fabs(dpiX - 72.0) < 0.01, "expected dpiX=96.0, got %f\n", dpiX);
666 ok(fabs(dpiY - 72.0) < 0.01, "expected dpiY=96.0, got %f\n", dpiY);
668 hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &guidresult);
669 ok(SUCCEEDED(hr), "GetPixelFormat failed, hr=%x\n", hr);
670 ok(IsEqualGUID(&guidresult, &GUID_WICPixelFormat32bppBGR), "unexpected pixel format\n");
672 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
673 &IID_IWICImagingFactory, (void**)&factory);
674 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
677 hr = IWICImagingFactory_CreatePalette(factory, &palette);
678 ok(SUCCEEDED(hr), "CreatePalette failed, hr=%x\n", hr);
681 hr = IWICBitmapDecoder_CopyPalette(decoder, palette);
682 ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x\n", hr);
684 hr = IWICBitmapFrameDecode_CopyPalette(framedecode, palette);
685 ok(SUCCEEDED(hr), "CopyPalette failed, hr=%x\n", hr);
687 hr = IWICPalette_GetColorCount(palette, &count);
688 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
689 ok(count == 17, "expected count=17, got %u\n", count);
691 hr = IWICPalette_GetColors(palette, 17, palettedata, &count);
692 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
693 ok(count == 17, "expected count=17, got %u\n", count);
694 ok(!memcmp(palettedata, expected_palettedata, sizeof(palettedata)), "unexpected palette data\n");
696 IWICPalette_Release(palette);
699 IWICImagingFactory_Release(factory);
706 hr = IWICBitmapFrameDecode_CopyPixels(framedecode, &rc, 32, sizeof(imagedata), (BYTE*)imagedata);
707 ok(SUCCEEDED(hr), "CopyPixels failed, hr=%x\n", hr);
708 ok(!memcmp(imagedata, expected_imagedata, sizeof(imagedata)), "unexpected image data\n");
710 IWICBitmapFrameDecode_Release(framedecode);
713 hr = CoCreateInstance(&CLSID_WICBmpDecoder, NULL, CLSCTX_INPROC_SERVER,
714 &IID_IWICBitmapDecoder, (void**)&decoder2);
715 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
718 hr = IWICBitmapDecoder_QueryCapability(decoder2, bmpstream, &capability);
719 ok(hr == S_OK, "QueryCapability failed, hr=%x\n", hr);
720 ok(capability == (WICBitmapDecoderCapabilityCanDecodeAllImages),
721 "unexpected capabilities: %x\n", capability);
722 IWICBitmapDecoder_Release(decoder2);
725 IStream_Release(bmpstream);
728 GlobalFree(hbmpdata);
731 IWICBitmapDecoder_Release(decoder);
734 static const char testbmp_rle4[] = {
735 /* BITMAPFILEHEADER */
737 142,0,0,0, /* file size */
738 0,0,0,0, /* reserved */
739 78,0,0,0, /* offset to bits */
740 /* BITMAPINFOHEADER */
741 40,0,0,0, /* header size */
743 8,0,0,0, /* height */
746 2,0,0,0, /* compression = BI_RLE4 */
747 64,0,0,0, /* image size */
748 19,11,0,0, /* X pixels per meter */
749 19,11,0,0, /* Y pixels per meter */
750 6,0,0,0, /* colors used */
751 6,0,0,0, /* colors important */
760 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
763 static void test_decode_rle4(void)
765 IWICBitmapDecoder *decoder, *decoder2;
766 IWICBitmapFrameDecode *framedecode;
773 UINT count=0, width=0, height=0;
775 DWORD imagedata[64] = {1};
776 const DWORD expected_imagedata[64] = {
777 0x0000ff,0xffffff,0x0000ff,0xffffff,0xff0000,0xff0000,0xff0000,0xff0000,
778 0xffffff,0x0000ff,0xffffff,0x0000ff,0xff0000,0xff0000,0xff0000,0xff0000,
779 0x0000ff,0xffffff,0x0000ff,0xffffff,0xff0000,0xff0000,0xff0000,0xff0000,
780 0xffffff,0x0000ff,0xffffff,0x0000ff,0xff0000,0xff0000,0xff0000,0xff0000,
781 0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x000000,0x000000,0x000000,0x000000,
782 0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x000000,0xff00ff,0xff00ff,0x000000,
783 0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x000000,0xff00ff,0xff00ff,0x000000,
784 0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x000000,0x000000,0x000000,0x000000};
785 WICColor palettedata[6] = {1};
786 const WICColor expected_palettedata[6] = {
787 0xff000000,0xff0000ff,0xffff0000,0xffff00ff,0xff00ff00,0xffffffff};
790 hr = CoCreateInstance(&CLSID_WICBmpDecoder, NULL, CLSCTX_INPROC_SERVER,
791 &IID_IWICBitmapDecoder, (void**)&decoder);
792 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
793 if (FAILED(hr)) return;
795 hbmpdata = GlobalAlloc(GMEM_MOVEABLE, sizeof(testbmp_rle4));
796 ok(hbmpdata != 0, "GlobalAlloc failed\n");
799 bmpdata = GlobalLock(hbmpdata);
800 memcpy(bmpdata, testbmp_rle4, sizeof(testbmp_rle4));
801 GlobalUnlock(hbmpdata);
803 hr = CreateStreamOnHGlobal(hbmpdata, FALSE, &bmpstream);
804 ok(SUCCEEDED(hr), "CreateStreamOnHGlobal failed, hr=%x\n", hr);
807 hr = IWICBitmapDecoder_Initialize(decoder, bmpstream, WICDecodeMetadataCacheOnLoad);
808 ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
810 hr = IWICBitmapDecoder_GetContainerFormat(decoder, &guidresult);
811 ok(SUCCEEDED(hr), "GetContainerFormat failed, hr=%x\n", hr);
812 ok(IsEqualGUID(&guidresult, &GUID_ContainerFormatBmp), "unexpected container format\n");
814 hr = IWICBitmapDecoder_GetFrameCount(decoder, &count);
815 ok(SUCCEEDED(hr), "GetFrameCount failed, hr=%x\n", hr);
816 ok(count == 1, "unexpected count %u\n", count);
818 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
819 ok(SUCCEEDED(hr), "GetFrame failed, hr=%x\n", hr);
822 IWICImagingFactory *factory;
823 IWICPalette *palette;
825 hr = IWICBitmapFrameDecode_GetSize(framedecode, &width, &height);
826 ok(SUCCEEDED(hr), "GetSize failed, hr=%x\n", hr);
827 ok(width == 8, "expected width=8, got %u\n", width);
828 ok(height == 8, "expected height=8, got %u\n", height);
830 hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY);
831 ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr);
832 ok(fabs(dpiX - 72.0) < 0.01, "expected dpiX=96.0, got %f\n", dpiX);
833 ok(fabs(dpiY - 72.0) < 0.01, "expected dpiY=96.0, got %f\n", dpiY);
835 hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &guidresult);
836 ok(SUCCEEDED(hr), "GetPixelFormat failed, hr=%x\n", hr);
837 ok(IsEqualGUID(&guidresult, &GUID_WICPixelFormat32bppBGR), "unexpected pixel format\n");
839 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
840 &IID_IWICImagingFactory, (void**)&factory);
841 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
844 hr = IWICImagingFactory_CreatePalette(factory, &palette);
845 ok(SUCCEEDED(hr), "CreatePalette failed, hr=%x\n", hr);
848 hr = IWICBitmapDecoder_CopyPalette(decoder, palette);
849 ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x\n", hr);
851 hr = IWICBitmapFrameDecode_CopyPalette(framedecode, palette);
852 ok(SUCCEEDED(hr), "CopyPalette failed, hr=%x\n", hr);
854 hr = IWICPalette_GetColorCount(palette, &count);
855 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
856 ok(count == 6, "expected count=6, got %u\n", count);
858 hr = IWICPalette_GetColors(palette, 6, palettedata, &count);
859 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
860 ok(count == 6, "expected count=6, got %u\n", count);
861 ok(!memcmp(palettedata, expected_palettedata, sizeof(palettedata)), "unexpected palette data\n");
863 IWICPalette_Release(palette);
866 IWICImagingFactory_Release(factory);
873 hr = IWICBitmapFrameDecode_CopyPixels(framedecode, &rc, 32, sizeof(imagedata), (BYTE*)imagedata);
874 ok(SUCCEEDED(hr), "CopyPixels failed, hr=%x\n", hr);
875 ok(!memcmp(imagedata, expected_imagedata, sizeof(imagedata)), "unexpected image data\n");
877 IWICBitmapFrameDecode_Release(framedecode);
880 hr = CoCreateInstance(&CLSID_WICBmpDecoder, NULL, CLSCTX_INPROC_SERVER,
881 &IID_IWICBitmapDecoder, (void**)&decoder2);
882 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
885 hr = IWICBitmapDecoder_QueryCapability(decoder2, bmpstream, &capability);
886 ok(hr == S_OK, "QueryCapability failed, hr=%x\n", hr);
887 ok(capability == (WICBitmapDecoderCapabilityCanDecodeAllImages),
888 "unexpected capabilities: %x\n", capability);
889 IWICBitmapDecoder_Release(decoder2);
892 IStream_Release(bmpstream);
895 GlobalFree(hbmpdata);
898 IWICBitmapDecoder_Release(decoder);
901 static void test_componentinfo(void)
903 IWICImagingFactory *factory;
904 IWICComponentInfo *info;
905 IWICBitmapDecoderInfo *decoderinfo;
906 IWICBitmapDecoder *decoder;
908 WICBitmapPattern *patterns;
909 UINT pattern_count, pattern_size;
910 WICComponentType type;
917 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
918 &IID_IWICImagingFactory, (void**)&factory);
919 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
922 hr = IWICImagingFactory_CreateComponentInfo(factory, &CLSID_WICBmpDecoder, &info);
923 ok(SUCCEEDED(hr), "CreateComponentInfo failed, hr=%x\n", hr);
926 hr = IWICComponentInfo_GetComponentType(info, &type);
927 ok(SUCCEEDED(hr), "GetComponentType failed, hr=%x\n", hr);
928 ok(type == WICDecoder, "got %i, expected WICDecoder\n", type);
930 hr = IWICComponentInfo_QueryInterface(info, &IID_IWICBitmapDecoderInfo, (void**)&decoderinfo);
931 ok(SUCCEEDED(hr), "QueryInterface failed, hr=%x\n", hr);
936 hr = IWICBitmapDecoderInfo_GetPatterns(decoderinfo, 0, NULL, &pattern_count, &pattern_size);
937 ok(SUCCEEDED(hr), "GetPatterns failed, hr=%x\n", hr);
938 ok(pattern_count != 0, "pattern count is 0\n");
939 ok(pattern_size > pattern_count * sizeof(WICBitmapPattern), "size=%i, count=%i\n", pattern_size, pattern_count);
941 patterns = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pattern_size);
942 hr = IWICBitmapDecoderInfo_GetPatterns(decoderinfo, pattern_size, patterns, &pattern_count, &pattern_size);
943 ok(SUCCEEDED(hr), "GetPatterns failed, hr=%x\n", hr);
944 ok(pattern_count != 0, "pattern count is 0\n");
945 ok(pattern_size > pattern_count * sizeof(WICBitmapPattern), "size=%i, count=%i\n", pattern_size, pattern_count);
946 ok(patterns[0].Length != 0, "pattern length is 0\n");
947 ok(patterns[0].Pattern != NULL, "pattern is NULL\n");
948 ok(patterns[0].Mask != NULL, "mask is NULL\n");
951 hr = IWICBitmapDecoderInfo_GetPatterns(decoderinfo, pattern_size, patterns, &pattern_count, &pattern_size);
952 ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "GetPatterns returned %x, expected WINCODEC_ERR_INSUFFICIENTBUFFER\n", hr);
954 HeapFree(GetProcessHeap(), 0, patterns);
956 hr = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, &decoder);
957 ok(SUCCEEDED(hr), "CreateInstance failed, hr=%x\n", hr);
960 hr = IWICBitmapDecoder_GetContainerFormat(decoder, &guidresult);
961 ok(SUCCEEDED(hr), "GetContainerFormat failed, hr=%x\n", hr);
962 ok(IsEqualGUID(&guidresult, &GUID_ContainerFormatBmp), "unexpected container format\n");
964 IWICBitmapDecoder_Release(decoder);
967 hbmpdata = GlobalAlloc(GMEM_MOVEABLE, sizeof(testbmp_rle4));
968 ok(hbmpdata != 0, "GlobalAlloc failed\n");
971 bmpdata = GlobalLock(hbmpdata);
972 memcpy(bmpdata, testbmp_rle4, sizeof(testbmp_rle4));
973 GlobalUnlock(hbmpdata);
975 hr = CreateStreamOnHGlobal(hbmpdata, FALSE, &bmpstream);
976 ok(SUCCEEDED(hr), "CreateStreamOnHGlobal failed, hr=%x\n", hr);
980 hr = IWICBitmapDecoderInfo_MatchesPattern(decoderinfo, bmpstream, &boolresult);
981 ok(SUCCEEDED(hr), "MatchesPattern failed, hr=%x\n", hr);
982 ok(boolresult, "pattern not matched\n");
984 IStream_Release(bmpstream);
987 GlobalFree(hbmpdata);
990 IWICBitmapDecoderInfo_Release(decoderinfo);
993 IWICComponentInfo_Release(info);
996 IWICImagingFactory_Release(factory);
1000 static void test_createfromstream(void)
1002 IWICBitmapDecoder *decoder;
1003 IWICImagingFactory *factory;
1010 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
1011 &IID_IWICImagingFactory, (void**)&factory);
1012 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
1013 if (FAILED(hr)) return;
1015 hbmpdata = GlobalAlloc(GMEM_MOVEABLE, sizeof(testbmp_1bpp));
1016 ok(hbmpdata != 0, "GlobalAlloc failed\n");
1019 bmpdata = GlobalLock(hbmpdata);
1020 memcpy(bmpdata, testbmp_1bpp, sizeof(testbmp_1bpp));
1021 GlobalUnlock(hbmpdata);
1023 hr = CreateStreamOnHGlobal(hbmpdata, FALSE, &bmpstream);
1024 ok(SUCCEEDED(hr), "CreateStreamOnHGlobal failed, hr=%x\n", hr);
1027 hr = IWICImagingFactory_CreateDecoderFromStream(factory, bmpstream,
1028 NULL, WICDecodeMetadataCacheOnDemand, &decoder);
1029 ok(SUCCEEDED(hr), "CreateDecoderFromStream failed, hr=%x\n", hr);
1032 hr = IWICBitmapDecoder_GetContainerFormat(decoder, &guidresult);
1033 ok(SUCCEEDED(hr), "GetContainerFormat failed, hr=%x\n", hr);
1034 ok(IsEqualGUID(&guidresult, &GUID_ContainerFormatBmp), "unexpected container format\n");
1036 IWICBitmapDecoder_Release(decoder);
1039 IStream_Release(bmpstream);
1042 GlobalFree(hbmpdata);
1045 IWICImagingFactory_Release(factory);
1048 /* 1x1 pixel gif, missing trailer */
1049 static unsigned char gifimage_notrailer[] = {
1050 0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x71,0xff,0xff,0xff,
1051 0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
1055 static void test_gif_notrailer(void)
1057 IWICBitmapDecoder *decoder;
1058 IWICImagingFactory *factory;
1060 IWICStream *gifstream;
1061 IWICBitmapFrameDecode *framedecode;
1062 double dpiX = 0.0, dpiY = 0.0;
1065 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
1066 &IID_IWICImagingFactory, (void**)&factory);
1067 ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
1068 if (FAILED(hr)) return;
1070 hr = IWICImagingFactory_CreateStream(factory, &gifstream);
1071 ok(hr == S_OK, "CreateStream failed, hr=%x\n", hr);
1074 hr = IWICStream_InitializeFromMemory(gifstream, gifimage_notrailer,
1075 sizeof(gifimage_notrailer));
1076 ok(hr == S_OK, "InitializeFromMemory failed, hr=%x\n", hr);
1080 hr = CoCreateInstance(&CLSID_WICGifDecoder, NULL, CLSCTX_INPROC_SERVER,
1081 &IID_IWICBitmapDecoder, (void**)&decoder);
1082 ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
1087 hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)gifstream,
1088 WICDecodeMetadataCacheOnDemand);
1089 ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
1093 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
1094 ok(hr == S_OK, "GetFrame failed, hr=%x\n", hr);
1097 hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY);
1098 ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr);
1099 ok(dpiX == 48.0, "expected dpiX=48.0, got %f\n", dpiX);
1100 ok(dpiY == 96.0, "expected dpiY=96.0, got %f\n", dpiY);
1102 IWICBitmapFrameDecode_Release(framedecode);
1108 hr = IWICBitmapDecoder_GetFrameCount(decoder, &framecount);
1109 ok(hr == S_OK, "GetFrameCount failed, hr=%x\n", hr);
1110 ok(framecount == 1, "framecount=%u\n", framecount);
1113 IWICBitmapDecoder_Release(decoder);
1116 IWICStream_Release(gifstream);
1119 IWICImagingFactory_Release(factory);
1122 static void test_create_decoder(void)
1124 IWICBitmapDecoder *decoder;
1125 IWICImagingFactory *factory;
1128 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
1129 &IID_IWICImagingFactory, (void **)&factory);
1130 ok(hr == S_OK, "CoCreateInstance error %#x\n", hr);
1132 hr = IWICImagingFactory_CreateDecoder(factory, NULL, NULL, NULL);
1133 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
1135 hr = IWICImagingFactory_CreateDecoder(factory, NULL, NULL, &decoder);
1136 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
1138 hr = IWICImagingFactory_CreateDecoder(factory, &GUID_ContainerFormatBmp, NULL, &decoder);
1139 ok(hr == S_OK, "CreateDecoder error %#x\n", hr);
1140 IWICBitmapDecoder_Release(decoder);
1142 hr = IWICImagingFactory_CreateDecoder(factory, &GUID_ContainerFormatBmp, &GUID_VendorMicrosoft, &decoder);
1143 ok(hr == S_OK, "CreateDecoder error %#x\n", hr);
1144 IWICBitmapDecoder_Release(decoder);
1146 IWICImagingFactory_Release(factory);
1149 START_TEST(bmpformat)
1151 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
1153 test_decode_24bpp();
1158 test_componentinfo();
1159 test_createfromstream();
1160 test_gif_notrailer();
1161 test_create_decoder();