po: Fix a formatting directive in the Danish translation.
[wine/multimedia.git] / dlls / windowscodecs / tests / icoformat.c
blob3974dfcc5780040ca129e2cb4516c3ba6c1cd495
1 /*
2 * Copyright 2010 Damjan Jovanovic
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
19 #include <stdarg.h>
20 #include <math.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "objbase.h"
26 #include "wincodec.h"
27 #include "wine/test.h"
29 static unsigned char testico_bad_icondirentry_size[] = {
30 /* ICONDIR */
31 0, 0, /* reserved */
32 1, 0, /* type */
33 1, 0, /* count */
34 /* ICONDIRENTRY */
35 2, /* width */
36 2, /* height */
37 2, /* colorCount */
38 0, /* reserved */
39 1,0, /* planes */
40 8,0, /* bitCount */
41 (40+2*4+16*16+16*4) & 0xFF,((40+2*4+16*16+16*4) >> 8) & 0xFF,0,0, /* bytesInRes */
42 22,0,0,0, /* imageOffset */
43 /* BITMAPINFOHEADER */
44 40,0,0,0, /* header size */
45 16,0,0,0, /* width */
46 2*16,0,0,0, /* height (XOR+AND rows) */
47 1,0, /* planes */
48 8,0, /* bit count */
49 0,0,0,0, /* compression */
50 0,0,0,0, /* sizeImage */
51 0,0,0,0, /* x pels per meter */
52 0,0,0,0, /* y pels per meter */
53 2,0,0,0, /* clrUsed */
54 0,0,0,0, /* clrImportant */
55 /* palette */
56 0,0,0,0,
57 0xFF,0xFF,0xFF,0,
58 /* XOR mask */
59 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
60 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
61 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
62 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
63 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
64 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,
65 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,
66 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,
67 0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,
68 0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,
69 0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,
70 0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,
71 0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,
72 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
73 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
74 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
75 /* AND mask */
76 0,0,0,0,
77 0,0,0,0,
78 0,0,0,0,
79 0,0,0,0,
80 0,0,0,0,
81 0,0,0,0,
82 0,0,0,0,
83 0,0,0,0,
84 0,0,0,0,
85 0,0,0,0,
86 0,0,0,0,
87 0,0,0,0,
88 0,0,0,0,
89 0,0,0,0,
90 0,0,0,0,
91 0,0,0,0
94 static void test_bad_icondirentry_size(void)
96 IWICBitmapDecoder *decoder;
97 IWICImagingFactory *factory;
98 HRESULT hr;
99 IWICStream *icostream;
100 IWICBitmapFrameDecode *framedecode = NULL;
102 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
103 &IID_IWICImagingFactory, (void**)&factory);
104 ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
105 if (FAILED(hr)) return;
107 hr = IWICImagingFactory_CreateStream(factory, &icostream);
108 ok(hr == S_OK, "CreateStream failed, hr=%x\n", hr);
109 if (SUCCEEDED(hr))
111 hr = IWICStream_InitializeFromMemory(icostream, testico_bad_icondirentry_size,
112 sizeof(testico_bad_icondirentry_size));
113 ok(hr == S_OK, "InitializeFromMemory failed, hr=%x\n", hr);
115 if (SUCCEEDED(hr))
117 hr = CoCreateInstance(&CLSID_WICIcoDecoder, NULL, CLSCTX_INPROC_SERVER,
118 &IID_IWICBitmapDecoder, (void**)&decoder);
119 ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
122 if (SUCCEEDED(hr))
124 hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)icostream,
125 WICDecodeMetadataCacheOnDemand);
126 ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
128 if (SUCCEEDED(hr))
130 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
131 ok(hr == S_OK, "GetFrame failed, hr=%x\n", hr);
134 if (SUCCEEDED(hr))
136 UINT width = 0, height = 0;
137 hr = IWICBitmapFrameDecode_GetSize(framedecode, &width, &height);
138 ok(hr == S_OK, "GetFrameSize failed, hr=%x\n", hr);
139 ok(width == 16 && height == 16, "framesize=%ux%u\n", width, height);
140 IWICBitmapFrameDecode_Release(framedecode);
143 IWICBitmapDecoder_Release(decoder);
146 IWICStream_Release(icostream);
149 IWICImagingFactory_Release(factory);
152 START_TEST(icoformat)
154 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
156 test_bad_icondirentry_size();
158 CoUninitialize();