2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
23 /* generated with JxrEncApp -i image.bmp -o image.jxr -q 1 -c 22 */
24 unsigned char wmp_imagedata
[] = {
25 0x49, 0x49, 0xbc, 0x01, 0x20, 0x00, 0x00, 0x00, 0x24, 0xc3, 0xdd, 0x6f,
26 0x03, 0x4e, 0xfe, 0x4b, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0f,
27 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x01, 0xbc,
28 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0xbc,
29 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbc,
30 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x81, 0xbc,
31 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x82, 0xbc,
32 0x0b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x42, 0x83, 0xbc,
33 0x0b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x42, 0xc0, 0xbc,
34 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0xc1, 0xbc,
35 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0xc2, 0xbc,
36 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x4e, 0x01, 0x00, 0x00, 0xc3, 0xbc,
37 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0xb3, 0x01, 0x00, 0x00, 0x00, 0x00,
38 0x00, 0x00, 0x57, 0x4d, 0x50, 0x48, 0x4f, 0x54, 0x4f, 0x00, 0x11, 0x45,
39 0xc0, 0x71, 0x00, 0x00, 0x00, 0x04, 0x60, 0x00, 0xc0, 0x00, 0x00, 0x0c,
40 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41 0x09, 0x00, 0x26, 0xff, 0xff, 0x00, 0x00, 0x01, 0x01, 0x51, 0x40, 0xc2,
42 0x51, 0x88, 0x00, 0x00, 0x01, 0x02, 0x02, 0x10, 0x08, 0x62, 0x18, 0x84,
43 0x21, 0x00, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
44 0x18, 0x00, 0x00, 0x80, 0x40, 0x30, 0x00, 0x00, 0x00, 0x01, 0x03, 0x19,
45 0x0d, 0x34, 0xd2, 0x77, 0x06, 0x62, 0xe8, 0x89, 0x8b, 0xa2, 0x26, 0x2f,
46 0x11, 0xba, 0xbc, 0x46, 0xea, 0xa3, 0x6e, 0xdd, 0x72, 0x23, 0x75, 0x86,
47 0xcd, 0x48, 0x73, 0xae, 0x43, 0xb9, 0x67, 0x8d, 0xfd, 0x98, 0xb0, 0xd5,
48 0x52, 0x1d, 0xcb, 0x0d, 0x81, 0x06, 0xb4, 0x7d, 0xb8, 0x92, 0x5f, 0xf3,
49 0x75, 0xc0, 0x3b, 0xd5, 0x07, 0xcb, 0xd0, 0xec, 0xde, 0x54, 0x1f, 0x7a,
50 0x9a, 0x21, 0x8e, 0xcd, 0xe5, 0x4c, 0xdc, 0xce, 0xb8, 0x3e, 0xfa, 0x1d,
51 0x8d, 0xca, 0x32, 0x94, 0xd2, 0x93, 0x2c, 0x76, 0x37, 0x2a, 0x63, 0x77,
52 0x72, 0xd4, 0xd7, 0x66, 0x5a, 0xdb, 0x66, 0xed, 0x60, 0x00, 0x57, 0x4d,
53 0x50, 0x48, 0x4f, 0x54, 0x4f, 0x00, 0x11, 0x45, 0xc0, 0x01, 0x00, 0x00,
54 0x00, 0x04, 0x00, 0x80, 0x20, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
55 0x06, 0x00, 0x13, 0xff, 0xff, 0x00, 0x00, 0x01, 0x01, 0x91, 0xe2, 0x00,
56 0x00, 0x01, 0x02, 0x00, 0x86, 0x00, 0x00, 0x20, 0x10, 0x0c, 0x00, 0x00,
57 0x00, 0x00, 0x01, 0x03, 0xad, 0xcf, 0xf4, 0x6b, 0x64, 0x45, 0xe1, 0x91,
58 0x17, 0x8e, 0x9a, 0x51, 0x32, 0x1f, 0xe2, 0x02, 0xfa, 0x69, 0x44, 0x3b,
59 0xfc, 0x7b, 0xab, 0x20, 0xfe, 0x9d, 0x35, 0xd4, 0xda, 0xb7, 0xcb, 0x77,
60 0x5f, 0x4d, 0xe5, 0x0e, 0xee, 0x39, 0x97, 0x6f, 0xb9, 0x99, 0x6b, 0x6d,
63 static void test_decode(void)
65 IWICBitmapDecoder
*decoder
;
66 IWICBitmapFrameDecode
*framedecode
;
67 IWICImagingFactory
*factory
;
74 UINT count
= 0, width
= 0, height
= 0;
75 BYTE imagedata
[5 * 4] = {1};
78 const BYTE expected_imagedata
[5 * 4] = {
79 0x6d, 0xb0, 0xfc, 0x00, 0x6d, 0xb0, 0xfc, 0x00, 0x6d, 0xb0,
80 0xfc, 0x00, 0x6d, 0xb0, 0xfc, 0x00, 0x6d, 0xb0, 0xfc, 0x00,
83 const BYTE broken_imagedata
[5 * 4] = {
84 0x74, 0xa2, 0xd6, 0x28, 0x73, 0xa1, 0xd4, 0x29, 0x71, 0xa9,
85 0xe7, 0x16, 0x71, 0xa9, 0xe7, 0x16, 0x70, 0xa7, 0xe5, 0x17
88 hr
= CoCreateInstance(&CLSID_WICWmpDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
89 &IID_IWICBitmapDecoder
, (void **)&decoder
);
92 win_skip("WmpDecoder isn't available, skipping test\n");
96 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
97 &IID_IWICImagingFactory
, (void **)&factory
);
98 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
100 hwmpdata
= GlobalAlloc(GMEM_MOVEABLE
, sizeof(wmp_imagedata
));
101 ok(hwmpdata
!= 0, "GlobalAlloc failed\n");
103 wmpdata
= GlobalLock(hwmpdata
);
104 memcpy(wmpdata
, wmp_imagedata
, sizeof(wmp_imagedata
));
105 GlobalUnlock(hwmpdata
);
107 hr
= CreateStreamOnHGlobal(hwmpdata
, FALSE
, &wmpstream
);
108 ok(SUCCEEDED(hr
), "CreateStreamOnHGlobal failed, hr=%x\n", hr
);
110 hr
= IWICBitmapDecoder_Initialize(decoder
, wmpstream
, WICDecodeMetadataCacheOnLoad
);
111 ok(hr
== S_OK
, "Initialize failed, hr=%x\n", hr
);
113 hr
= IWICBitmapDecoder_Initialize(decoder
, wmpstream
, WICDecodeMetadataCacheOnLoad
);
114 ok(hr
== WINCODEC_ERR_WRONGSTATE
, "Initialize returned %x\n", hr
);
116 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &format
);
117 ok(SUCCEEDED(hr
), "GetContainerFormat failed, hr=%x\n", hr
);
118 ok(IsEqualGUID(&format
, &GUID_ContainerFormatWmp
),
119 "unexpected container format\n");
121 hr
= IWICBitmapDecoder_GetFrameCount(decoder
, &count
);
122 ok(SUCCEEDED(hr
), "GetFrameCount failed, hr=%x\n", hr
);
123 ok(count
== 1, "unexpected count %u\n", count
);
125 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, NULL
);
126 ok(hr
== E_INVALIDARG
, "GetFrame(NULL) returned hr=%x\n", hr
);
128 for (j
= 2; j
> 0; --j
)
130 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &framedecode
);
131 ok(SUCCEEDED(hr
), "GetFrame failed, hr=%x\n", hr
);
133 hr
= IWICBitmapFrameDecode_GetSize(framedecode
, &width
, &height
);
134 ok(SUCCEEDED(hr
), "GetSize failed, hr=%x\n", hr
);
135 ok(width
== 1, "expected width=1, got %u\n", width
);
136 ok(height
== 5, "expected height=5, got %u\n", height
);
138 hr
= IWICBitmapFrameDecode_GetPixelFormat(framedecode
, &format
);
139 ok(SUCCEEDED(hr
), "GetPixelFormat failed, hr=%x\n", hr
);
140 ok(IsEqualGUID(&format
, &GUID_WICPixelFormat32bppBGRA
),
141 "unexpected pixel format: %s\n", wine_dbgstr_guid(&format
));
143 for (i
= 2; i
> 0; --i
)
145 memset(imagedata
, 0, sizeof(imagedata
));
146 hr
= IWICBitmapFrameDecode_CopyPixels(
147 framedecode
, NULL
, 4, sizeof(imagedata
), imagedata
);
148 ok(SUCCEEDED(hr
), "CopyPixels failed, hr=%x\n", hr
);
149 ok(!memcmp(imagedata
, expected_imagedata
, sizeof(imagedata
)) ||
150 broken(!memcmp(imagedata
, broken_imagedata
, sizeof(imagedata
)) /* w2008s64 */),
151 "unexpected image data\n");
154 hr
= IWICImagingFactory_CreatePalette(factory
, &palette
);
155 ok(SUCCEEDED(hr
), "CreatePalette failed, hr=%x\n", hr
);
157 hr
= IWICBitmapDecoder_CopyPalette(decoder
, palette
);
158 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "Unexpected hr %#x.\n", hr
);
160 hr
= IWICBitmapFrameDecode_CopyPalette(framedecode
, palette
);
161 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "Unexpected hr %#x.\n", hr
);
163 IWICPalette_Release(palette
);
165 IWICBitmapFrameDecode_Release(framedecode
);
168 IStream_Release(wmpstream
);
169 GlobalFree(hwmpdata
);
171 IWICBitmapDecoder_Release(decoder
);
172 IWICImagingFactory_Release(factory
);
175 START_TEST(wmpformat
)
177 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);