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
27 #include "wine/test.h"
29 static unsigned char testico_bad_icondirentry_size[] = {
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 */
46 2*16,0,0,0, /* height (XOR+AND rows) */
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 */
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,
94 static void test_bad_icondirentry_size(void)
96 IWICBitmapDecoder *decoder;
97 IWICImagingFactory *factory;
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);
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);
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);
124 hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)icostream,
125 WICDecodeMetadataCacheOnDemand);
126 ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
130 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
131 ok(hr == S_OK, "GetFrame failed, hr=%x\n", 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();