2 * Unit test suite for images
4 * Copyright (C) 2007 Google (Evan Stade)
5 * Copyright (C) 2012 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/test.h"
33 #define expect(expected, got) ok((got) == (expected), "Expected %d, got %d\n", (UINT)(expected), (UINT)(got))
34 #define expectf(expected, got) ok(fabs((expected) - (got)) < 0.0001, "Expected %f, got %f\n", (expected), (got))
36 static BOOL
color_match(ARGB c1
, ARGB c2
, BYTE max_diff
)
38 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
40 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
42 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
44 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
48 static void expect_guid(REFGUID expected
, REFGUID got
, int line
, BOOL todo
)
54 StringFromGUID2(got
, bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]));
55 WideCharToMultiByte(CP_ACP
, 0, bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), buffer
, sizeof(buffer
), NULL
, NULL
);
56 StringFromGUID2(expected
, bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]));
57 WideCharToMultiByte(CP_ACP
, 0, bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), buffer2
, sizeof(buffer2
), NULL
, NULL
);
59 todo_wine
ok_(__FILE__
, line
)(IsEqualGUID(expected
, got
), "Expected %s, got %s\n", buffer2
, buffer
);
61 ok_(__FILE__
, line
)(IsEqualGUID(expected
, got
), "Expected %s, got %s\n", buffer2
, buffer
);
64 static void expect_rawformat(REFGUID expected
, GpImage
*img
, int line
, BOOL todo
)
69 stat
= GdipGetImageRawFormat(img
, &raw
);
70 ok_(__FILE__
, line
)(stat
== Ok
, "GdipGetImageRawFormat failed with %d\n", stat
);
71 if(stat
!= Ok
) return;
72 expect_guid(expected
, &raw
, line
, todo
);
75 static void test_bufferrawformat(void* buff
, int size
, REFGUID expected
, int line
, BOOL todo
)
84 hglob
= GlobalAlloc (0, size
);
85 data
= GlobalLock (hglob
);
86 memcpy(data
, buff
, size
);
87 GlobalUnlock(hglob
); data
= NULL
;
89 hres
= CreateStreamOnHGlobal(hglob
, TRUE
, &stream
);
90 ok_(__FILE__
, line
)(hres
== S_OK
, "Failed to create a stream\n");
91 if(hres
!= S_OK
) return;
93 stat
= GdipLoadImageFromStream(stream
, &img
);
94 ok_(__FILE__
, line
)(stat
== Ok
, "Failed to create a Bitmap\n");
96 IStream_Release(stream
);
100 expect_rawformat(expected
, img
, line
, todo
);
102 GdipDisposeImage(img
);
103 IStream_Release(stream
);
106 static void test_Scan0(void)
113 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bm
);
115 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
117 GdipDisposeImage((GpImage
*)bm
);
119 bm
= (GpBitmap
*)0xdeadbeef;
120 stat
= GdipCreateBitmapFromScan0(10, -10, 10, PixelFormat24bppRGB
, NULL
, &bm
);
121 expect(InvalidParameter
, stat
);
122 ok( !bm
, "expected null bitmap\n" );
124 bm
= (GpBitmap
*)0xdeadbeef;
125 stat
= GdipCreateBitmapFromScan0(-10, 10, 10, PixelFormat24bppRGB
, NULL
, &bm
);
126 expect(InvalidParameter
, stat
);
127 ok( !bm
, "expected null bitmap\n" );
129 bm
= (GpBitmap
*)0xdeadbeef;
130 stat
= GdipCreateBitmapFromScan0(10, 0, 10, PixelFormat24bppRGB
, NULL
, &bm
);
131 expect(InvalidParameter
, stat
);
132 ok( !bm
, "expected null bitmap\n" );
135 stat
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, buff
, &bm
);
137 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
139 GdipDisposeImage((GpImage
*)bm
);
141 bm
= (GpBitmap
*) 0xdeadbeef;
142 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, buff
, &bm
);
143 expect(InvalidParameter
, stat
);
144 ok( !bm
, "expected null bitmap\n" );
146 bm
= (GpBitmap
*)0xdeadbeef;
147 stat
= GdipCreateBitmapFromScan0(10, 10, 0, PixelFormat24bppRGB
, buff
, &bm
);
148 expect(InvalidParameter
, stat
);
149 ok( bm
== (GpBitmap
*)0xdeadbeef, "expected deadbeef bitmap\n" );
152 stat
= GdipCreateBitmapFromScan0(10, 10, -8, PixelFormat24bppRGB
, buff
, &bm
);
154 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
156 GdipDisposeImage((GpImage
*)bm
);
158 bm
= (GpBitmap
*)0xdeadbeef;
159 stat
= GdipCreateBitmapFromScan0(10, 10, -10, PixelFormat24bppRGB
, buff
, &bm
);
160 expect(InvalidParameter
, stat
);
161 ok( !bm
, "expected null bitmap\n" );
164 static void test_FromGdiDib(void)
169 BYTE rbmi
[sizeof(BITMAPINFOHEADER
)+256*sizeof(RGBQUAD
)];
170 BITMAPINFO
*bmi
= (BITMAPINFO
*)rbmi
;
175 memset(rbmi
, 0, sizeof(rbmi
));
177 bmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
178 bmi
->bmiHeader
.biWidth
= 10;
179 bmi
->bmiHeader
.biHeight
= 10;
180 bmi
->bmiHeader
.biPlanes
= 1;
181 bmi
->bmiHeader
.biBitCount
= 32;
182 bmi
->bmiHeader
.biCompression
= BI_RGB
;
184 stat
= GdipCreateBitmapFromGdiDib(NULL
, buff
, &bm
);
185 expect(InvalidParameter
, stat
);
187 stat
= GdipCreateBitmapFromGdiDib(bmi
, NULL
, &bm
);
188 expect(InvalidParameter
, stat
);
190 stat
= GdipCreateBitmapFromGdiDib(bmi
, buff
, NULL
);
191 expect(InvalidParameter
, stat
);
193 stat
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
195 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
198 stat
= GdipGetImagePixelFormat((GpImage
*)bm
, &format
);
200 expect(PixelFormat32bppRGB
, format
);
202 GdipDisposeImage((GpImage
*)bm
);
205 bmi
->bmiHeader
.biBitCount
= 24;
206 stat
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
208 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
211 stat
= GdipGetImagePixelFormat((GpImage
*)bm
, &format
);
213 expect(PixelFormat24bppRGB
, format
);
215 GdipDisposeImage((GpImage
*)bm
);
218 bmi
->bmiHeader
.biBitCount
= 16;
219 stat
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
221 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
224 stat
= GdipGetImagePixelFormat((GpImage
*)bm
, &format
);
226 expect(PixelFormat16bppRGB555
, format
);
228 GdipDisposeImage((GpImage
*)bm
);
231 bmi
->bmiHeader
.biBitCount
= 8;
232 stat
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
234 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
237 stat
= GdipGetImagePixelFormat((GpImage
*)bm
, &format
);
239 expect(PixelFormat8bppIndexed
, format
);
241 GdipDisposeImage((GpImage
*)bm
);
244 bmi
->bmiHeader
.biBitCount
= 4;
245 stat
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
247 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
250 stat
= GdipGetImagePixelFormat((GpImage
*)bm
, &format
);
252 expect(PixelFormat4bppIndexed
, format
);
254 GdipDisposeImage((GpImage
*)bm
);
257 bmi
->bmiHeader
.biBitCount
= 1;
258 stat
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
260 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
263 stat
= GdipGetImagePixelFormat((GpImage
*)bm
, &format
);
265 expect(PixelFormat1bppIndexed
, format
);
267 GdipDisposeImage((GpImage
*)bm
);
270 bmi
->bmiHeader
.biBitCount
= 0;
271 stat
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
272 expect(InvalidParameter
, stat
);
275 static void test_GetImageDimension(void)
279 const REAL WIDTH
= 10.0, HEIGHT
= 20.0;
282 bm
= (GpBitmap
*)0xdeadbeef;
283 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
,NULL
, &bm
);
285 ok((GpBitmap
*)0xdeadbeef != bm
, "Expected bitmap to not be 0xdeadbeef\n");
286 ok(NULL
!= bm
, "Expected bitmap to not be NULL\n");
288 stat
= GdipGetImageDimension(NULL
,&w
,&h
);
289 expect(InvalidParameter
, stat
);
291 stat
= GdipGetImageDimension((GpImage
*)bm
,NULL
,&h
);
292 expect(InvalidParameter
, stat
);
294 stat
= GdipGetImageDimension((GpImage
*)bm
,&w
,NULL
);
295 expect(InvalidParameter
, stat
);
299 stat
= GdipGetImageDimension((GpImage
*)bm
,&w
,&h
);
303 GdipDisposeImage((GpImage
*)bm
);
306 static void test_GdipImageGetFrameDimensionsCount(void)
310 const REAL WIDTH
= 10.0, HEIGHT
= 20.0;
312 GUID dimension
= {0};
316 bm
= (GpBitmap
*)0xdeadbeef;
317 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
,NULL
, &bm
);
319 ok((GpBitmap
*)0xdeadbeef != bm
, "Expected bitmap to not be 0xdeadbeef\n");
320 ok(NULL
!= bm
, "Expected bitmap to not be NULL\n");
322 stat
= GdipImageGetFrameDimensionsCount(NULL
,&w
);
323 expect(InvalidParameter
, stat
);
325 stat
= GdipImageGetFrameDimensionsCount((GpImage
*)bm
,NULL
);
326 expect(InvalidParameter
, stat
);
329 stat
= GdipImageGetFrameDimensionsCount((GpImage
*)bm
,&w
);
333 stat
= GdipImageGetFrameDimensionsList((GpImage
*)bm
, &dimension
, 1);
335 expect_guid(&FrameDimensionPage
, &dimension
, __LINE__
, FALSE
);
337 stat
= GdipImageGetFrameDimensionsList((GpImage
*)bm
, &dimension
, 2);
338 expect(InvalidParameter
, stat
);
340 stat
= GdipImageGetFrameDimensionsList((GpImage
*)bm
, &dimension
, 0);
341 expect(InvalidParameter
, stat
);
343 stat
= GdipImageGetFrameCount(NULL
, &dimension
, &count
);
344 expect(InvalidParameter
, stat
);
346 /* WinXP crashes on this test */
349 stat
= GdipImageGetFrameCount((GpImage
*)bm
, &dimension
, NULL
);
350 expect(InvalidParameter
, stat
);
353 stat
= GdipImageGetFrameCount((GpImage
*)bm
, NULL
, &count
);
357 stat
= GdipImageGetFrameCount((GpImage
*)bm
, &dimension
, &count
);
361 GdipBitmapSetPixel(bm
, 0, 0, 0xffffffff);
363 stat
= GdipImageSelectActiveFrame((GpImage
*)bm
, &dimension
, 0);
366 /* SelectActiveFrame has no effect on image data of memory bitmaps */
368 GdipBitmapGetPixel(bm
, 0, 0, &color
);
369 expect(0xffffffff, color
);
371 GdipDisposeImage((GpImage
*)bm
);
374 static void test_LoadingImages(void)
378 stat
= GdipCreateBitmapFromFile(0, 0);
379 expect(InvalidParameter
, stat
);
381 stat
= GdipCreateBitmapFromFile(0, (GpBitmap
**)0xdeadbeef);
382 expect(InvalidParameter
, stat
);
384 stat
= GdipLoadImageFromFile(0, 0);
385 expect(InvalidParameter
, stat
);
387 stat
= GdipLoadImageFromFile(0, (GpImage
**)0xdeadbeef);
388 expect(InvalidParameter
, stat
);
390 stat
= GdipLoadImageFromFileICM(0, 0);
391 expect(InvalidParameter
, stat
);
393 stat
= GdipLoadImageFromFileICM(0, (GpImage
**)0xdeadbeef);
394 expect(InvalidParameter
, stat
);
397 static void test_SavingImages(void)
403 const REAL WIDTH
= 10.0, HEIGHT
= 20.0;
405 ImageCodecInfo
*codecs
;
406 static const CHAR filenameA
[] = "a.bmp";
407 static const WCHAR filename
[] = { 'a','.','b','m','p',0 };
411 stat
= GdipSaveImageToFile(0, 0, 0, 0);
412 expect(InvalidParameter
, stat
);
415 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
421 stat
= GdipSaveImageToFile((GpImage
*)bm
, 0, 0, 0);
422 expect(InvalidParameter
, stat
);
424 stat
= GdipSaveImageToFile((GpImage
*)bm
, filename
, 0, 0);
425 expect(InvalidParameter
, stat
);
427 /* encoder tests should succeed -- already tested */
428 stat
= GdipGetImageEncodersSize(&n
, &s
);
429 if (stat
!= Ok
|| n
== 0) goto cleanup
;
431 codecs
= GdipAlloc(s
);
432 if (!codecs
) goto cleanup
;
434 stat
= GdipGetImageEncoders(n
, s
, codecs
);
435 if (stat
!= Ok
) goto cleanup
;
437 stat
= GdipSaveImageToFile((GpImage
*)bm
, filename
, &codecs
[0].Clsid
, 0);
440 GdipDisposeImage((GpImage
*)bm
);
443 /* re-load and check image stats */
444 stat
= GdipLoadImageFromFile(filename
, (GpImage
**)&bm
);
446 if (stat
!= Ok
) goto cleanup
;
448 stat
= GdipGetImageDimension((GpImage
*)bm
, &w
, &h
);
449 if (stat
!= Ok
) goto cleanup
;
457 GdipDisposeImage((GpImage
*)bm
);
458 ok(DeleteFileA(filenameA
), "Delete failed.\n");
461 static void test_encoders(void)
466 ImageCodecInfo
*codecs
;
470 static const CHAR bmp_format
[] = "BMP";
472 stat
= GdipGetImageEncodersSize(&n
, &s
);
475 codecs
= GdipAlloc(s
);
479 stat
= GdipGetImageEncoders(n
, s
, NULL
);
480 expect(GenericError
, stat
);
482 stat
= GdipGetImageEncoders(0, s
, codecs
);
483 expect(GenericError
, stat
);
485 stat
= GdipGetImageEncoders(n
, s
-1, codecs
);
486 expect(GenericError
, stat
);
488 stat
= GdipGetImageEncoders(n
, s
+1, codecs
);
489 expect(GenericError
, stat
);
491 stat
= GdipGetImageEncoders(n
, s
, codecs
);
495 for (i
= 0; i
< n
; i
++)
499 WideCharToMultiByte(CP_ACP
, 0, codecs
[i
].FormatDescription
, -1,
502 if (CompareStringA(LOCALE_SYSTEM_DEFAULT
, 0,
504 bmp_format
, -1) == CSTR_EQUAL
) {
510 ok(FALSE
, "No BMP codec found.\n");
515 static void test_LockBits(void)
521 const INT WIDTH
= 10, HEIGHT
= 20;
526 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
534 stat
= GdipBitmapSetPixel(bm
, 2, 3, 0xffc30000);
537 stat
= GdipBitmapSetPixel(bm
, 2, 8, 0xff480000);
541 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
545 expect(0xc3, ((BYTE
*)bd
.Scan0
)[2]);
546 expect(0x48, ((BYTE
*)bd
.Scan0
)[2 + bd
.Stride
* 5]);
548 ((char*)bd
.Scan0
)[2] = 0xff;
550 stat
= GdipBitmapUnlockBits(bm
, &bd
);
554 stat
= GdipBitmapGetPixel(bm
, 2, 3, &color
);
556 expect(0xffff0000, color
);
558 stat
= GdipBitmapSetPixel(bm
, 2, 3, 0xffc30000);
561 /* read-only, with NULL rect -> whole bitmap lock */
562 stat
= GdipBitmapLockBits(bm
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
564 expect(bd
.Width
, WIDTH
);
565 expect(bd
.Height
, HEIGHT
);
568 ((char*)bd
.Scan0
)[2 + 2*3 + 3*bd
.Stride
] = 0xff;
570 stat
= GdipBitmapUnlockBits(bm
, &bd
);
574 stat
= GdipBitmapGetPixel(bm
, 2, 3, &color
);
576 expect(0xffff0000, color
);
578 /* read-only, consecutive */
579 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
583 stat
= GdipBitmapUnlockBits(bm
, &bd
);
587 stat
= GdipDisposeImage((GpImage
*)bm
);
589 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
593 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
595 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
596 expect(WrongState
, stat
);
598 stat
= GdipBitmapUnlockBits(bm
, &bd
);
601 stat
= GdipDisposeImage((GpImage
*)bm
);
603 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
606 stat
= GdipBitmapSetPixel(bm
, 2, 3, 0xffff0000);
609 stat
= GdipBitmapSetPixel(bm
, 2, 8, 0xffc30000);
612 /* write, no conversion */
613 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeWrite
, PixelFormat24bppRGB
, &bd
);
617 /* all bits are readable, inside the rect or not */
618 expect(0xff, ((BYTE
*)bd
.Scan0
)[2]);
619 expect(0xc3, ((BYTE
*)bd
.Scan0
)[2 + bd
.Stride
* 5]);
621 stat
= GdipBitmapUnlockBits(bm
, &bd
);
625 /* read, conversion */
626 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
, PixelFormat32bppARGB
, &bd
);
630 expect(0xff, ((BYTE
*)bd
.Scan0
)[2]);
632 /* Areas outside the rectangle appear to be uninitialized */
633 ok(0xc3 != ((BYTE
*)bd
.Scan0
)[2 + bd
.Stride
* 5], "original image bits are readable\n");
635 ((BYTE
*)bd
.Scan0
)[2] = 0xc3;
637 stat
= GdipBitmapUnlockBits(bm
, &bd
);
641 /* writes do not work in read mode if there was a conversion */
642 stat
= GdipBitmapGetPixel(bm
, 2, 3, &color
);
644 expect(0xffff0000, color
);
646 /* read/write, conversion */
647 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
|ImageLockModeWrite
, PixelFormat32bppARGB
, &bd
);
651 expect(0xff, ((BYTE
*)bd
.Scan0
)[2]);
652 ((BYTE
*)bd
.Scan0
)[1] = 0x88;
654 /* Areas outside the rectangle appear to be uninitialized */
655 ok(0xc3 != ((BYTE
*)bd
.Scan0
)[2 + bd
.Stride
* 5], "original image bits are readable\n");
657 stat
= GdipBitmapUnlockBits(bm
, &bd
);
661 stat
= GdipBitmapGetPixel(bm
, 2, 3, &color
);
663 expect(0xffff8800, color
);
665 /* write, conversion */
666 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeWrite
, PixelFormat32bppARGB
, &bd
);
672 /* This is completely uninitialized. */
673 ok(0xff != ((BYTE
*)bd
.Scan0
)[2], "original image bits are readable\n");
674 ok(0xc3 != ((BYTE
*)bd
.Scan0
)[2 + bd
.Stride
* 5], "original image bits are readable\n");
677 /* Initialize the buffer so the unlock doesn't access undefined memory */
679 memset(((BYTE
*)bd
.Scan0
) + bd
.Stride
* y
, 0, 12);
681 ((BYTE
*)bd
.Scan0
)[0] = 0x12;
682 ((BYTE
*)bd
.Scan0
)[1] = 0x34;
683 ((BYTE
*)bd
.Scan0
)[2] = 0x56;
685 stat
= GdipBitmapUnlockBits(bm
, &bd
);
689 stat
= GdipBitmapGetPixel(bm
, 2, 3, &color
);
691 expect(0xff563412, color
);
693 stat
= GdipBitmapGetPixel(bm
, 2, 8, &color
);
695 expect(0xffc30000, color
);
697 stat
= GdipDisposeImage((GpImage
*)bm
);
699 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
702 /* write, no modification */
703 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeWrite
, PixelFormat24bppRGB
, &bd
);
707 stat
= GdipBitmapUnlockBits(bm
, &bd
);
711 /* write, consecutive */
712 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeWrite
, PixelFormat24bppRGB
, &bd
);
716 stat
= GdipBitmapUnlockBits(bm
, &bd
);
720 stat
= GdipDisposeImage((GpImage
*)bm
);
722 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
726 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeWrite
, PixelFormat24bppRGB
, &bd
);
731 ((char*)bd
.Scan0
)[2] = 0xff;
733 stat
= GdipBitmapUnlockBits(bm
, &bd
);
737 stat
= GdipBitmapGetPixel(bm
, 2, 3, &color
);
739 expect(0xffff0000, color
);
741 stat
= GdipDisposeImage((GpImage
*)bm
);
745 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
747 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
749 stat
= GdipDisposeImage((GpImage
*)bm
);
753 static void test_LockBits_UserBuf(void)
759 const INT WIDTH
= 10, HEIGHT
= 20;
764 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat32bppARGB
, NULL
, &bm
);
767 memset(bits
, 0xaa, sizeof(bits
));
776 bd
.Stride
= WIDTH
* 4;
777 bd
.PixelFormat
= PixelFormat32bppARGB
;
778 bd
.Scan0
= &bits
[2+3*WIDTH
];
779 bd
.Reserved
= 0xaaaaaaaa;
782 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
|ImageLockModeUserInputBuf
, PixelFormat32bppARGB
, &bd
);
785 expect(0xaaaaaaaa, bits
[0]);
786 expect(0, bits
[2+3*WIDTH
]);
788 bits
[2+3*WIDTH
] = 0xdeadbeef;
791 stat
= GdipBitmapUnlockBits(bm
, &bd
);
795 stat
= GdipBitmapGetPixel(bm
, 2, 3, &color
);
800 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeWrite
|ImageLockModeUserInputBuf
, PixelFormat32bppARGB
, &bd
);
803 expect(0xdeadbeef, bits
[2+3*WIDTH
]);
804 bits
[2+3*WIDTH
] = 0x12345678;
807 stat
= GdipBitmapUnlockBits(bm
, &bd
);
811 stat
= GdipBitmapGetPixel(bm
, 2, 3, &color
);
813 expect(0x12345678, color
);
818 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
|ImageLockModeWrite
|ImageLockModeUserInputBuf
, PixelFormat32bppARGB
, &bd
);
821 expect(0x12345678, bits
[2+3*WIDTH
]);
822 bits
[2+3*WIDTH
] = 0xdeadbeef;
825 stat
= GdipBitmapUnlockBits(bm
, &bd
);
829 stat
= GdipBitmapGetPixel(bm
, 2, 3, &color
);
831 expect(0xdeadbeef, color
);
833 stat
= GdipDisposeImage((GpImage
*)bm
);
837 struct BITMAPINFOWITHBITFIELDS
839 BITMAPINFOHEADER bmiHeader
;
843 union BITMAPINFOUNION
846 struct BITMAPINFOWITHBITFIELDS bf
;
849 static void test_GdipCreateBitmapFromHBITMAP(void)
851 GpBitmap
* gpbm
= NULL
;
853 HPALETTE hpal
= NULL
;
856 LOGPALETTE
* LogPal
= NULL
;
858 const REAL WIDTH1
= 5;
859 const REAL HEIGHT1
= 15;
860 const REAL WIDTH2
= 10;
861 const REAL HEIGHT2
= 20;
863 union BITMAPINFOUNION bmi
;
867 stat
= GdipCreateBitmapFromHBITMAP(NULL
, NULL
, NULL
);
868 expect(InvalidParameter
, stat
);
870 hbm
= CreateBitmap(WIDTH1
, HEIGHT1
, 1, 1, NULL
);
871 stat
= GdipCreateBitmapFromHBITMAP(hbm
, NULL
, NULL
);
872 expect(InvalidParameter
, stat
);
874 stat
= GdipCreateBitmapFromHBITMAP(hbm
, NULL
, &gpbm
);
876 expect(Ok
, GdipGetImageDimension((GpImage
*) gpbm
, &width
, &height
));
877 expectf(WIDTH1
, width
);
878 expectf(HEIGHT1
, height
);
880 GdipDisposeImage((GpImage
*)gpbm
);
883 memset(buff
, 0, sizeof(buff
));
884 hbm
= CreateBitmap(WIDTH2
, HEIGHT2
, 1, 1, &buff
);
885 stat
= GdipCreateBitmapFromHBITMAP(hbm
, NULL
, &gpbm
);
888 expect_rawformat(&ImageFormatMemoryBMP
, (GpImage
*)gpbm
, __LINE__
, FALSE
);
890 expect(Ok
, GdipGetImageDimension((GpImage
*) gpbm
, &width
, &height
));
891 expectf(WIDTH2
, width
);
892 expectf(HEIGHT2
, height
);
894 GdipDisposeImage((GpImage
*)gpbm
);
897 hdc
= CreateCompatibleDC(0);
898 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
899 bmi
.bi
.bmiHeader
.biSize
= sizeof(bmi
.bi
.bmiHeader
);
900 bmi
.bi
.bmiHeader
.biHeight
= HEIGHT1
;
901 bmi
.bi
.bmiHeader
.biWidth
= WIDTH1
;
902 bmi
.bi
.bmiHeader
.biBitCount
= 24;
903 bmi
.bi
.bmiHeader
.biPlanes
= 1;
904 bmi
.bi
.bmiHeader
.biCompression
= BI_RGB
;
905 bmi
.bi
.bmiHeader
.biClrUsed
= 0;
907 hbm
= CreateDIBSection(hdc
, &bmi
.bi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
908 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
912 stat
= GdipCreateBitmapFromHBITMAP(hbm
, NULL
, &gpbm
);
914 expect(Ok
, GdipGetImageDimension((GpImage
*) gpbm
, &width
, &height
));
915 expectf(WIDTH1
, width
);
916 expectf(HEIGHT1
, height
);
919 /* test whether writing to the bitmap affects the original */
920 stat
= GdipBitmapSetPixel(gpbm
, 0, 0, 0xffffffff);
925 GdipDisposeImage((GpImage
*)gpbm
);
928 LogPal
= GdipAlloc(sizeof(LOGPALETTE
));
929 ok(LogPal
!= NULL
, "unable to allocate LOGPALETTE\n");
930 LogPal
->palVersion
= 0x300;
931 LogPal
->palNumEntries
= 1;
932 hpal
= CreatePalette(LogPal
);
933 ok(hpal
!= NULL
, "CreatePalette failed\n");
936 stat
= GdipCreateBitmapFromHBITMAP(hbm
, hpal
, &gpbm
);
940 GdipDisposeImage((GpImage
*)gpbm
);
945 /* 16-bit 555 dib, rgb */
946 bmi
.bi
.bmiHeader
.biBitCount
= 16;
947 bmi
.bi
.bmiHeader
.biCompression
= BI_RGB
;
949 hbm
= CreateDIBSection(hdc
, &bmi
.bi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
950 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
954 stat
= GdipCreateBitmapFromHBITMAP(hbm
, NULL
, &gpbm
);
959 stat
= GdipGetImageDimension((GpImage
*) gpbm
, &width
, &height
);
961 expectf(WIDTH1
, width
);
962 expectf(HEIGHT1
, height
);
964 stat
= GdipGetImagePixelFormat((GpImage
*) gpbm
, &format
);
966 expect(PixelFormat16bppRGB555
, format
);
968 GdipDisposeImage((GpImage
*)gpbm
);
972 /* 16-bit 555 dib, with bitfields */
973 bmi
.bi
.bmiHeader
.biSize
= sizeof(bmi
);
974 bmi
.bi
.bmiHeader
.biCompression
= BI_BITFIELDS
;
975 bmi
.bf
.masks
[0] = 0x7c00;
976 bmi
.bf
.masks
[1] = 0x3e0;
977 bmi
.bf
.masks
[2] = 0x1f;
979 hbm
= CreateDIBSection(hdc
, &bmi
.bi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
980 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
984 stat
= GdipCreateBitmapFromHBITMAP(hbm
, NULL
, &gpbm
);
989 stat
= GdipGetImageDimension((GpImage
*) gpbm
, &width
, &height
);
991 expectf(WIDTH1
, width
);
992 expectf(HEIGHT1
, height
);
994 stat
= GdipGetImagePixelFormat((GpImage
*) gpbm
, &format
);
996 expect(PixelFormat16bppRGB555
, format
);
998 GdipDisposeImage((GpImage
*)gpbm
);
1002 /* 16-bit 565 dib, with bitfields */
1003 bmi
.bf
.masks
[0] = 0xf800;
1004 bmi
.bf
.masks
[1] = 0x7e0;
1005 bmi
.bf
.masks
[2] = 0x1f;
1007 hbm
= CreateDIBSection(hdc
, &bmi
.bi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
1008 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
1012 stat
= GdipCreateBitmapFromHBITMAP(hbm
, NULL
, &gpbm
);
1017 stat
= GdipGetImageDimension((GpImage
*) gpbm
, &width
, &height
);
1019 expectf(WIDTH1
, width
);
1020 expectf(HEIGHT1
, height
);
1022 stat
= GdipGetImagePixelFormat((GpImage
*) gpbm
, &format
);
1024 expect(PixelFormat16bppRGB565
, format
);
1026 GdipDisposeImage((GpImage
*)gpbm
);
1033 static void test_GdipGetImageFlags(void)
1039 img
= (GpImage
*)0xdeadbeef;
1041 stat
= GdipGetImageFlags(NULL
, NULL
);
1042 expect(InvalidParameter
, stat
);
1044 stat
= GdipGetImageFlags(NULL
, &flags
);
1045 expect(InvalidParameter
, stat
);
1047 stat
= GdipGetImageFlags(img
, NULL
);
1048 expect(InvalidParameter
, stat
);
1050 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, (GpBitmap
**)&img
);
1052 stat
= GdipGetImageFlags(img
, &flags
);
1054 expect(ImageFlagsHasAlpha
, flags
);
1055 GdipDisposeImage(img
);
1057 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, (GpBitmap
**)&img
);
1059 stat
= GdipGetImageFlags(img
, &flags
);
1061 expect(ImageFlagsHasAlpha
, flags
);
1062 GdipDisposeImage(img
);
1064 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, (GpBitmap
**)&img
);
1066 stat
= GdipGetImageFlags(img
, &flags
);
1068 expect(ImageFlagsHasAlpha
, flags
);
1069 GdipDisposeImage(img
);
1071 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, (GpBitmap
**)&img
);
1073 stat
= GdipGetImageFlags(img
, &flags
);
1075 expect(ImageFlagsNone
, flags
);
1076 GdipDisposeImage(img
);
1078 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, (GpBitmap
**)&img
);
1080 stat
= GdipGetImageFlags(img
, &flags
);
1082 expect(ImageFlagsNone
, flags
);
1083 GdipDisposeImage(img
);
1085 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, (GpBitmap
**)&img
);
1087 stat
= GdipGetImageFlags(img
, &flags
);
1089 expect(ImageFlagsNone
, flags
);
1090 GdipDisposeImage(img
);
1092 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppARGB1555
, NULL
, (GpBitmap
**)&img
);
1094 stat
= GdipGetImageFlags(img
, &flags
);
1096 expect(ImageFlagsHasAlpha
, flags
);
1097 GdipDisposeImage(img
);
1099 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, (GpBitmap
**)&img
);
1101 stat
= GdipGetImageFlags(img
, &flags
);
1103 expect(ImageFlagsNone
, flags
);
1104 GdipDisposeImage(img
);
1106 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, (GpBitmap
**)&img
);
1108 stat
= GdipGetImageFlags(img
, &flags
);
1110 expect(ImageFlagsNone
, flags
);
1111 GdipDisposeImage(img
);
1113 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, (GpBitmap
**)&img
);
1115 stat
= GdipGetImageFlags(img
, &flags
);
1117 expect(ImageFlagsHasAlpha
, flags
);
1118 GdipDisposeImage(img
);
1120 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppPARGB
, NULL
, (GpBitmap
**)&img
);
1122 stat
= GdipGetImageFlags(img
, &flags
);
1124 expect(ImageFlagsHasAlpha
, flags
);
1125 GdipDisposeImage(img
);
1127 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, (GpBitmap
**)&img
);
1131 stat
= GdipGetImageFlags(img
, &flags
);
1133 expect(ImageFlagsNone
, flags
);
1134 GdipDisposeImage(img
);
1137 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, (GpBitmap
**)&img
);
1142 stat
= GdipGetImageFlags(img
, &flags
);
1144 expect(ImageFlagsHasAlpha
, flags
);
1145 GdipDisposeImage(img
);
1148 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, (GpBitmap
**)&img
);
1153 stat
= GdipGetImageFlags(img
, &flags
);
1155 expect(ImageFlagsHasAlpha
, flags
);
1156 GdipDisposeImage(img
);
1160 static void test_GdipCloneImage(void)
1166 GpImage
*image_src
, *image_dest
= NULL
;
1167 const INT WIDTH
= 10, HEIGHT
= 20;
1169 /* Create an image, clone it, delete the original, make sure the copy works */
1170 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
1172 expect_rawformat(&ImageFormatMemoryBMP
, (GpImage
*)bm
, __LINE__
, FALSE
);
1174 image_src
= ((GpImage
*)bm
);
1175 stat
= GdipCloneImage(image_src
, &image_dest
);
1177 expect_rawformat(&ImageFormatMemoryBMP
, image_dest
, __LINE__
, FALSE
);
1179 stat
= GdipDisposeImage((GpImage
*)bm
);
1181 stat
= GdipGetImageBounds(image_dest
, &rectF
, &unit
);
1184 /* Treat FP values carefully */
1185 expectf((REAL
)WIDTH
, rectF
.Width
);
1186 expectf((REAL
)HEIGHT
, rectF
.Height
);
1188 stat
= GdipDisposeImage(image_dest
);
1192 static void test_testcontrol(void)
1198 stat
= GdipTestControl(TestControlGetBuildNumber
, ¶m
);
1200 ok(param
!= 0, "Build number expected, got %u\n", param
);
1203 static void test_fromhicon(void)
1205 static const BYTE bmp_bits
[1024];
1206 HBITMAP hbmMask
, hbmColor
;
1210 GpBitmap
*bitmap
= NULL
;
1216 stat
= GdipCreateBitmapFromHICON(NULL
, NULL
);
1217 expect(InvalidParameter
, stat
);
1218 stat
= GdipCreateBitmapFromHICON(NULL
, &bitmap
);
1219 expect(InvalidParameter
, stat
);
1221 /* color icon 1 bit */
1222 hbmMask
= CreateBitmap(16, 16, 1, 1, bmp_bits
);
1223 ok(hbmMask
!= 0, "CreateBitmap failed\n");
1224 hbmColor
= CreateBitmap(16, 16, 1, 1, bmp_bits
);
1225 ok(hbmColor
!= 0, "CreateBitmap failed\n");
1229 info
.hbmMask
= hbmMask
;
1230 info
.hbmColor
= hbmColor
;
1231 hIcon
= CreateIconIndirect(&info
);
1232 ok(hIcon
!= 0, "CreateIconIndirect failed\n");
1233 DeleteObject(hbmMask
);
1234 DeleteObject(hbmColor
);
1236 stat
= GdipCreateBitmapFromHICON(hIcon
, &bitmap
);
1238 broken(stat
== InvalidParameter
), /* Win98 */
1239 "Expected Ok, got %.8x\n", stat
);
1241 /* check attributes */
1242 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &dim
);
1245 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &dim
);
1248 stat
= GdipGetImageType((GpImage
*)bitmap
, &type
);
1250 expect(ImageTypeBitmap
, type
);
1251 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
1253 expect(PixelFormat32bppARGB
, format
);
1255 expect_rawformat(&ImageFormatMemoryBMP
, (GpImage
*)bitmap
, __LINE__
, FALSE
);
1256 GdipDisposeImage((GpImage
*)bitmap
);
1260 /* color icon 8 bpp */
1261 hbmMask
= CreateBitmap(16, 16, 1, 8, bmp_bits
);
1262 ok(hbmMask
!= 0, "CreateBitmap failed\n");
1263 hbmColor
= CreateBitmap(16, 16, 1, 8, bmp_bits
);
1264 ok(hbmColor
!= 0, "CreateBitmap failed\n");
1268 info
.hbmMask
= hbmMask
;
1269 info
.hbmColor
= hbmColor
;
1270 hIcon
= CreateIconIndirect(&info
);
1271 ok(hIcon
!= 0, "CreateIconIndirect failed\n");
1272 DeleteObject(hbmMask
);
1273 DeleteObject(hbmColor
);
1275 stat
= GdipCreateBitmapFromHICON(hIcon
, &bitmap
);
1278 /* check attributes */
1279 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &dim
);
1282 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &dim
);
1285 stat
= GdipGetImageType((GpImage
*)bitmap
, &type
);
1287 expect(ImageTypeBitmap
, type
);
1288 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
1290 expect(PixelFormat32bppARGB
, format
);
1292 expect_rawformat(&ImageFormatMemoryBMP
, (GpImage
*)bitmap
, __LINE__
, FALSE
);
1293 GdipDisposeImage((GpImage
*)bitmap
);
1299 static const unsigned char pngimage
[285] = {
1300 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
1301 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,
1302 0xde,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b,
1303 0x13,0x01,0x00,0x9a,0x9c,0x18,0x00,0x00,0x00,0x07,0x74,0x49,0x4d,0x45,0x07,0xd5,
1304 0x06,0x03,0x0f,0x07,0x2d,0x12,0x10,0xf0,0xfd,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,
1305 0x54,0x08,0xd7,0x63,0xf8,0xff,0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,
1306 0xe7,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
1309 static const unsigned char gifimage
[35] = {
1310 0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff,
1311 0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
1315 static const unsigned char bmpimage
[66] = {
1316 0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
1317 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
1318 0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
1319 0x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0x00,0x00,
1323 static const unsigned char jpgimage
[285] = {
1324 0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2c,
1325 0x01,0x2c,0x00,0x00,0xff,0xdb,0x00,0x43,0x00,0x05,0x03,0x04,0x04,0x04,0x03,0x05,
1326 0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x07,0x0c,0x08,0x07,0x07,0x07,0x07,0x0f,0x0b,
1327 0x0b,0x09,0x0c,0x11,0x0f,0x12,0x12,0x11,0x0f,0x11,0x11,0x13,0x16,0x1c,0x17,0x13,
1328 0x14,0x1a,0x15,0x11,0x11,0x18,0x21,0x18,0x1a,0x1d,0x1d,0x1f,0x1f,0x1f,0x13,0x17,
1329 0x22,0x24,0x22,0x1e,0x24,0x1c,0x1e,0x1f,0x1e,0xff,0xdb,0x00,0x43,0x01,0x05,0x05,
1330 0x05,0x07,0x06,0x07,0x0e,0x08,0x08,0x0e,0x1e,0x14,0x11,0x14,0x1e,0x1e,0x1e,0x1e,
1331 0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
1332 0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
1333 0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0xff,0xc0,
1334 0x00,0x11,0x08,0x00,0x01,0x00,0x01,0x03,0x01,0x22,0x00,0x02,0x11,0x01,0x03,0x11,
1335 0x01,0xff,0xc4,0x00,0x15,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1336 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xff,0xc4,0x00,0x14,0x10,0x01,0x00,0x00,
1337 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xc4,
1338 0x00,0x14,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1339 0x00,0x00,0x00,0x00,0xff,0xc4,0x00,0x14,0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
1340 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xda,0x00,0x0c,0x03,0x01,
1341 0x00,0x02,0x11,0x03,0x11,0x00,0x3f,0x00,0xb2,0xc0,0x07,0xff,0xd9
1343 /* 1x1 pixel tiff */
1344 static const unsigned char tiffimage
[] = {
1345 0x49,0x49,0x2a,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0xfe,0x00,
1346 0x04,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x00,0x01,0x00,
1347 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x01,0x00,
1348 0x00,0x00,0x02,0x01,0x03,0x00,0x03,0x00,0x00,0x00,0xd2,0x00,0x00,0x00,0x03,0x01,
1349 0x03,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x01,0x03,0x00,0x01,0x00,
1350 0x00,0x00,0x02,0x00,0x00,0x00,0x0d,0x01,0x02,0x00,0x1b,0x00,0x00,0x00,0xd8,0x00,
1351 0x00,0x00,0x11,0x01,0x04,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x12,0x01,
1352 0x03,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x15,0x01,0x03,0x00,0x01,0x00,
1353 0x00,0x00,0x03,0x00,0x00,0x00,0x16,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x40,0x00,
1354 0x00,0x00,0x17,0x01,0x04,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x1a,0x01,
1355 0x05,0x00,0x01,0x00,0x00,0x00,0xf4,0x00,0x00,0x00,0x1b,0x01,0x05,0x00,0x01,0x00,
1356 0x00,0x00,0xfc,0x00,0x00,0x00,0x1c,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x01,0x00,
1357 0x00,0x00,0x28,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
1358 0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x2f,0x68,0x6f,0x6d,0x65,0x2f,0x6d,0x65,
1359 0x68,0x2f,0x44,0x65,0x73,0x6b,0x74,0x6f,0x70,0x2f,0x74,0x65,0x73,0x74,0x2e,0x74,
1360 0x69,0x66,0x00,0x00,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x48,
1363 /* 320x320 twip wmf */
1364 static const unsigned char wmfimage
[180] = {
1365 0xd7,0xcd,0xc6,0x9a,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x01,0x40,0x01,0xa0,0x05,
1366 0x00,0x00,0x00,0x00,0xb1,0x52,0x01,0x00,0x09,0x00,0x00,0x03,0x4f,0x00,0x00,0x00,
1367 0x0f,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x0b,0x02,0x00,0x00,
1368 0x00,0x00,0x05,0x00,0x00,0x00,0x0c,0x02,0x40,0x01,0x40,0x01,0x04,0x00,0x00,0x00,
1369 0x02,0x01,0x01,0x00,0x04,0x00,0x00,0x00,0x04,0x01,0x0d,0x00,0x08,0x00,0x00,0x00,
1370 0xfa,0x02,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
1371 0x2d,0x01,0x00,0x00,0x07,0x00,0x00,0x00,0xfc,0x02,0x01,0x00,0x00,0x00,0x00,0x00,
1372 0x00,0x00,0x04,0x00,0x00,0x00,0x2d,0x01,0x01,0x00,0x07,0x00,0x00,0x00,0xfc,0x02,
1373 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x2d,0x01,0x02,0x00,
1374 0x07,0x00,0x00,0x00,0x1b,0x04,0x40,0x01,0x40,0x01,0x00,0x00,0x00,0x00,0x04,0x00,
1375 0x00,0x00,0xf0,0x01,0x00,0x00,0x04,0x00,0x00,0x00,0xf0,0x01,0x01,0x00,0x03,0x00,
1378 static void test_getrawformat(void)
1380 test_bufferrawformat((void*)pngimage
, sizeof(pngimage
), &ImageFormatPNG
, __LINE__
, FALSE
);
1381 test_bufferrawformat((void*)gifimage
, sizeof(gifimage
), &ImageFormatGIF
, __LINE__
, FALSE
);
1382 test_bufferrawformat((void*)bmpimage
, sizeof(bmpimage
), &ImageFormatBMP
, __LINE__
, FALSE
);
1383 test_bufferrawformat((void*)jpgimage
, sizeof(jpgimage
), &ImageFormatJPEG
, __LINE__
, FALSE
);
1384 test_bufferrawformat((void*)tiffimage
, sizeof(tiffimage
), &ImageFormatTIFF
, __LINE__
, FALSE
);
1385 test_bufferrawformat((void*)wmfimage
, sizeof(wmfimage
), &ImageFormatWMF
, __LINE__
, FALSE
);
1388 static void test_loadwmf(void)
1399 MetafileHeader header
;
1401 hglob
= GlobalAlloc (0, sizeof(wmfimage
));
1402 data
= GlobalLock (hglob
);
1403 memcpy(data
, wmfimage
, sizeof(wmfimage
));
1404 GlobalUnlock(hglob
); data
= NULL
;
1406 hres
= CreateStreamOnHGlobal(hglob
, TRUE
, &stream
);
1407 ok(hres
== S_OK
, "Failed to create a stream\n");
1408 if(hres
!= S_OK
) return;
1410 stat
= GdipLoadImageFromStream(stream
, &img
);
1411 ok(stat
== Ok
, "Failed to create a Bitmap\n");
1413 IStream_Release(stream
);
1417 IStream_Release(stream
);
1419 stat
= GdipGetImageBounds(img
, &bounds
, &unit
);
1421 todo_wine
expect(UnitPixel
, unit
);
1422 expectf(0.0, bounds
.X
);
1423 expectf(0.0, bounds
.Y
);
1424 todo_wine
expectf(320.0, bounds
.Width
);
1425 todo_wine
expectf(320.0, bounds
.Height
);
1427 stat
= GdipGetImageHorizontalResolution(img
, &res
);
1429 todo_wine
expectf(1440.0, res
);
1431 stat
= GdipGetImageVerticalResolution(img
, &res
);
1433 todo_wine
expectf(1440.0, res
);
1435 memset(&header
, 0, sizeof(header
));
1436 stat
= GdipGetMetafileHeaderFromMetafile((GpMetafile
*)img
, &header
);
1440 todo_wine
expect(MetafileTypeWmfPlaceable
, header
.Type
);
1441 todo_wine
expect(sizeof(wmfimage
)-sizeof(WmfPlaceableFileHeader
), header
.Size
);
1442 todo_wine
expect(0x300, header
.Version
);
1443 expect(0, header
.EmfPlusFlags
);
1444 todo_wine
expectf(1440.0, header
.DpiX
);
1445 todo_wine
expectf(1440.0, header
.DpiY
);
1446 expect(0, header
.X
);
1447 expect(0, header
.Y
);
1448 todo_wine
expect(320, header
.Width
);
1449 todo_wine
expect(320, header
.Height
);
1450 todo_wine
expect(1, U(header
).WmfHeader
.mtType
);
1451 expect(0, header
.EmfPlusHeaderSize
);
1452 expect(0, header
.LogicalDpiX
);
1453 expect(0, header
.LogicalDpiY
);
1456 GdipDisposeImage(img
);
1459 static void test_createfromwmf(void)
1467 MetafileHeader header
;
1469 hwmf
= SetMetaFileBitsEx(sizeof(wmfimage
)-sizeof(WmfPlaceableFileHeader
),
1470 wmfimage
+sizeof(WmfPlaceableFileHeader
));
1471 ok(hwmf
!= 0, "SetMetaFileBitsEx failed\n");
1473 stat
= GdipCreateMetafileFromWmf(hwmf
, TRUE
,
1474 (WmfPlaceableFileHeader
*)wmfimage
, (GpMetafile
**)&img
);
1477 stat
= GdipGetImageBounds(img
, &bounds
, &unit
);
1479 expect(UnitPixel
, unit
);
1480 expectf(0.0, bounds
.X
);
1481 expectf(0.0, bounds
.Y
);
1482 expectf(320.0, bounds
.Width
);
1483 expectf(320.0, bounds
.Height
);
1485 stat
= GdipGetImageHorizontalResolution(img
, &res
);
1487 expectf(1440.0, res
);
1489 stat
= GdipGetImageVerticalResolution(img
, &res
);
1491 expectf(1440.0, res
);
1493 memset(&header
, 0, sizeof(header
));
1494 stat
= GdipGetMetafileHeaderFromMetafile((GpMetafile
*)img
, &header
);
1498 todo_wine
expect(MetafileTypeWmfPlaceable
, header
.Type
);
1499 todo_wine
expect(sizeof(wmfimage
)-sizeof(WmfPlaceableFileHeader
), header
.Size
);
1500 todo_wine
expect(0x300, header
.Version
);
1501 expect(0, header
.EmfPlusFlags
);
1502 todo_wine
expectf(1440.0, header
.DpiX
);
1503 todo_wine
expectf(1440.0, header
.DpiY
);
1504 expect(0, header
.X
);
1505 expect(0, header
.Y
);
1506 todo_wine
expect(320, header
.Width
);
1507 todo_wine
expect(320, header
.Height
);
1508 todo_wine
expect(1, U(header
).WmfHeader
.mtType
);
1509 expect(0, header
.EmfPlusHeaderSize
);
1510 expect(0, header
.LogicalDpiX
);
1511 expect(0, header
.LogicalDpiY
);
1514 GdipDisposeImage(img
);
1517 static void test_resolution(void)
1521 GpGraphics
*graphics
;
1524 int screenxres
, screenyres
;
1527 stat
= GdipCreateBitmapFromScan0(1, 1, 32, PixelFormat24bppRGB
, NULL
, &bitmap
);
1530 /* test invalid values */
1531 stat
= GdipGetImageHorizontalResolution(NULL
, &res
);
1532 expect(InvalidParameter
, stat
);
1534 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, NULL
);
1535 expect(InvalidParameter
, stat
);
1537 stat
= GdipGetImageVerticalResolution(NULL
, &res
);
1538 expect(InvalidParameter
, stat
);
1540 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, NULL
);
1541 expect(InvalidParameter
, stat
);
1543 stat
= GdipBitmapSetResolution(NULL
, 96.0, 96.0);
1544 expect(InvalidParameter
, stat
);
1546 stat
= GdipBitmapSetResolution(bitmap
, 0.0, 0.0);
1547 expect(InvalidParameter
, stat
);
1549 /* defaults to screen resolution */
1550 screendc
= GetDC(0);
1552 screenxres
= GetDeviceCaps(screendc
, LOGPIXELSX
);
1553 screenyres
= GetDeviceCaps(screendc
, LOGPIXELSY
);
1555 ReleaseDC(0, screendc
);
1557 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &res
);
1559 expectf((REAL
)screenxres
, res
);
1561 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &res
);
1563 expectf((REAL
)screenyres
, res
);
1565 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
1567 stat
= GdipGetDpiX(graphics
, &res
);
1569 expectf((REAL
)screenxres
, res
);
1570 stat
= GdipGetDpiY(graphics
, &res
);
1572 expectf((REAL
)screenyres
, res
);
1574 /* test changing the resolution */
1575 stat
= GdipBitmapSetResolution(bitmap
, screenxres
*2.0, screenyres
*3.0);
1578 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &res
);
1580 expectf(screenxres
*2.0, res
);
1582 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &res
);
1584 expectf(screenyres
*3.0, res
);
1586 stat
= GdipGetDpiX(graphics
, &res
);
1588 expectf((REAL
)screenxres
, res
);
1589 stat
= GdipGetDpiY(graphics
, &res
);
1591 expectf((REAL
)screenyres
, res
);
1593 stat
= GdipDeleteGraphics(graphics
);
1596 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
1598 stat
= GdipGetDpiX(graphics
, &res
);
1600 expectf(screenxres
*2.0, res
);
1601 stat
= GdipGetDpiY(graphics
, &res
);
1603 expectf(screenyres
*3.0, res
);
1604 stat
= GdipDeleteGraphics(graphics
);
1607 stat
= GdipDisposeImage((GpImage
*)bitmap
);
1611 static void test_createhbitmap(void)
1615 HBITMAP hbitmap
, oldhbitmap
;
1622 memset(bits
, 0x68, 640);
1625 stat
= GdipCreateBitmapFromScan0(10, 20, 32, PixelFormat24bppRGB
, bits
, &bitmap
);
1628 /* test NULL values */
1629 stat
= GdipCreateHBITMAPFromBitmap(NULL
, &hbitmap
, 0);
1630 expect(InvalidParameter
, stat
);
1632 stat
= GdipCreateHBITMAPFromBitmap(bitmap
, NULL
, 0);
1633 expect(InvalidParameter
, stat
);
1635 /* create HBITMAP */
1636 stat
= GdipCreateHBITMAPFromBitmap(bitmap
, &hbitmap
, 0);
1641 ret
= GetObjectA(hbitmap
, sizeof(BITMAP
), &bm
);
1642 expect(sizeof(BITMAP
), ret
);
1644 expect(0, bm
.bmType
);
1645 expect(10, bm
.bmWidth
);
1646 expect(20, bm
.bmHeight
);
1647 expect(40, bm
.bmWidthBytes
);
1648 expect(1, bm
.bmPlanes
);
1649 expect(32, bm
.bmBitsPixel
);
1650 ok(bm
.bmBits
!= NULL
, "got DDB, expected DIB\n");
1654 DWORD val
= *(DWORD
*)bm
.bmBits
;
1655 ok(val
== 0xff686868, "got %x, expected 0xff686868\n", val
);
1658 hdc
= CreateCompatibleDC(NULL
);
1660 oldhbitmap
= SelectObject(hdc
, hbitmap
);
1661 pixel
= GetPixel(hdc
, 5, 5);
1662 SelectObject(hdc
, oldhbitmap
);
1666 expect(0x686868, pixel
);
1668 DeleteObject(hbitmap
);
1671 stat
= GdipDisposeImage((GpImage
*)bitmap
);
1674 /* create alpha Bitmap */
1675 stat
= GdipCreateBitmapFromScan0(8, 20, 32, PixelFormat32bppARGB
, bits
, &bitmap
);
1678 /* create HBITMAP */
1679 stat
= GdipCreateHBITMAPFromBitmap(bitmap
, &hbitmap
, 0);
1684 ret
= GetObjectA(hbitmap
, sizeof(BITMAP
), &bm
);
1685 expect(sizeof(BITMAP
), ret
);
1687 expect(0, bm
.bmType
);
1688 expect(8, bm
.bmWidth
);
1689 expect(20, bm
.bmHeight
);
1690 expect(32, bm
.bmWidthBytes
);
1691 expect(1, bm
.bmPlanes
);
1692 expect(32, bm
.bmBitsPixel
);
1693 ok(bm
.bmBits
!= NULL
, "got DDB, expected DIB\n");
1697 DWORD val
= *(DWORD
*)bm
.bmBits
;
1698 ok(val
== 0x682a2a2a, "got %x, expected 0x682a2a2a\n", val
);
1701 hdc
= CreateCompatibleDC(NULL
);
1703 oldhbitmap
= SelectObject(hdc
, hbitmap
);
1704 pixel
= GetPixel(hdc
, 5, 5);
1705 SelectObject(hdc
, oldhbitmap
);
1709 expect(0x2a2a2a, pixel
);
1711 DeleteObject(hbitmap
);
1714 stat
= GdipDisposeImage((GpImage
*)bitmap
);
1718 static void test_getthumbnail(void)
1721 GpImage
*bitmap1
, *bitmap2
;
1724 stat
= GdipGetImageThumbnail(NULL
, 0, 0, &bitmap2
, NULL
, NULL
);
1725 expect(InvalidParameter
, stat
);
1727 stat
= GdipCreateBitmapFromScan0(128, 128, 0, PixelFormat32bppRGB
, NULL
, (GpBitmap
**)&bitmap1
);
1730 stat
= GdipGetImageThumbnail(bitmap1
, 0, 0, NULL
, NULL
, NULL
);
1731 expect(InvalidParameter
, stat
);
1733 stat
= GdipGetImageThumbnail(bitmap1
, 0, 0, &bitmap2
, NULL
, NULL
);
1738 stat
= GdipGetImageWidth(bitmap2
, &width
);
1742 stat
= GdipGetImageHeight(bitmap2
, &height
);
1744 expect(120, height
);
1746 GdipDisposeImage(bitmap2
);
1749 GdipDisposeImage(bitmap1
);
1752 stat
= GdipCreateBitmapFromScan0(64, 128, 0, PixelFormat32bppRGB
, NULL
, (GpBitmap
**)&bitmap1
);
1755 stat
= GdipGetImageThumbnail(bitmap1
, 32, 32, &bitmap2
, NULL
, NULL
);
1760 stat
= GdipGetImageWidth(bitmap2
, &width
);
1764 stat
= GdipGetImageHeight(bitmap2
, &height
);
1768 GdipDisposeImage(bitmap2
);
1771 stat
= GdipGetImageThumbnail(bitmap1
, 0, 0, &bitmap2
, NULL
, NULL
);
1776 stat
= GdipGetImageWidth(bitmap2
, &width
);
1780 stat
= GdipGetImageHeight(bitmap2
, &height
);
1782 expect(120, height
);
1784 GdipDisposeImage(bitmap2
);
1787 GdipDisposeImage(bitmap1
);
1790 static void test_getsetpixel(void)
1795 BYTE bits
[16] = {0x00,0x00,0x00,0x00, 0x00,0xff,0xff,0x00,
1796 0xff,0x00,0x00,0x00, 0xff,0xff,0xff,0x00};
1798 stat
= GdipCreateBitmapFromScan0(2, 2, 8, PixelFormat32bppRGB
, bits
, &bitmap
);
1801 /* null parameters */
1802 stat
= GdipBitmapGetPixel(NULL
, 1, 1, &color
);
1803 expect(InvalidParameter
, stat
);
1805 stat
= GdipBitmapGetPixel(bitmap
, 1, 1, NULL
);
1806 expect(InvalidParameter
, stat
);
1808 stat
= GdipBitmapSetPixel(NULL
, 1, 1, 0);
1809 expect(InvalidParameter
, stat
);
1812 stat
= GdipBitmapGetPixel(bitmap
, -1, 1, &color
);
1813 expect(InvalidParameter
, stat
);
1815 stat
= GdipBitmapSetPixel(bitmap
, -1, 1, 0);
1816 expect(InvalidParameter
, stat
);
1818 stat
= GdipBitmapGetPixel(bitmap
, 1, -1, &color
);
1819 ok(stat
== InvalidParameter
||
1820 broken(stat
== Ok
), /* Older gdiplus */
1821 "Expected InvalidParameter, got %.8x\n", stat
);
1823 if (0) /* crashes some gdiplus implementations */
1825 stat
= GdipBitmapSetPixel(bitmap
, 1, -1, 0);
1826 ok(stat
== InvalidParameter
||
1827 broken(stat
== Ok
), /* Older gdiplus */
1828 "Expected InvalidParameter, got %.8x\n", stat
);
1831 stat
= GdipBitmapGetPixel(bitmap
, 2, 1, &color
);
1832 expect(InvalidParameter
, stat
);
1834 stat
= GdipBitmapSetPixel(bitmap
, 2, 1, 0);
1835 expect(InvalidParameter
, stat
);
1837 stat
= GdipBitmapGetPixel(bitmap
, 1, 2, &color
);
1838 expect(InvalidParameter
, stat
);
1840 stat
= GdipBitmapSetPixel(bitmap
, 1, 2, 0);
1841 expect(InvalidParameter
, stat
);
1844 stat
= GdipBitmapGetPixel(bitmap
, 1, 1, &color
);
1846 expect(0xffffffff, color
);
1848 stat
= GdipBitmapGetPixel(bitmap
, 0, 1, &color
);
1850 expect(0xff0000ff, color
);
1852 stat
= GdipBitmapSetPixel(bitmap
, 1, 1, 0xff676869);
1855 stat
= GdipBitmapSetPixel(bitmap
, 0, 0, 0xff474849);
1858 stat
= GdipBitmapGetPixel(bitmap
, 1, 1, &color
);
1860 expect(0xff676869, color
);
1862 stat
= GdipBitmapGetPixel(bitmap
, 0, 0, &color
);
1864 expect(0xff474849, color
);
1866 stat
= GdipDisposeImage((GpImage
*)bitmap
);
1870 static void check_halftone_palette(ColorPalette
*palette
)
1872 static const BYTE halftone_values
[6]={0x00,0x33,0x66,0x99,0xcc,0xff};
1875 for (i
=0; i
<palette
->Count
; i
++)
1877 ARGB expected
=0xff000000;
1880 if (i
&1) expected
|= 0x800000;
1881 if (i
&2) expected
|= 0x8000;
1882 if (i
&4) expected
|= 0x80;
1886 expected
= 0xffc0c0c0;
1890 if (i
&1) expected
|= 0xff0000;
1891 if (i
&2) expected
|= 0xff00;
1892 if (i
&4) expected
|= 0xff;
1896 expected
= 0x00000000;
1900 expected
|= halftone_values
[(i
-40)%6];
1901 expected
|= halftone_values
[((i
-40)/6)%6] << 8;
1902 expected
|= halftone_values
[((i
-40)/36)%6] << 16;
1904 ok(expected
== palette
->Entries
[i
], "Expected %.8x, got %.8x, i=%u/%u\n",
1905 expected
, palette
->Entries
[i
], i
, palette
->Count
);
1909 static void test_palette(void)
1915 ColorPalette
*palette
=(ColorPalette
*)buffer
;
1916 ARGB
*entries
= palette
->Entries
;
1919 /* test initial palette from non-indexed bitmap */
1920 stat
= GdipCreateBitmapFromScan0(2, 2, 8, PixelFormat32bppRGB
, NULL
, &bitmap
);
1923 stat
= GdipGetImagePaletteSize((GpImage
*)bitmap
, &size
);
1925 expect(sizeof(UINT
)*2+sizeof(ARGB
), size
);
1927 stat
= GdipGetImagePalette((GpImage
*)bitmap
, palette
, size
);
1929 expect(0, palette
->Count
);
1931 /* test setting palette on not-indexed bitmap */
1934 stat
= GdipSetImagePalette((GpImage
*)bitmap
, palette
);
1937 stat
= GdipGetImagePaletteSize((GpImage
*)bitmap
, &size
);
1939 expect(sizeof(UINT
)*2+sizeof(ARGB
)*3, size
);
1941 stat
= GdipGetImagePalette((GpImage
*)bitmap
, palette
, size
);
1943 expect(3, palette
->Count
);
1945 GdipDisposeImage((GpImage
*)bitmap
);
1947 /* test initial palette on 1-bit bitmap */
1948 stat
= GdipCreateBitmapFromScan0(2, 2, 4, PixelFormat1bppIndexed
, NULL
, &bitmap
);
1951 stat
= GdipGetImagePaletteSize((GpImage
*)bitmap
, &size
);
1953 expect(sizeof(UINT
)*2+sizeof(ARGB
)*2, size
);
1955 stat
= GdipGetImagePalette((GpImage
*)bitmap
, palette
, size
);
1957 expect(PaletteFlagsGrayScale
, palette
->Flags
);
1958 expect(2, palette
->Count
);
1960 expect(0xff000000, entries
[0]);
1961 expect(0xffffffff, entries
[1]);
1963 /* test getting/setting pixels */
1964 stat
= GdipBitmapGetPixel(bitmap
, 0, 0, &color
);
1966 expect(0xff000000, color
);
1968 stat
= GdipBitmapSetPixel(bitmap
, 0, 1, 0xffffffff);
1970 broken(stat
== InvalidParameter
) /* pre-win7 */, "stat=%.8x\n", stat
);
1974 stat
= GdipBitmapGetPixel(bitmap
, 0, 1, &color
);
1976 expect(0xffffffff, color
);
1979 GdipDisposeImage((GpImage
*)bitmap
);
1981 /* test initial palette on 4-bit bitmap */
1982 stat
= GdipCreateBitmapFromScan0(2, 2, 4, PixelFormat4bppIndexed
, NULL
, &bitmap
);
1985 stat
= GdipGetImagePaletteSize((GpImage
*)bitmap
, &size
);
1987 expect(sizeof(UINT
)*2+sizeof(ARGB
)*16, size
);
1989 stat
= GdipGetImagePalette((GpImage
*)bitmap
, palette
, size
);
1991 expect(0, palette
->Flags
);
1992 expect(16, palette
->Count
);
1994 check_halftone_palette(palette
);
1996 /* test getting/setting pixels */
1997 stat
= GdipBitmapGetPixel(bitmap
, 0, 0, &color
);
1999 expect(0xff000000, color
);
2001 stat
= GdipBitmapSetPixel(bitmap
, 0, 1, 0xffff00ff);
2003 broken(stat
== InvalidParameter
) /* pre-win7 */, "stat=%.8x\n", stat
);
2007 stat
= GdipBitmapGetPixel(bitmap
, 0, 1, &color
);
2009 expect(0xffff00ff, color
);
2012 GdipDisposeImage((GpImage
*)bitmap
);
2014 /* test initial palette on 8-bit bitmap */
2015 stat
= GdipCreateBitmapFromScan0(2, 2, 8, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2018 stat
= GdipGetImagePaletteSize((GpImage
*)bitmap
, &size
);
2020 expect(sizeof(UINT
)*2+sizeof(ARGB
)*256, size
);
2022 stat
= GdipGetImagePalette((GpImage
*)bitmap
, palette
, size
);
2024 expect(PaletteFlagsHalftone
, palette
->Flags
);
2025 expect(256, palette
->Count
);
2027 check_halftone_palette(palette
);
2029 /* test getting/setting pixels */
2030 stat
= GdipBitmapGetPixel(bitmap
, 0, 0, &color
);
2032 expect(0xff000000, color
);
2034 stat
= GdipBitmapSetPixel(bitmap
, 0, 1, 0xffcccccc);
2036 broken(stat
== InvalidParameter
) /* pre-win7 */, "stat=%.8x\n", stat
);
2040 stat
= GdipBitmapGetPixel(bitmap
, 0, 1, &color
);
2042 expect(0xffcccccc, color
);
2045 /* test setting/getting a different palette */
2046 entries
[1] = 0xffcccccc;
2048 stat
= GdipSetImagePalette((GpImage
*)bitmap
, palette
);
2053 stat
= GdipGetImagePaletteSize((GpImage
*)bitmap
, &size
);
2055 expect(sizeof(UINT
)*2+sizeof(ARGB
)*256, size
);
2057 stat
= GdipGetImagePalette((GpImage
*)bitmap
, palette
, size
);
2059 expect(PaletteFlagsHalftone
, palette
->Flags
);
2060 expect(256, palette
->Count
);
2061 expect(0xffcccccc, entries
[1]);
2063 /* test count < 256 */
2064 palette
->Flags
= 12345;
2067 stat
= GdipSetImagePalette((GpImage
*)bitmap
, palette
);
2071 entries
[3] = 0xdeadbeef;
2073 stat
= GdipGetImagePaletteSize((GpImage
*)bitmap
, &size
);
2075 expect(sizeof(UINT
)*2+sizeof(ARGB
)*3, size
);
2077 stat
= GdipGetImagePalette((GpImage
*)bitmap
, palette
, size
);
2079 expect(12345, palette
->Flags
);
2080 expect(3, palette
->Count
);
2081 expect(0xffcccccc, entries
[1]);
2082 expect(0xdeadbeef, entries
[3]);
2084 /* test count > 256 */
2085 palette
->Count
= 257;
2087 stat
= GdipSetImagePalette((GpImage
*)bitmap
, palette
);
2088 ok(stat
== InvalidParameter
||
2089 broken(stat
== Ok
), /* Old gdiplus behavior */
2090 "Expected %.8x, got %.8x\n", InvalidParameter
, stat
);
2092 GdipDisposeImage((GpImage
*)bitmap
);
2095 static void test_colormatrix(void)
2098 ColorMatrix colormatrix
, graymatrix
;
2099 GpImageAttributes
*imageattr
;
2100 const ColorMatrix identity
= {{
2101 {1.0,0.0,0.0,0.0,0.0},
2102 {0.0,1.0,0.0,0.0,0.0},
2103 {0.0,0.0,1.0,0.0,0.0},
2104 {0.0,0.0,0.0,1.0,0.0},
2105 {0.0,0.0,0.0,0.0,1.0}}};
2106 const ColorMatrix double_red
= {{
2107 {2.0,0.0,0.0,0.0,0.0},
2108 {0.0,1.0,0.0,0.0,0.0},
2109 {0.0,0.0,1.0,0.0,0.0},
2110 {0.0,0.0,0.0,1.0,0.0},
2111 {0.0,0.0,0.0,0.0,1.0}}};
2112 const ColorMatrix asymmetric
= {{
2113 {0.0,1.0,0.0,0.0,0.0},
2114 {0.0,0.0,1.0,0.0,0.0},
2115 {0.0,0.0,0.0,1.0,0.0},
2116 {1.0,0.0,0.0,0.0,0.0},
2117 {0.0,0.0,0.0,0.0,1.0}}};
2118 GpBitmap
*bitmap1
, *bitmap2
;
2119 GpGraphics
*graphics
;
2122 colormatrix
= identity
;
2123 graymatrix
= identity
;
2125 stat
= GdipSetImageAttributesColorMatrix(NULL
, ColorAdjustTypeDefault
,
2126 TRUE
, &colormatrix
, &graymatrix
, ColorMatrixFlagsDefault
);
2127 expect(InvalidParameter
, stat
);
2129 stat
= GdipCreateImageAttributes(&imageattr
);
2132 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeDefault
,
2133 TRUE
, &colormatrix
, NULL
, ColorMatrixFlagsDefault
);
2136 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeDefault
,
2137 TRUE
, NULL
, NULL
, ColorMatrixFlagsDefault
);
2138 expect(InvalidParameter
, stat
);
2140 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeDefault
,
2141 TRUE
, &colormatrix
, &graymatrix
, ColorMatrixFlagsDefault
);
2144 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeDefault
,
2145 TRUE
, &colormatrix
, NULL
, ColorMatrixFlagsSkipGrays
);
2148 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeDefault
,
2149 TRUE
, &colormatrix
, NULL
, ColorMatrixFlagsAltGray
);
2150 expect(InvalidParameter
, stat
);
2152 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeDefault
,
2153 TRUE
, &colormatrix
, &graymatrix
, ColorMatrixFlagsAltGray
);
2156 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeDefault
,
2157 TRUE
, &colormatrix
, &graymatrix
, 3);
2158 expect(InvalidParameter
, stat
);
2160 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeCount
,
2161 TRUE
, &colormatrix
, &graymatrix
, ColorMatrixFlagsDefault
);
2162 expect(InvalidParameter
, stat
);
2164 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeAny
,
2165 TRUE
, &colormatrix
, &graymatrix
, ColorMatrixFlagsDefault
);
2166 expect(InvalidParameter
, stat
);
2168 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeDefault
,
2169 FALSE
, NULL
, NULL
, ColorMatrixFlagsDefault
);
2172 /* Drawing a bitmap transforms the colors */
2173 colormatrix
= double_red
;
2174 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeDefault
,
2175 TRUE
, &colormatrix
, NULL
, ColorMatrixFlagsDefault
);
2178 stat
= GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppARGB
, NULL
, &bitmap1
);
2181 stat
= GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppARGB
, NULL
, &bitmap2
);
2184 stat
= GdipBitmapSetPixel(bitmap1
, 0, 0, 0xff40ccee);
2187 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap2
, &graphics
);
2190 stat
= GdipDrawImageRectRectI(graphics
, (GpImage
*)bitmap1
, 0,0,1,1, 0,0,1,1,
2191 UnitPixel
, imageattr
, NULL
, NULL
);
2194 stat
= GdipBitmapGetPixel(bitmap2
, 0, 0, &color
);
2196 expect(0xff80ccee, color
);
2198 colormatrix
= asymmetric
;
2199 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeDefault
,
2200 TRUE
, &colormatrix
, NULL
, ColorMatrixFlagsDefault
);
2203 stat
= GdipBitmapSetPixel(bitmap2
, 0, 0, 0);
2206 stat
= GdipDrawImageRectRectI(graphics
, (GpImage
*)bitmap1
, 0,0,1,1, 0,0,1,1,
2207 UnitPixel
, imageattr
, NULL
, NULL
);
2210 stat
= GdipBitmapGetPixel(bitmap2
, 0, 0, &color
);
2212 ok(color_match(0xeeff40cc, color
, 3), "expected 0xeeff40cc, got 0x%08x\n", color
);
2214 GdipDeleteGraphics(graphics
);
2215 GdipDisposeImage((GpImage
*)bitmap1
);
2216 GdipDisposeImage((GpImage
*)bitmap2
);
2217 GdipDisposeImageAttributes(imageattr
);
2220 static void test_gamma(void)
2223 GpImageAttributes
*imageattr
;
2224 GpBitmap
*bitmap1
, *bitmap2
;
2225 GpGraphics
*graphics
;
2228 stat
= GdipSetImageAttributesGamma(NULL
, ColorAdjustTypeDefault
, TRUE
, 1.0);
2229 expect(InvalidParameter
, stat
);
2231 stat
= GdipCreateImageAttributes(&imageattr
);
2234 stat
= GdipSetImageAttributesGamma(imageattr
, ColorAdjustTypeDefault
, TRUE
, 1.0);
2237 stat
= GdipSetImageAttributesGamma(imageattr
, ColorAdjustTypeAny
, TRUE
, 1.0);
2238 expect(InvalidParameter
, stat
);
2240 stat
= GdipSetImageAttributesGamma(imageattr
, ColorAdjustTypeDefault
, TRUE
, -1.0);
2241 expect(InvalidParameter
, stat
);
2243 stat
= GdipSetImageAttributesGamma(imageattr
, ColorAdjustTypeDefault
, TRUE
, 0.0);
2244 expect(InvalidParameter
, stat
);
2246 stat
= GdipSetImageAttributesGamma(imageattr
, ColorAdjustTypeDefault
, TRUE
, 0.5);
2249 stat
= GdipSetImageAttributesGamma(imageattr
, ColorAdjustTypeDefault
, FALSE
, 0.0);
2252 /* Drawing a bitmap transforms the colors */
2253 stat
= GdipSetImageAttributesGamma(imageattr
, ColorAdjustTypeDefault
, TRUE
, 3.0);
2256 stat
= GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB
, NULL
, &bitmap1
);
2259 stat
= GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB
, NULL
, &bitmap2
);
2262 stat
= GdipBitmapSetPixel(bitmap1
, 0, 0, 0xff80ffff);
2265 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap2
, &graphics
);
2268 stat
= GdipDrawImageRectRectI(graphics
, (GpImage
*)bitmap1
, 0,0,1,1, 0,0,1,1,
2269 UnitPixel
, imageattr
, NULL
, NULL
);
2272 stat
= GdipBitmapGetPixel(bitmap2
, 0, 0, &color
);
2274 ok(color_match(0xff20ffff, color
, 1), "Expected ff20ffff, got %.8x\n", color
);
2276 GdipDeleteGraphics(graphics
);
2277 GdipDisposeImage((GpImage
*)bitmap1
);
2278 GdipDisposeImage((GpImage
*)bitmap2
);
2279 GdipDisposeImageAttributes(imageattr
);
2282 /* 1x1 pixel gif, 2 frames; first frame is white, second is black */
2283 static const unsigned char gifanimation
[72] = {
2284 0x47,0x49,0x46,0x38,0x39,0x61,0x01,0x00,0x01,0x00,0xa1,0x00,0x00,0x00,0x00,0x00,
2285 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0xf9,0x04,0x00,0x0a,0x00,0xff,
2286 0x00,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x4c,0x01,0x00,
2287 0x21,0xf9,0x04,0x01,0x0a,0x00,0x01,0x00,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,
2288 0x00,0x00,0x02,0x02,0x44,0x01,0x00,0x3b
2291 static void test_multiframegif(void)
2303 /* Test frame functions with an animated GIF */
2304 hglob
= GlobalAlloc (0, sizeof(gifanimation
));
2305 data
= GlobalLock (hglob
);
2306 memcpy(data
, gifanimation
, sizeof(gifanimation
));
2307 GlobalUnlock(hglob
);
2309 hres
= CreateStreamOnHGlobal(hglob
, TRUE
, &stream
);
2310 ok(hres
== S_OK
, "Failed to create a stream\n");
2311 if(hres
!= S_OK
) return;
2313 stat
= GdipCreateBitmapFromStream(stream
, &bmp
);
2314 ok(stat
== Ok
, "Failed to create a Bitmap\n");
2316 IStream_Release(stream
);
2320 /* Bitmap starts at frame 0 */
2322 stat
= GdipBitmapGetPixel(bmp
, 0, 0, &color
);
2324 expect(0xffffffff, color
);
2326 /* Check that we get correct metadata */
2327 stat
= GdipImageGetFrameDimensionsCount((GpImage
*)bmp
,&count
);
2331 stat
= GdipImageGetFrameDimensionsList((GpImage
*)bmp
, &dimension
, 1);
2333 expect_guid(&FrameDimensionTime
, &dimension
, __LINE__
, FALSE
);
2336 stat
= GdipImageGetFrameCount((GpImage
*)bmp
, &dimension
, &count
);
2340 /* SelectActiveFrame overwrites our current data */
2341 stat
= GdipImageSelectActiveFrame((GpImage
*)bmp
, &dimension
, 1);
2345 GdipBitmapGetPixel(bmp
, 0, 0, &color
);
2347 expect(0xff000000, color
);
2349 stat
= GdipImageSelectActiveFrame((GpImage
*)bmp
, &dimension
, 0);
2353 GdipBitmapGetPixel(bmp
, 0, 0, &color
);
2355 expect(0xffffffff, color
);
2357 /* Write over the image data */
2358 stat
= GdipBitmapSetPixel(bmp
, 0, 0, 0xff000000);
2361 /* Switching to the same frame does not overwrite our changes */
2362 stat
= GdipImageSelectActiveFrame((GpImage
*)bmp
, &dimension
, 0);
2365 stat
= GdipBitmapGetPixel(bmp
, 0, 0, &color
);
2367 expect(0xff000000, color
);
2369 /* But switching to another frame and back does */
2370 stat
= GdipImageSelectActiveFrame((GpImage
*)bmp
, &dimension
, 1);
2373 stat
= GdipImageSelectActiveFrame((GpImage
*)bmp
, &dimension
, 0);
2376 stat
= GdipBitmapGetPixel(bmp
, 0, 0, &color
);
2378 expect(0xffffffff, color
);
2380 /* rotate/flip discards the information about other frames */
2381 stat
= GdipImageRotateFlip((GpImage
*)bmp
, Rotate90FlipNone
);
2385 stat
= GdipImageGetFrameCount((GpImage
*)bmp
, &dimension
, &count
);
2389 expect_rawformat(&ImageFormatMemoryBMP
, (GpImage
*)bmp
, __LINE__
, FALSE
);
2391 GdipDisposeImage((GpImage
*)bmp
);
2392 IStream_Release(stream
);
2394 /* Test with a non-animated gif */
2395 hglob
= GlobalAlloc (0, sizeof(gifimage
));
2396 data
= GlobalLock (hglob
);
2397 memcpy(data
, gifimage
, sizeof(gifimage
));
2398 GlobalUnlock(hglob
);
2400 hres
= CreateStreamOnHGlobal(hglob
, TRUE
, &stream
);
2401 ok(hres
== S_OK
, "Failed to create a stream\n");
2402 if(hres
!= S_OK
) return;
2404 stat
= GdipCreateBitmapFromStream(stream
, &bmp
);
2405 ok(stat
== Ok
, "Failed to create a Bitmap\n");
2407 IStream_Release(stream
);
2411 /* Check metadata */
2412 stat
= GdipImageGetFrameDimensionsCount((GpImage
*)bmp
,&count
);
2416 stat
= GdipImageGetFrameDimensionsList((GpImage
*)bmp
, &dimension
, 1);
2418 expect_guid(&FrameDimensionTime
, &dimension
, __LINE__
, FALSE
);
2421 stat
= GdipImageGetFrameCount((GpImage
*)bmp
, &dimension
, &count
);
2425 GdipDisposeImage((GpImage
*)bmp
);
2426 IStream_Release(stream
);
2429 static void test_rotateflip(void)
2434 static const BYTE orig_bits
[24] = {
2435 0,0,0xff, 0,0xff,0, 0xff,0,0, 23,23,23,
2436 0xff,0xff,0, 0xff,0,0xff, 0,0xff,0xff, 23,23,23};
2440 memcpy(bits
, orig_bits
, sizeof(bits
));
2441 stat
= GdipCreateBitmapFromScan0(3, 2, 12, PixelFormat24bppRGB
, bits
, (GpBitmap
**)&bitmap
);
2444 stat
= GdipImageRotateFlip(bitmap
, Rotate90FlipNone
);
2447 stat
= GdipGetImageWidth(bitmap
, &width
);
2449 stat
= GdipGetImageHeight(bitmap
, &height
);
2454 stat
= GdipBitmapGetPixel((GpBitmap
*)bitmap
, 0, 0, &color
);
2456 expect(0xff00ffff, color
);
2458 stat
= GdipBitmapGetPixel((GpBitmap
*)bitmap
, 1, 0, &color
);
2460 expect(0xffff0000, color
);
2462 stat
= GdipBitmapGetPixel((GpBitmap
*)bitmap
, 0, 2, &color
);
2464 expect(0xffffff00, color
);
2466 stat
= GdipBitmapGetPixel((GpBitmap
*)bitmap
, 1, 2, &color
);
2468 expect(0xff0000ff, color
);
2472 expect(0xff, bits
[2]);
2474 GdipDisposeImage(bitmap
);
2476 memcpy(bits
, orig_bits
, sizeof(bits
));
2477 stat
= GdipCreateBitmapFromScan0(3, 2, 12, PixelFormat24bppRGB
, bits
, (GpBitmap
**)&bitmap
);
2480 stat
= GdipImageRotateFlip(bitmap
, RotateNoneFlipX
);
2483 stat
= GdipGetImageWidth(bitmap
, &width
);
2485 stat
= GdipGetImageHeight(bitmap
, &height
);
2490 stat
= GdipBitmapGetPixel((GpBitmap
*)bitmap
, 0, 0, &color
);
2492 expect(0xff0000ff, color
);
2494 stat
= GdipBitmapGetPixel((GpBitmap
*)bitmap
, 2, 0, &color
);
2496 expect(0xffff0000, color
);
2498 stat
= GdipBitmapGetPixel((GpBitmap
*)bitmap
, 0, 1, &color
);
2500 expect(0xffffff00, color
);
2502 stat
= GdipBitmapGetPixel((GpBitmap
*)bitmap
, 2, 1, &color
);
2504 expect(0xff00ffff, color
);
2508 expect(0xff, bits
[2]);
2510 GdipDisposeImage(bitmap
);
2512 memcpy(bits
, orig_bits
, sizeof(bits
));
2513 stat
= GdipCreateBitmapFromScan0(3, 2, 12, PixelFormat24bppRGB
, bits
, (GpBitmap
**)&bitmap
);
2516 stat
= GdipImageRotateFlip(bitmap
, RotateNoneFlipY
);
2519 stat
= GdipGetImageWidth(bitmap
, &width
);
2521 stat
= GdipGetImageHeight(bitmap
, &height
);
2526 stat
= GdipBitmapGetPixel((GpBitmap
*)bitmap
, 0, 0, &color
);
2528 expect(0xff00ffff, color
);
2530 stat
= GdipBitmapGetPixel((GpBitmap
*)bitmap
, 2, 0, &color
);
2532 expect(0xffffff00, color
);
2534 stat
= GdipBitmapGetPixel((GpBitmap
*)bitmap
, 0, 1, &color
);
2536 expect(0xffff0000, color
);
2538 stat
= GdipBitmapGetPixel((GpBitmap
*)bitmap
, 2, 1, &color
);
2540 expect(0xff0000ff, color
);
2544 expect(0xff, bits
[2]);
2546 GdipDisposeImage(bitmap
);
2549 static void test_remaptable(void)
2552 GpImageAttributes
*imageattr
;
2553 GpBitmap
*bitmap1
, *bitmap2
;
2554 GpGraphics
*graphics
;
2558 map
= GdipAlloc(sizeof(ColorMap
));
2560 map
->oldColor
.Argb
= 0xff00ff00;
2561 map
->newColor
.Argb
= 0xffff00ff;
2563 stat
= GdipSetImageAttributesRemapTable(NULL
, ColorAdjustTypeDefault
, TRUE
, 1, map
);
2564 expect(InvalidParameter
, stat
);
2566 stat
= GdipCreateImageAttributes(&imageattr
);
2569 stat
= GdipSetImageAttributesRemapTable(imageattr
, ColorAdjustTypeDefault
, TRUE
, 1, NULL
);
2570 expect(InvalidParameter
, stat
);
2572 stat
= GdipSetImageAttributesRemapTable(imageattr
, ColorAdjustTypeCount
, TRUE
, 1, map
);
2573 expect(InvalidParameter
, stat
);
2575 stat
= GdipSetImageAttributesRemapTable(imageattr
, ColorAdjustTypeAny
, TRUE
, 1, map
);
2576 expect(InvalidParameter
, stat
);
2578 stat
= GdipSetImageAttributesRemapTable(imageattr
, ColorAdjustTypeDefault
, TRUE
, 0, map
);
2579 expect(InvalidParameter
, stat
);
2581 stat
= GdipSetImageAttributesRemapTable(imageattr
, ColorAdjustTypeDefault
, FALSE
, 0, NULL
);
2584 stat
= GdipSetImageAttributesRemapTable(imageattr
, ColorAdjustTypeDefault
, TRUE
, 1, map
);
2587 stat
= GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB
, NULL
, &bitmap1
);
2590 stat
= GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB
, NULL
, &bitmap2
);
2593 stat
= GdipBitmapSetPixel(bitmap1
, 0, 0, 0xff00ff00);
2596 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap2
, &graphics
);
2599 stat
= GdipDrawImageRectRectI(graphics
, (GpImage
*)bitmap1
, 0,0,1,1, 0,0,1,1,
2600 UnitPixel
, imageattr
, NULL
, NULL
);
2603 stat
= GdipBitmapGetPixel(bitmap2
, 0, 0, &color
);
2605 ok(color_match(0xffff00ff, color
, 1), "Expected ffff00ff, got %.8x\n", color
);
2607 GdipDeleteGraphics(graphics
);
2608 GdipDisposeImage((GpImage
*)bitmap1
);
2609 GdipDisposeImage((GpImage
*)bitmap2
);
2610 GdipDisposeImageAttributes(imageattr
);
2614 static void test_colorkey(void)
2617 GpImageAttributes
*imageattr
;
2618 GpBitmap
*bitmap1
, *bitmap2
;
2619 GpGraphics
*graphics
;
2622 stat
= GdipSetImageAttributesColorKeys(NULL
, ColorAdjustTypeDefault
, TRUE
, 0xff405060, 0xff708090);
2623 expect(InvalidParameter
, stat
);
2625 stat
= GdipCreateImageAttributes(&imageattr
);
2628 stat
= GdipSetImageAttributesColorKeys(imageattr
, ColorAdjustTypeCount
, TRUE
, 0xff405060, 0xff708090);
2629 expect(InvalidParameter
, stat
);
2631 stat
= GdipSetImageAttributesColorKeys(imageattr
, ColorAdjustTypeAny
, TRUE
, 0xff405060, 0xff708090);
2632 expect(InvalidParameter
, stat
);
2634 stat
= GdipSetImageAttributesColorKeys(imageattr
, ColorAdjustTypeDefault
, TRUE
, 0xff405060, 0xff708090);
2637 stat
= GdipCreateBitmapFromScan0(2, 2, 0, PixelFormat32bppARGB
, NULL
, &bitmap1
);
2640 stat
= GdipCreateBitmapFromScan0(2, 2, 0, PixelFormat32bppARGB
, NULL
, &bitmap2
);
2643 stat
= GdipBitmapSetPixel(bitmap1
, 0, 0, 0x20405060);
2646 stat
= GdipBitmapSetPixel(bitmap1
, 0, 1, 0x40506070);
2649 stat
= GdipBitmapSetPixel(bitmap1
, 1, 0, 0x60708090);
2652 stat
= GdipBitmapSetPixel(bitmap1
, 1, 1, 0xffffffff);
2655 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap2
, &graphics
);
2658 stat
= GdipDrawImageRectRectI(graphics
, (GpImage
*)bitmap1
, 0,0,2,2, 0,0,2,2,
2659 UnitPixel
, imageattr
, NULL
, NULL
);
2662 stat
= GdipBitmapGetPixel(bitmap2
, 0, 0, &color
);
2664 ok(color_match(0x00000000, color
, 1), "Expected ffff00ff, got %.8x\n", color
);
2666 stat
= GdipBitmapGetPixel(bitmap2
, 0, 1, &color
);
2668 ok(color_match(0x00000000, color
, 1), "Expected ffff00ff, got %.8x\n", color
);
2670 stat
= GdipBitmapGetPixel(bitmap2
, 1, 0, &color
);
2672 ok(color_match(0x00000000, color
, 1), "Expected ffff00ff, got %.8x\n", color
);
2674 stat
= GdipBitmapGetPixel(bitmap2
, 1, 1, &color
);
2676 ok(color_match(0xffffffff, color
, 1), "Expected ffff00ff, got %.8x\n", color
);
2678 GdipDeleteGraphics(graphics
);
2679 GdipDisposeImage((GpImage
*)bitmap1
);
2680 GdipDisposeImage((GpImage
*)bitmap2
);
2681 GdipDisposeImageAttributes(imageattr
);
2684 static void test_dispose(void)
2688 char invalid_image
[256];
2690 stat
= GdipDisposeImage(NULL
);
2691 expect(InvalidParameter
, stat
);
2693 stat
= GdipCreateBitmapFromScan0(2, 2, 0, PixelFormat32bppARGB
, NULL
, (GpBitmap
**)&image
);
2696 stat
= GdipDisposeImage(image
);
2699 stat
= GdipDisposeImage(image
);
2700 expect(ObjectBusy
, stat
);
2702 memset(invalid_image
, 0, 256);
2703 stat
= GdipDisposeImage((GpImage
*)invalid_image
);
2704 expect(ObjectBusy
, stat
);
2707 static LONG
obj_refcount(void *obj
)
2709 IUnknown_AddRef((IUnknown
*)obj
);
2710 return IUnknown_Release((IUnknown
*)obj
);
2713 static GpImage
*load_image(const BYTE
*image_data
, UINT image_size
)
2720 GpImage
*image
= NULL
, *clone
;
2721 ImageType image_type
;
2722 LONG refcount
, old_refcount
;
2724 hmem
= GlobalAlloc(0, image_size
);
2725 data
= GlobalLock(hmem
);
2726 memcpy(data
, image_data
, image_size
);
2729 hr
= CreateStreamOnHGlobal(hmem
, TRUE
, &stream
);
2730 ok(hr
== S_OK
, "CreateStreamOnHGlobal error %#x\n", hr
);
2731 if (hr
!= S_OK
) return NULL
;
2733 refcount
= obj_refcount(stream
);
2734 ok(refcount
== 1, "expected stream refcount 1, got %d\n", refcount
);
2736 status
= GdipLoadImageFromStream(stream
, &image
);
2737 ok(status
== Ok
|| broken(status
== InvalidParameter
), /* XP */
2738 "GdipLoadImageFromStream error %d\n", status
);
2741 IStream_Release(stream
);
2745 status
= GdipGetImageType(image
, &image_type
);
2746 ok(status
== Ok
, "GdipGetImageType error %d\n", status
);
2748 refcount
= obj_refcount(stream
);
2749 if (image_type
== ImageTypeBitmap
)
2750 ok(refcount
> 1, "expected stream refcount > 1, got %d\n", refcount
);
2752 ok(refcount
== 1, "expected stream refcount 1, got %d\n", refcount
);
2753 old_refcount
= refcount
;
2755 status
= GdipCloneImage(image
, &clone
);
2756 ok(status
== Ok
, "GdipCloneImage error %d\n", status
);
2757 refcount
= obj_refcount(stream
);
2758 ok(refcount
== old_refcount
, "expected stream refcount %d, got %d\n", old_refcount
, refcount
);
2759 status
= GdipDisposeImage(clone
);
2760 ok(status
== Ok
, "GdipDisposeImage error %d\n", status
);
2761 refcount
= obj_refcount(stream
);
2762 ok(refcount
== old_refcount
, "expected stream refcount %d, got %d\n", old_refcount
, refcount
);
2764 refcount
= IStream_Release(stream
);
2765 if (image_type
== ImageTypeBitmap
)
2766 ok(refcount
>= 1, "expected stream refcount != 0\n");
2768 ok(refcount
== 0, "expected stream refcount 0, got %d\n", refcount
);
2773 static void test_image_properties(void)
2775 static const struct test_data
2777 const BYTE
*image_data
;
2779 ImageType image_type
;
2781 UINT prop_count2
; /* if win7 behaves differently */
2782 /* 1st property attributes */
2784 UINT prop_size2
; /* if win7 behaves differently */
2786 UINT prop_id2
; /* if win7 behaves differently */
2790 { pngimage
, sizeof(pngimage
), ImageTypeBitmap
, 4, ~0, 1, 20, 0x5110, 0x132 },
2791 { gifimage
, sizeof(gifimage
), ImageTypeBitmap
, 1, 4, 4, 0, 0x5100, 0 },
2792 { jpgimage
, sizeof(jpgimage
), ImageTypeBitmap
, 2, ~0, 128, 0, 0x5090, 0x5091 },
2793 { tiffimage
, sizeof(tiffimage
), ImageTypeBitmap
, 16, 0, 4, 0, 0xfe, 0 },
2794 { bmpimage
, sizeof(bmpimage
), ImageTypeBitmap
, 0, 0, 0, 0, 0, 0 },
2795 { wmfimage
, sizeof(wmfimage
), ImageTypeMetafile
, 0, 0, 0, 0, 0, 0 }
2799 UINT prop_count
, prop_size
, i
;
2800 PROPID prop_id
[16] = { 0 };
2801 ImageType image_type
;
2808 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
2810 image
= load_image(td
[i
].image_data
, td
[i
].image_size
);
2813 trace("%u: failed to load image data\n", i
);
2817 status
= GdipGetImageType(image
, &image_type
);
2818 ok(status
== Ok
, "%u: GdipGetImageType error %d\n", i
, status
);
2819 ok(td
[i
].image_type
== image_type
, "%u: expected image_type %d, got %d\n",
2820 i
, td
[i
].image_type
, image_type
);
2822 status
= GdipGetPropertyCount(image
, &prop_count
);
2823 ok(status
== Ok
, "%u: GdipGetPropertyCount error %d\n", i
, status
);
2824 if (td
[i
].image_data
== pngimage
|| td
[i
].image_data
== gifimage
||
2825 td
[i
].image_data
== jpgimage
)
2827 ok(td
[i
].prop_count
== prop_count
|| td
[i
].prop_count2
== prop_count
,
2828 " %u: expected property count %u or %u, got %u\n",
2829 i
, td
[i
].prop_count
, td
[i
].prop_count2
, prop_count
);
2831 ok(td
[i
].prop_count
== prop_count
|| td
[i
].prop_count2
== prop_count
,
2832 " %u: expected property count %u or %u, got %u\n",
2833 i
, td
[i
].prop_count
, td
[i
].prop_count2
, prop_count
);
2835 status
= GdipGetPropertyItemSize(NULL
, 0, &prop_size
);
2836 expect(InvalidParameter
, status
);
2837 status
= GdipGetPropertyItemSize(image
, 0, NULL
);
2838 expect(InvalidParameter
, status
);
2839 status
= GdipGetPropertyItemSize(image
, 0, &prop_size
);
2840 if (image_type
== ImageTypeMetafile
)
2841 expect(NotImplemented
, status
);
2843 expect(PropertyNotFound
, status
);
2845 status
= GdipGetPropertyItem(NULL
, 0, 0, &item
.data
);
2846 expect(InvalidParameter
, status
);
2847 status
= GdipGetPropertyItem(image
, 0, 0, NULL
);
2848 expect(InvalidParameter
, status
);
2849 status
= GdipGetPropertyItem(image
, 0, 0, &item
.data
);
2850 if (image_type
== ImageTypeMetafile
)
2851 expect(NotImplemented
, status
);
2853 expect(PropertyNotFound
, status
);
2855 /* FIXME: remove once Wine is fixed */
2856 if (td
[i
].prop_count
!= prop_count
)
2858 GdipDisposeImage(image
);
2862 status
= GdipGetPropertyIdList(NULL
, prop_count
, prop_id
);
2863 expect(InvalidParameter
, status
);
2864 status
= GdipGetPropertyIdList(image
, prop_count
, NULL
);
2865 expect(InvalidParameter
, status
);
2866 status
= GdipGetPropertyIdList(image
, 0, prop_id
);
2867 if (image_type
== ImageTypeMetafile
)
2868 expect(NotImplemented
, status
);
2869 else if (prop_count
== 0)
2872 expect(InvalidParameter
, status
);
2873 status
= GdipGetPropertyIdList(image
, prop_count
- 1, prop_id
);
2874 if (image_type
== ImageTypeMetafile
)
2875 expect(NotImplemented
, status
);
2877 expect(InvalidParameter
, status
);
2878 status
= GdipGetPropertyIdList(image
, prop_count
+ 1, prop_id
);
2879 if (image_type
== ImageTypeMetafile
)
2880 expect(NotImplemented
, status
);
2882 expect(InvalidParameter
, status
);
2883 status
= GdipGetPropertyIdList(image
, prop_count
, prop_id
);
2884 if (image_type
== ImageTypeMetafile
)
2885 expect(NotImplemented
, status
);
2889 if (prop_count
!= 0)
2890 ok(td
[i
].prop_id
== prop_id
[0] || td
[i
].prop_id2
== prop_id
[0],
2891 " %u: expected property id %#x or %#x, got %#x\n",
2892 i
, td
[i
].prop_id
, td
[i
].prop_id2
, prop_id
[0]);
2897 status
= GdipGetPropertyItemSize(image
, prop_id
[0], &prop_size
);
2898 if (prop_count
== 0)
2899 expect(PropertyNotFound
, status
);
2904 assert(sizeof(item
) >= prop_size
);
2905 ok(prop_size
> sizeof(PropertyItem
), "%u: got too small prop_size %u\n",
2907 ok(td
[i
].prop_size
+ sizeof(PropertyItem
) == prop_size
||
2908 td
[i
].prop_size2
+ sizeof(PropertyItem
) == prop_size
,
2909 " %u: expected property size %u or %u, got %u\n",
2910 i
, td
[i
].prop_size
, td
[i
].prop_size2
, prop_size
);
2912 status
= GdipGetPropertyItem(image
, prop_id
[0], 0, &item
.data
);
2913 ok(status
== InvalidParameter
|| status
== GenericError
/* Win7 */,
2914 "%u: expected InvalidParameter, got %d\n", i
, status
);
2915 status
= GdipGetPropertyItem(image
, prop_id
[0], prop_size
- 1, &item
.data
);
2916 ok(status
== InvalidParameter
|| status
== GenericError
/* Win7 */,
2917 "%u: expected InvalidParameter, got %d\n", i
, status
);
2918 status
= GdipGetPropertyItem(image
, prop_id
[0], prop_size
+ 1, &item
.data
);
2919 ok(status
== InvalidParameter
|| status
== GenericError
/* Win7 */,
2920 "%u: expected InvalidParameter, got %d\n", i
, status
);
2921 status
= GdipGetPropertyItem(image
, prop_id
[0], prop_size
, &item
.data
);
2923 ok(prop_id
[0] == item
.data
.id
,
2924 "%u: expected property id %#x, got %#x\n", i
, prop_id
[0], item
.data
.id
);
2928 GdipDisposeImage(image
);
2936 #define IFD_RATIONAL 5
2938 #define IFD_UNDEFINED 7
2939 #define IFD_SSHORT 8
2941 #define IFD_SRATIONAL 10
2942 #define IFD_FLOAT 11
2943 #define IFD_DOUBLE 12
2945 #ifndef PropertyTagTypeSByte
2946 #define PropertyTagTypeSByte 6
2947 #define PropertyTagTypeSShort 8
2948 #define PropertyTagTypeFloat 11
2949 #define PropertyTagTypeDouble 12
2952 static UINT
documented_type(UINT type
)
2956 case PropertyTagTypeSByte
: return PropertyTagTypeByte
;
2957 case PropertyTagTypeSShort
: return PropertyTagTypeShort
;
2958 case PropertyTagTypeFloat
: return PropertyTagTypeUndefined
;
2959 case PropertyTagTypeDouble
: return PropertyTagTypeUndefined
;
2960 default: return type
;
2964 #include "pshpack2.h"
2979 static const struct tiff_data
2984 USHORT number_of_entries
;
2985 struct IFD_entry entry
[40];
2987 struct IFD_rational xres
;
2989 struct IFD_rational srational_val
;
2994 struct IFD_rational rational
[3];
2998 #ifdef WORDS_BIGENDIAN
3004 FIELD_OFFSET(struct tiff_data
, number_of_entries
),
3007 { 0xff, IFD_SHORT
, 1, 0 }, /* SUBFILETYPE */
3008 { 0x100, IFD_LONG
, 1, 1 }, /* IMAGEWIDTH */
3009 { 0x101, IFD_LONG
, 1, 1 }, /* IMAGELENGTH */
3010 { 0x102, IFD_SHORT
, 1, 1 }, /* BITSPERSAMPLE */
3011 { 0x103, IFD_LONG
, 1, 1 }, /* COMPRESSION */
3012 { 0x106, IFD_SHORT
, 1, 1 }, /* PHOTOMETRIC */
3013 { 0x111, IFD_LONG
, 1, FIELD_OFFSET(struct tiff_data
, pixel_data
) }, /* STRIPOFFSETS */
3014 { 0x115, IFD_SHORT
, 1, 1 }, /* SAMPLESPERPIXEL */
3015 { 0x116, IFD_LONG
, 1, 1 }, /* ROWSPERSTRIP */
3016 { 0x117, IFD_LONG
, 1, 1 }, /* STRIPBYTECOUNT */
3017 { 0x11a, IFD_RATIONAL
, 1, FIELD_OFFSET(struct tiff_data
, xres
) },
3018 { 0x11b, IFD_RATIONAL
, 1, FIELD_OFFSET(struct tiff_data
, xres
) },
3019 { 0x128, IFD_SHORT
, 1, 2 }, /* RESOLUTIONUNIT */
3020 { 0xf001, IFD_BYTE
, 1, 0x11223344 },
3021 { 0xf002, IFD_BYTE
, 4, 0x11223344 },
3022 { 0xf003, IFD_SBYTE
, 1, 0x11223344 },
3023 { 0xf004, IFD_SSHORT
, 1, 0x11223344 },
3024 { 0xf005, IFD_SSHORT
, 2, 0x11223344 },
3025 { 0xf006, IFD_SLONG
, 1, 0x11223344 },
3026 { 0xf007, IFD_FLOAT
, 1, 0x11223344 },
3027 { 0xf008, IFD_DOUBLE
, 1, FIELD_OFFSET(struct tiff_data
, double_val
) },
3028 { 0xf009, IFD_SRATIONAL
, 1, FIELD_OFFSET(struct tiff_data
, srational_val
) },
3029 { 0xf00a, IFD_BYTE
, 13, FIELD_OFFSET(struct tiff_data
, string
) },
3030 { 0xf00b, IFD_SSHORT
, 4, FIELD_OFFSET(struct tiff_data
, short_val
) },
3031 { 0xf00c, IFD_SLONG
, 2, FIELD_OFFSET(struct tiff_data
, long_val
) },
3032 { 0xf00e, IFD_ASCII
, 13, FIELD_OFFSET(struct tiff_data
, string
) },
3033 { 0xf00f, IFD_ASCII
, 4, 'a' | 'b' << 8 | 'c' << 16 | 'd' << 24 },
3034 { 0xf010, IFD_UNDEFINED
, 13, FIELD_OFFSET(struct tiff_data
, string
) },
3035 { 0xf011, IFD_UNDEFINED
, 4, 'a' | 'b' << 8 | 'c' << 16 | 'd' << 24 },
3036 /* Some gdiplus versions ignore these fields.
3037 { 0xf012, IFD_BYTE, 0, 0x11223344 },
3038 { 0xf013, IFD_SHORT, 0, 0x11223344 },
3039 { 0xf014, IFD_LONG, 0, 0x11223344 },
3040 { 0xf015, IFD_FLOAT, 0, 0x11223344 },*/
3041 { 0xf016, IFD_SRATIONAL
, 3, FIELD_OFFSET(struct tiff_data
, rational
) },
3042 /* Win7 before SP1 doesn't recognize this field, everybody else does. */
3043 { 0xf017, IFD_FLOAT
, 2, FIELD_OFFSET(struct tiff_data
, float_val
) },
3047 1234567890.0987654321,
3048 { 0x1a2b3c4d, 0x5a6b7c8d },
3050 { 0x0101, 0x0202, 0x0303, 0x0404 },
3051 { 0x11223344, 0x55667788 },
3052 { (FLOAT
)1234.5678, (FLOAT
)8765.4321 },
3053 { { 0x01020304, 0x05060708 }, { 0x10203040, 0x50607080 }, { 0x11223344, 0x55667788 } },
3054 { 0x11, 0x22, 0x33, 0 }
3056 #include "poppack.h"
3058 static void test_tiff_properties(void)
3060 static const struct test_data
3062 ULONG type
, id
, length
;
3063 const BYTE value
[24];
3066 { PropertyTagTypeShort
, 0xff, 2, { 0 } },
3067 { PropertyTagTypeLong
, 0x100, 4, { 1 } },
3068 { PropertyTagTypeLong
, 0x101, 4, { 1 } },
3069 { PropertyTagTypeShort
, 0x102, 2, { 1 } },
3070 { PropertyTagTypeLong
, 0x103, 4, { 1 } },
3071 { PropertyTagTypeShort
, 0x106, 2, { 1 } },
3072 { PropertyTagTypeLong
, 0x111, 4, { 0x44,0x02 } },
3073 { PropertyTagTypeShort
, 0x115, 2, { 1 } },
3074 { PropertyTagTypeLong
, 0x116, 4, { 1 } },
3075 { PropertyTagTypeLong
, 0x117, 4, { 1 } },
3076 { PropertyTagTypeRational
, 0x11a, 8, { 0x84,0x03,0,0,0x03 } },
3077 { PropertyTagTypeRational
, 0x11b, 8, { 0x84,0x03,0,0,0x03 } },
3078 { PropertyTagTypeShort
, 0x128, 2, { 2 } },
3079 { PropertyTagTypeByte
, 0xf001, 1, { 0x44 } },
3080 { PropertyTagTypeByte
, 0xf002, 4, { 0x44,0x33,0x22,0x11 } },
3081 { PropertyTagTypeSByte
, 0xf003, 1, { 0x44 } },
3082 { PropertyTagTypeSShort
, 0xf004, 2, { 0x44,0x33 } },
3083 { PropertyTagTypeSShort
, 0xf005, 4, { 0x44,0x33,0x22,0x11 } },
3084 { PropertyTagTypeSLONG
, 0xf006, 4, { 0x44,0x33,0x22,0x11 } },
3085 { PropertyTagTypeFloat
, 0xf007, 4, { 0x44,0x33,0x22,0x11 } },
3086 { PropertyTagTypeDouble
, 0xf008, 8, { 0x2c,0x52,0x86,0xb4,0x80,0x65,0xd2,0x41 } },
3087 { PropertyTagTypeSRational
, 0xf009, 8, { 0x4d, 0x3c, 0x2b, 0x1a, 0x8d, 0x7c, 0x6b, 0x5a } },
3088 { PropertyTagTypeByte
, 0xf00a, 13, { 'H','e','l','l','o',' ','W','o','r','l','d','!',0 } },
3089 { PropertyTagTypeSShort
, 0xf00b, 8, { 0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04 } },
3090 { PropertyTagTypeSLONG
, 0xf00c, 8, { 0x44,0x33,0x22,0x11,0x88,0x77,0x66,0x55 } },
3091 { PropertyTagTypeASCII
, 0xf00e, 13, { 'H','e','l','l','o',' ','W','o','r','l','d','!',0 } },
3092 { PropertyTagTypeASCII
, 0xf00f, 5, { 'a','b','c','d' } },
3093 { PropertyTagTypeUndefined
, 0xf010, 13, { 'H','e','l','l','o',' ','W','o','r','l','d','!',0 } },
3094 { PropertyTagTypeUndefined
, 0xf011, 4, { 'a','b','c','d' } },
3095 { PropertyTagTypeSRational
, 0xf016, 24,
3096 { 0x04,0x03,0x02,0x01,0x08,0x07,0x06,0x05,
3097 0x40,0x30,0x20,0x10,0x80,0x70,0x60,0x50,
3098 0x44,0x33,0x22,0x11,0x88,0x77,0x66,0x55 } },
3099 /* Win7 before SP1 doesn't recognize this field, everybody else does. */
3100 { PropertyTagTypeFloat
, 0xf017, 8, { 0x2b,0x52,0x9a,0x44,0xba,0xf5,0x08,0x46 } },
3105 UINT dim_count
, frame_count
, prop_count
, prop_size
, i
;
3107 PropertyItem
*prop_item
;
3109 image
= load_image((const BYTE
*)&TIFF_data
, sizeof(TIFF_data
));
3110 ok(image
!= 0, "Failed to load TIFF image data\n");
3113 status
= GdipImageGetFrameDimensionsCount(image
, &dim_count
);
3115 expect(1, dim_count
);
3117 status
= GdipImageGetFrameDimensionsList(image
, &guid
, 1);
3119 expect_guid(&FrameDimensionPage
, &guid
, __LINE__
, FALSE
);
3121 frame_count
= 0xdeadbeef;
3122 status
= GdipImageGetFrameCount(image
, &guid
, &frame_count
);
3124 expect(1, frame_count
);
3126 prop_count
= 0xdeadbeef;
3127 status
= GdipGetPropertyCount(image
, &prop_count
);
3129 ok(prop_count
== sizeof(td
)/sizeof(td
[0]) ||
3130 broken(prop_count
== sizeof(td
)/sizeof(td
[0]) - 1) /* Win7 SP0 */,
3131 "expected property count %u, got %u\n", (UINT
)(sizeof(td
)/sizeof(td
[0])), prop_count
);
3133 prop_id
= HeapAlloc(GetProcessHeap(), 0, prop_count
* sizeof(*prop_id
));
3135 status
= GdipGetPropertyIdList(image
, prop_count
, prop_id
);
3138 for (i
= 0; i
< prop_count
; i
++)
3140 status
= GdipGetPropertyItemSize(image
, prop_id
[i
], &prop_size
);
3142 if (status
!= Ok
) break;
3143 ok(prop_size
> sizeof(*prop_item
), "%u: too small item length %u\n", i
, prop_size
);
3145 prop_item
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, prop_size
);
3146 status
= GdipGetPropertyItem(image
, prop_id
[i
], prop_size
, prop_item
);
3148 ok(prop_item
->value
== prop_item
+ 1, "expected item->value %p, got %p\n", prop_item
+ 1, prop_item
->value
);
3149 ok(td
[i
].type
== prop_item
->type
||
3150 /* Win7 stopped using proper but not documented types, and it
3151 looks broken since TypeFloat and TypeDouble now reported as
3152 TypeUndefined, and signed types reported as unsigned. */
3153 broken(prop_item
->type
== documented_type(td
[i
].type
)),
3154 "%u: expected type %u, got %u\n", i
, td
[i
].type
, prop_item
->type
);
3155 ok(td
[i
].id
== prop_item
->id
, "%u: expected id %#x, got %#x\n", i
, td
[i
].id
, prop_item
->id
);
3156 prop_size
-= sizeof(*prop_item
);
3157 ok(prop_item
->length
== prop_size
, "%u: expected length %u, got %u\n", i
, prop_size
, prop_item
->length
);
3158 ok(td
[i
].length
== prop_item
->length
, "%u: expected length %u, got %u\n", i
, td
[i
].length
, prop_item
->length
);
3159 ok(td
[i
].length
== prop_size
, "%u: expected length %u, got %u\n", i
, td
[i
].length
, prop_size
);
3160 if (td
[i
].length
== prop_item
->length
)
3162 int match
= memcmp(td
[i
].value
, prop_item
->value
, td
[i
].length
) == 0;
3163 ok(match
|| broken(td
[i
].length
<= 4 && !match
), "%u: data mismatch\n", i
);
3167 BYTE
*data
= prop_item
->value
;
3168 printf("id %#x:", prop_item
->id
);
3169 for (j
= 0; j
< prop_item
->length
; j
++)
3170 printf(" %02x", data
[j
]);
3174 HeapFree(GetProcessHeap(), 0, prop_item
);
3177 HeapFree(GetProcessHeap(), 0, prop_id
);
3179 GdipDisposeImage(image
);
3182 static void test_GdipGetAllPropertyItems(void)
3184 static const struct test_data
3186 ULONG type
, id
, length
;
3190 { PropertyTagTypeLong
, 0xfe, 4, { 0 } },
3191 { PropertyTagTypeShort
, 0x100, 2, { 1 } },
3192 { PropertyTagTypeShort
, 0x101, 2, { 1 } },
3193 { PropertyTagTypeShort
, 0x102, 6, { 8,0,8,0,8,0 } },
3194 { PropertyTagTypeShort
, 0x103, 2, { 1 } },
3195 { PropertyTagTypeShort
, 0x106, 2, { 2,0 } },
3196 { PropertyTagTypeASCII
, 0x10d, 27, "/home/meh/Desktop/test.tif" },
3197 { PropertyTagTypeLong
, 0x111, 4, { 8,0,0,0 } },
3198 { PropertyTagTypeShort
, 0x112, 2, { 1 } },
3199 { PropertyTagTypeShort
, 0x115, 2, { 3,0 } },
3200 { PropertyTagTypeShort
, 0x116, 2, { 0x40,0 } },
3201 { PropertyTagTypeLong
, 0x117, 4, { 3,0,0,0 } },
3202 { PropertyTagTypeRational
, 0x11a, 8, { 0,0,0,72,0,0,0,1 } },
3203 { PropertyTagTypeRational
, 0x11b, 8, { 0,0,0,72,0,0,0,1 } },
3204 { PropertyTagTypeShort
, 0x11c, 2, { 1 } },
3205 { PropertyTagTypeShort
, 0x128, 2, { 2 } }
3210 UINT dim_count
, frame_count
, prop_count
, prop_size
, i
;
3211 UINT total_size
, total_count
;
3213 PropertyItem
*prop_item
;
3214 const char *item_data
;
3216 image
= load_image(tiffimage
, sizeof(tiffimage
));
3217 ok(image
!= 0, "Failed to load TIFF image data\n");
3220 dim_count
= 0xdeadbeef;
3221 status
= GdipImageGetFrameDimensionsCount(image
, &dim_count
);
3223 expect(1, dim_count
);
3225 status
= GdipImageGetFrameDimensionsList(image
, &guid
, 1);
3227 expect_guid(&FrameDimensionPage
, &guid
, __LINE__
, FALSE
);
3229 frame_count
= 0xdeadbeef;
3230 status
= GdipImageGetFrameCount(image
, &guid
, &frame_count
);
3232 expect(1, frame_count
);
3234 prop_count
= 0xdeadbeef;
3235 status
= GdipGetPropertyCount(image
, &prop_count
);
3237 ok(prop_count
== sizeof(td
)/sizeof(td
[0]),
3238 "expected property count %u, got %u\n", (UINT
)(sizeof(td
)/sizeof(td
[0])), prop_count
);
3240 prop_id
= HeapAlloc(GetProcessHeap(), 0, prop_count
* sizeof(*prop_id
));
3242 status
= GdipGetPropertyIdList(image
, prop_count
, prop_id
);
3246 for (i
= 0; i
< prop_count
; i
++)
3249 status
= GdipGetPropertyItemSize(image
, prop_id
[i
], &size
);
3251 if (status
!= Ok
) break;
3252 ok(size
> sizeof(*prop_item
), "%u: too small item length %u\n", i
, size
);
3256 prop_item
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
3257 status
= GdipGetPropertyItem(image
, prop_id
[i
], size
, prop_item
);
3259 ok(prop_item
->value
== prop_item
+ 1, "expected item->value %p, got %p\n", prop_item
+ 1, prop_item
->value
);
3260 ok(td
[i
].type
== prop_item
->type
,
3261 "%u: expected type %u, got %u\n", i
, td
[i
].type
, prop_item
->type
);
3262 ok(td
[i
].id
== prop_item
->id
, "%u: expected id %#x, got %#x\n", i
, td
[i
].id
, prop_item
->id
);
3263 size
-= sizeof(*prop_item
);
3264 ok(prop_item
->length
== size
, "%u: expected length %u, got %u\n", i
, size
, prop_item
->length
);
3265 ok(td
[i
].length
== prop_item
->length
, "%u: expected length %u, got %u\n", i
, td
[i
].length
, prop_item
->length
);
3266 if (td
[i
].length
== prop_item
->length
)
3268 int match
= memcmp(td
[i
].value
, prop_item
->value
, td
[i
].length
) == 0;
3269 ok(match
, "%u: data mismatch\n", i
);
3273 BYTE
*data
= prop_item
->value
;
3274 printf("id %#x:", prop_item
->id
);
3275 for (j
= 0; j
< prop_item
->length
; j
++)
3276 printf(" %02x", data
[j
]);
3280 HeapFree(GetProcessHeap(), 0, prop_item
);
3283 HeapFree(GetProcessHeap(), 0, prop_id
);
3285 status
= GdipGetPropertySize(NULL
, &total_size
, &total_count
);
3286 expect(InvalidParameter
, status
);
3287 status
= GdipGetPropertySize(image
, &total_size
, NULL
);
3288 expect(InvalidParameter
, status
);
3289 status
= GdipGetPropertySize(image
, NULL
, &total_count
);
3290 expect(InvalidParameter
, status
);
3291 status
= GdipGetPropertySize(image
, NULL
, NULL
);
3292 expect(InvalidParameter
, status
);
3293 total_size
= 0xdeadbeef;
3294 total_count
= 0xdeadbeef;
3295 status
= GdipGetPropertySize(image
, &total_size
, &total_count
);
3297 ok(prop_count
== total_count
,
3298 "expected total property count %u, got %u\n", prop_count
, total_count
);
3299 ok(prop_size
== total_size
,
3300 "expected total property size %u, got %u\n", prop_size
, total_size
);
3302 prop_item
= HeapAlloc(GetProcessHeap(), 0, prop_size
);
3304 status
= GdipGetAllPropertyItems(image
, 0, prop_count
, prop_item
);
3305 expect(InvalidParameter
, status
);
3306 status
= GdipGetAllPropertyItems(image
, prop_size
, 1, prop_item
);
3307 expect(InvalidParameter
, status
);
3308 status
= GdipGetAllPropertyItems(image
, prop_size
, prop_count
, NULL
);
3309 expect(InvalidParameter
, status
);
3310 status
= GdipGetAllPropertyItems(image
, prop_size
, prop_count
, NULL
);
3311 expect(InvalidParameter
, status
);
3312 status
= GdipGetAllPropertyItems(image
, 0, 0, NULL
);
3313 expect(InvalidParameter
, status
);
3314 status
= GdipGetAllPropertyItems(image
, prop_size
+ 1, prop_count
, prop_item
);
3315 expect(InvalidParameter
, status
);
3316 status
= GdipGetAllPropertyItems(image
, prop_size
, prop_count
, prop_item
);
3319 item_data
= (const char *)(prop_item
+ prop_count
);
3320 for (i
= 0; i
< prop_count
; i
++)
3322 ok(prop_item
[i
].value
== item_data
, "%u: expected value %p, got %p\n",
3323 i
, item_data
, prop_item
[i
].value
);
3324 ok(td
[i
].type
== prop_item
[i
].type
,
3325 "%u: expected type %u, got %u\n", i
, td
[i
].type
, prop_item
[i
].type
);
3326 ok(td
[i
].id
== prop_item
[i
].id
, "%u: expected id %#x, got %#x\n", i
, td
[i
].id
, prop_item
[i
].id
);
3327 ok(td
[i
].length
== prop_item
[i
].length
, "%u: expected length %u, got %u\n", i
, td
[i
].length
, prop_item
[i
].length
);
3328 if (td
[i
].length
== prop_item
[i
].length
)
3330 int match
= memcmp(td
[i
].value
, prop_item
[i
].value
, td
[i
].length
) == 0;
3331 ok(match
, "%u: data mismatch\n", i
);
3335 BYTE
*data
= prop_item
[i
].value
;
3336 printf("id %#x:", prop_item
[i
].id
);
3337 for (j
= 0; j
< prop_item
[i
].length
; j
++)
3338 printf(" %02x", data
[j
]);
3342 item_data
+= prop_item
[i
].length
;
3345 HeapFree(GetProcessHeap(), 0, prop_item
);
3347 GdipDisposeImage(image
);
3350 static void test_tiff_palette(void)
3361 ARGB
*entries
= palette
.pal
.Entries
;
3363 /* 1bpp TIFF without palette */
3364 image
= load_image((const BYTE
*)&TIFF_data
, sizeof(TIFF_data
));
3365 ok(image
!= 0, "Failed to load TIFF image data\n");
3368 status
= GdipGetImagePixelFormat(image
, &format
);
3370 ok(format
== PixelFormat1bppIndexed
, "expected PixelFormat1bppIndexed, got %#x\n", format
);
3372 status
= GdipGetImagePaletteSize(image
, &size
);
3373 ok(status
== Ok
|| broken(status
== GenericError
), /* XP */
3374 "GdipGetImagePaletteSize error %d\n", status
);
3375 if (status
== GenericError
)
3377 GdipDisposeImage(image
);
3380 expect(sizeof(ColorPalette
) + sizeof(ARGB
), size
);
3382 status
= GdipGetImagePalette(image
, &palette
.pal
, size
);
3384 expect(0, palette
.pal
.Flags
);
3385 expect(2, palette
.pal
.Count
);
3386 if (palette
.pal
.Count
== 2)
3388 ok(entries
[0] == 0xff000000, "expected 0xff000000, got %#x\n", entries
[0]);
3389 ok(entries
[1] == 0xffffffff, "expected 0xffffffff, got %#x\n", entries
[1]);
3392 GdipDisposeImage(image
);
3395 static void test_bitmapbits(void)
3398 static const BYTE pixels_24
[48] =
3400 0xff,0xff,0xff, 0,0,0, 0xff,0xff,0xff, 0,0,0,
3401 0xff,0xff,0xff, 0,0,0, 0xff,0xff,0xff, 0,0,0,
3402 0xff,0xff,0xff, 0,0,0, 0xff,0xff,0xff, 0,0,0,
3403 0xff,0xff,0xff, 0,0,0, 0xff,0xff,0xff, 0,0,0
3405 static const BYTE pixels_00
[48] =
3407 0,0,0, 0,0,0, 0,0,0, 0,0,0,
3408 0,0,0, 0,0,0, 0,0,0, 0,0,0,
3409 0,0,0, 0,0,0, 0,0,0, 0,0,0,
3410 0,0,0, 0,0,0, 0,0,0, 0,0,0
3412 static const BYTE pixels_24_77
[64] =
3414 0xff,0xff,0xff, 0,0,0, 0xff,0xff,0xff, 0,0,0,
3415 0xff,0xff,0xff, 0,0,0, 0xff,0xff,0xff, 0,0,0,
3416 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3417 0xff,0xff,0xff, 0,0,0, 0xff,0xff,0xff, 0,0,0,
3418 0xff,0xff,0xff, 0,0,0, 0xff,0xff,0xff, 0,0,0,
3419 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77
3421 static const BYTE pixels_77
[64] =
3423 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3424 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3425 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3426 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3427 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3428 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3429 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3430 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77
3432 static const BYTE pixels_8
[16] =
3434 0x01,0,0x01,0,0x01,0,0x01,0,
3435 0x01,0,0x01,0,0x01,0,0x01,0
3437 static const BYTE pixels_8_77
[64] =
3439 0x01,0,0x01,0,0x01,0,0x01,0,
3440 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3441 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3442 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3443 0x01,0,0x01,0,0x01,0,0x01,0,
3444 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3445 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3446 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77
3448 static const BYTE pixels_1_77
[64] =
3450 0xaa,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3451 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3452 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3453 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3454 0xaa,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3455 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3456 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
3457 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77
3459 static const BYTE pixels_1
[8] = {0xaa,0,0,0,0xaa,0,0,0};
3460 static const struct test_data
3467 const BYTE
*pixels_unlocked
;
3471 { PixelFormat24bppRGB
, 24, 0xfff0, 24, 48, pixels_24
, pixels_00
},
3473 { PixelFormat24bppRGB
, 24, 0, 24, 48, pixels_24
, pixels_00
},
3474 { PixelFormat24bppRGB
, 24, ImageLockModeRead
, 24, 48, pixels_24
, pixels_00
},
3475 { PixelFormat24bppRGB
, 24, ImageLockModeWrite
, 24, 48, pixels_24
, pixels_00
},
3476 { PixelFormat24bppRGB
, 24, ImageLockModeRead
|ImageLockModeWrite
, 24, 48, pixels_24
, pixels_00
},
3477 { PixelFormat24bppRGB
, 24, ImageLockModeRead
|ImageLockModeUserInputBuf
, 32, 64, pixels_24_77
, pixels_24
},
3478 { PixelFormat24bppRGB
, 24, ImageLockModeWrite
|ImageLockModeUserInputBuf
, 32, 64, pixels_77
, pixels_00
},
3479 { PixelFormat24bppRGB
, 24, ImageLockModeUserInputBuf
, 32, 64, pixels_77
, pixels_24
},
3481 { PixelFormat8bppIndexed
, 8, 0, 8, 16, pixels_8
, pixels_24
},
3482 { PixelFormat8bppIndexed
, 8, ImageLockModeRead
, 8, 16, pixels_8
, pixels_24
},
3483 { PixelFormat8bppIndexed
, 8, ImageLockModeWrite
, 8, 16, pixels_8
, pixels_00
},
3484 { PixelFormat8bppIndexed
, 8, ImageLockModeRead
|ImageLockModeWrite
, 8, 16, pixels_8
, pixels_00
},
3485 { PixelFormat8bppIndexed
, 8, ImageLockModeRead
|ImageLockModeUserInputBuf
, 32, 64, pixels_8_77
, pixels_24
},
3486 { PixelFormat8bppIndexed
, 8, ImageLockModeWrite
|ImageLockModeUserInputBuf
, 32, 64, pixels_77
, pixels_00
},
3487 { PixelFormat8bppIndexed
, 8, ImageLockModeUserInputBuf
, 32, 64, pixels_77
, pixels_24
},
3489 { PixelFormat1bppIndexed
, 1, 0, 4, 8, pixels_1
, pixels_24
},
3490 { PixelFormat1bppIndexed
, 1, ImageLockModeRead
, 4, 8, pixels_1
, pixels_24
},
3491 { PixelFormat1bppIndexed
, 1, ImageLockModeWrite
, 4, 8, pixels_1
, pixels_00
},
3492 { PixelFormat1bppIndexed
, 1, ImageLockModeRead
|ImageLockModeWrite
, 4, 8, pixels_1
, pixels_00
},
3493 { PixelFormat1bppIndexed
, 1, ImageLockModeRead
|ImageLockModeUserInputBuf
, 32, 64, pixels_1_77
, pixels_24
},
3494 { PixelFormat1bppIndexed
, 1, ImageLockModeWrite
|ImageLockModeUserInputBuf
, 32, 64, pixels_77
, pixels_00
},
3495 { PixelFormat1bppIndexed
, 1, ImageLockModeUserInputBuf
, 32, 64, pixels_77
, pixels_24
},
3507 ARGB
*entries
= palette
.pal
.Entries
;
3509 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3511 BYTE pixels
[sizeof(pixels_24
)];
3512 memcpy(pixels
, pixels_24
, sizeof(pixels_24
));
3513 status
= GdipCreateBitmapFromScan0(8, 2, 24, PixelFormat24bppRGB
, pixels
, &bitmap
);
3516 /* associate known palette with pixel data */
3517 palette
.pal
.Flags
= PaletteFlagsGrayScale
;
3518 palette
.pal
.Count
= 2;
3519 entries
[0] = 0xff000000;
3520 entries
[1] = 0xffffffff;
3521 status
= GdipSetImagePalette((GpImage
*)bitmap
, &palette
.pal
);
3524 memset(&data
, 0xfe, sizeof(data
));
3525 if (td
[i
].mode
& ImageLockModeUserInputBuf
)
3527 memset(buf
, 0x77, sizeof(buf
));
3531 status
= GdipBitmapLockBits(bitmap
, NULL
, td
[i
].mode
, td
[i
].format
, &data
);
3532 ok(status
== Ok
|| broken(status
== InvalidParameter
) /* XP */, "%u: GdipBitmapLockBits error %d\n", i
, status
);
3535 GdipDisposeImage((GpImage
*)bitmap
);
3538 ok(data
.Width
== 8, "%u: expected 8, got %d\n", i
, data
.Width
);
3539 ok(data
.Height
== 2, "%u: expected 2, got %d\n", i
, data
.Height
);
3540 ok(td
[i
].stride
== data
.Stride
, "%u: expected %d, got %d\n", i
, td
[i
].stride
, data
.Stride
);
3541 ok(td
[i
].format
== data
.PixelFormat
, "%u: expected %d, got %d\n", i
, td
[i
].format
, data
.PixelFormat
);
3542 ok(td
[i
].size
== data
.Height
* data
.Stride
, "%u: expected %d, got %d\n", i
, td
[i
].size
, data
.Height
* data
.Stride
);
3543 if (td
[i
].mode
& ImageLockModeUserInputBuf
)
3544 ok(data
.Scan0
== buf
, "%u: got wrong buffer\n", i
);
3545 if (td
[i
].size
== data
.Height
* data
.Stride
)
3547 UINT j
, match
, width_bytes
= (data
.Width
* td
[i
].bpp
) / 8;
3550 for (j
= 0; j
< data
.Height
; j
++)
3552 if (memcmp((const BYTE
*)data
.Scan0
+ j
* data
.Stride
, td
[i
].pixels
+ j
* data
.Stride
, width_bytes
) != 0)
3558 if ((td
[i
].mode
& (ImageLockModeRead
|ImageLockModeUserInputBuf
)) || td
[i
].format
== PixelFormat24bppRGB
)
3561 "%u: data should match\n", i
);
3564 BYTE
*bits
= data
.Scan0
;
3565 printf("%u: data mismatch for format %#x:", i
, td
[i
].format
);
3566 for (j
= 0; j
< td
[i
].size
; j
++)
3567 printf(" %02x", bits
[j
]);
3572 ok(!match
, "%u: data shouldn't match\n", i
);
3574 memset(data
.Scan0
, 0, td
[i
].size
);
3577 status
= GdipBitmapUnlockBits(bitmap
, &data
);
3578 ok(status
== Ok
, "%u: GdipBitmapUnlockBits error %d\n", i
, status
);
3580 memset(&data
, 0xfe, sizeof(data
));
3581 status
= GdipBitmapLockBits(bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &data
);
3582 ok(status
== Ok
, "%u: GdipBitmapLockBits error %d\n", i
, status
);
3583 ok(data
.Width
== 8, "%u: expected 8, got %d\n", i
, data
.Width
);
3584 ok(data
.Height
== 2, "%u: expected 2, got %d\n", i
, data
.Height
);
3585 ok(data
.Stride
== 24, "%u: expected 24, got %d\n", i
, data
.Stride
);
3586 ok(data
.PixelFormat
== PixelFormat24bppRGB
, "%u: got wrong pixel format %d\n", i
, data
.PixelFormat
);
3587 ok(data
.Height
* data
.Stride
== 48, "%u: expected 48, got %d\n", i
, data
.Height
* data
.Stride
);
3588 if (data
.Height
* data
.Stride
== 48)
3590 int match
= memcmp(data
.Scan0
, td
[i
].pixels_unlocked
, 48) == 0;
3591 ok(match
, "%u: data should match\n", i
);
3595 BYTE
*bits
= data
.Scan0
;
3596 printf("%u: data mismatch for format %#x:", i
, td
[i
].format
);
3597 for (j
= 0; j
< 48; j
++)
3598 printf(" %02x", bits
[j
]);
3603 status
= GdipBitmapUnlockBits(bitmap
, &data
);
3604 ok(status
== Ok
, "%u: GdipBitmapUnlockBits error %d\n", i
, status
);
3606 status
= GdipDisposeImage((GpImage
*)bitmap
);
3611 static void test_DrawImage(void)
3613 BYTE black_1x1
[4] = { 0,0,0,0 };
3614 BYTE white_2x2
[16] = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
3615 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff };
3616 BYTE black_2x2
[16] = { 0,0,0,0,0,0,0xff,0xff,
3617 0,0,0,0,0,0,0xff,0xff };
3624 GpGraphics
*graphics
;
3627 status
= GdipCreateBitmapFromScan0(1, 1, 4, PixelFormat24bppRGB
, black_1x1
, &u1
.bitmap
);
3629 status
= GdipBitmapSetResolution(u1
.bitmap
, 100.0, 100.0);
3632 status
= GdipCreateBitmapFromScan0(2, 2, 8, PixelFormat24bppRGB
, white_2x2
, &u2
.bitmap
);
3634 status
= GdipBitmapSetResolution(u2
.bitmap
, 300.0, 300.0);
3636 status
= GdipGetImageGraphicsContext(u2
.image
, &graphics
);
3638 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3641 status
= GdipDrawImageI(graphics
, u1
.image
, 0, 0);
3644 match
= memcmp(white_2x2
, black_2x2
, sizeof(black_2x2
)) == 0;
3645 ok(match
, "data should match\n");
3648 UINT i
, size
= sizeof(white_2x2
);
3649 BYTE
*bits
= white_2x2
;
3650 for (i
= 0; i
< size
; i
++)
3651 printf(" %02x", bits
[i
]);
3655 status
= GdipDeleteGraphics(graphics
);
3657 status
= GdipDisposeImage(u1
.image
);
3659 status
= GdipDisposeImage(u2
.image
);
3663 static void test_GdipDrawImagePointRect(void)
3665 BYTE black_1x1
[4] = { 0,0,0,0 };
3666 BYTE white_2x2
[16] = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
3667 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff };
3668 BYTE black_2x2
[16] = { 0,0,0,0,0,0,0xff,0xff,
3669 0,0,0,0,0,0,0xff,0xff };
3676 GpGraphics
*graphics
;
3679 status
= GdipCreateBitmapFromScan0(1, 1, 4, PixelFormat24bppRGB
, black_1x1
, &u1
.bitmap
);
3681 status
= GdipBitmapSetResolution(u1
.bitmap
, 100.0, 100.0);
3684 status
= GdipCreateBitmapFromScan0(2, 2, 8, PixelFormat24bppRGB
, white_2x2
, &u2
.bitmap
);
3686 status
= GdipBitmapSetResolution(u2
.bitmap
, 300.0, 300.0);
3688 status
= GdipGetImageGraphicsContext(u2
.image
, &graphics
);
3690 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3693 status
= GdipDrawImagePointRectI(graphics
, u1
.image
, 0, 0, 0, 0, 1, 1, UnitPixel
);
3696 match
= memcmp(white_2x2
, black_2x2
, sizeof(black_2x2
)) == 0;
3697 ok(match
, "data should match\n");
3700 UINT i
, size
= sizeof(white_2x2
);
3701 BYTE
*bits
= white_2x2
;
3702 for (i
= 0; i
< size
; i
++)
3703 printf(" %02x", bits
[i
]);
3707 status
= GdipDeleteGraphics(graphics
);
3709 status
= GdipDisposeImage(u1
.image
);
3711 status
= GdipDisposeImage(u2
.image
);
3715 static void test_image_format(void)
3717 static const PixelFormat fmt
[] =
3719 PixelFormat1bppIndexed
, PixelFormat4bppIndexed
, PixelFormat8bppIndexed
,
3720 PixelFormat16bppGrayScale
, PixelFormat16bppRGB555
, PixelFormat16bppRGB565
,
3721 PixelFormat16bppARGB1555
, PixelFormat24bppRGB
, PixelFormat32bppRGB
,
3722 PixelFormat32bppARGB
, PixelFormat32bppPARGB
, PixelFormat48bppRGB
,
3723 PixelFormat64bppARGB
, PixelFormat64bppPARGB
, PixelFormat32bppCMYK
3734 for (i
= 0; i
< sizeof(fmt
)/sizeof(fmt
[0]); i
++)
3736 status
= GdipCreateBitmapFromScan0(1, 1, 0, fmt
[i
], NULL
, &bitmap
);
3737 ok(status
== Ok
|| broken(status
== InvalidParameter
) /* before win7 */,
3738 "GdipCreateBitmapFromScan0 error %d\n", status
);
3739 if (status
!= Ok
) continue;
3741 status
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
3743 expect(fmt
[i
], format
);
3745 status
= GdipCreateHBITMAPFromBitmap(bitmap
, &hbitmap
, 0);
3746 if (fmt
[i
] == PixelFormat16bppGrayScale
|| fmt
[i
] == PixelFormat32bppCMYK
)
3747 todo_wine
expect(InvalidParameter
, status
);
3751 ret
= GetObject(hbitmap
, sizeof(bm
), &bm
);
3752 expect(sizeof(bm
), ret
);
3753 expect(0, bm
.bmType
);
3754 expect(1, bm
.bmWidth
);
3755 expect(1, bm
.bmHeight
);
3756 expect(4, bm
.bmWidthBytes
);
3757 expect(1, bm
.bmPlanes
);
3758 expect(32, bm
.bmBitsPixel
);
3759 DeleteObject(hbitmap
);
3762 status
= GdipGetImageThumbnail((GpImage
*)bitmap
, 0, 0, &thumb
, NULL
, NULL
);
3763 if (fmt
[i
] == PixelFormat16bppGrayScale
|| fmt
[i
] == PixelFormat32bppCMYK
)
3765 ok(status
== OutOfMemory
|| broken(status
== InvalidParameter
) /* before win7 */,
3766 "expected OutOfMemory, got %d\n", status
);
3770 status
= GdipGetImagePixelFormat(thumb
, &format
);
3772 ok(format
== PixelFormat32bppPARGB
|| broken(format
!= PixelFormat32bppPARGB
) /* before win7 */,
3773 "expected PixelFormat32bppPARGB, got %#x\n", format
);
3774 status
= GdipDisposeImage(thumb
);
3778 status
= GdipBitmapLockBits(bitmap
, NULL
, ImageLockModeRead
, PixelFormat32bppPARGB
, &data
);
3779 if (fmt
[i
] == PixelFormat16bppGrayScale
|| fmt
[i
] == PixelFormat32bppCMYK
)
3780 todo_wine
expect(InvalidParameter
, status
);
3784 status
= GdipBitmapUnlockBits(bitmap
, &data
);
3788 status
= GdipDisposeImage((GpImage
*)bitmap
);
3793 static void test_DrawImage_scale(void)
3795 static const BYTE back_8x1
[24] = { 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
3796 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
3797 static const BYTE image_080
[24] = { 0x40,0x40,0x40,0x80,0x80,0x80,0x40,0x40,0x40,0x40,0x40,0x40,
3798 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
3799 static const BYTE image_100
[24] = { 0x40,0x40,0x40,0x80,0x80,0x80,0x80,0x80,0x80,0x40,0x40,0x40,
3800 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
3801 static const BYTE image_120
[24] = { 0x40,0x40,0x40,0x40,0x40,0x40,0x80,0x80,0x80,0x40,0x40,0x40,
3802 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
3803 static const BYTE image_150
[24] = { 0x40,0x40,0x40,0x40,0x40,0x40,0x80,0x80,0x80,0x80,0x80,0x80,
3804 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
3805 static const BYTE image_180
[24] = { 0x40,0x40,0x40,0x40,0x40,0x40,0x80,0x80,0x80,0x80,0x80,0x80,
3806 0x80,0x80,0x80,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
3807 static const BYTE image_200
[24] = { 0x40,0x40,0x40,0x40,0x40,0x40,0x80,0x80,0x80,0x80,0x80,0x80,
3808 0x80,0x80,0x80,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
3809 static const BYTE image_250
[24] = { 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x80,0x80,0x80,
3810 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x40,0x40,0x40 };
3811 static const BYTE image_120_half
[24] = { 0x40,0x40,0x40,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
3812 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
3813 static const BYTE image_150_half
[24] = { 0x40,0x40,0x40,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
3814 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
3815 static const BYTE image_200_half
[24] = { 0x40,0x40,0x40,0x40,0x40,0x40,0x80,0x80,0x80,0x80,0x80,0x80,
3816 0x80,0x80,0x80,0x80,0x80,0x80,0x40,0x40,0x40,0x40,0x40,0x40 };
3817 static const BYTE image_250_half
[24] = { 0x40,0x40,0x40,0x40,0x40,0x40,0x80,0x80,0x80,0x80,0x80,0x80,
3818 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x40,0x40,0x40 };
3819 static const struct test_data
3822 PixelOffsetMode pixel_offset_mode
;
3827 { 0.8, PixelOffsetModeNone
, image_080
}, /* 0 */
3828 { 1.0, PixelOffsetModeNone
, image_100
},
3829 { 1.2, PixelOffsetModeNone
, image_120
},
3830 { 1.5, PixelOffsetModeNone
, image_150
},
3831 { 1.8, PixelOffsetModeNone
, image_180
},
3832 { 2.0, PixelOffsetModeNone
, image_200
},
3833 { 2.5, PixelOffsetModeNone
, image_250
},
3835 { 0.8, PixelOffsetModeHighSpeed
, image_080
}, /* 7 */
3836 { 1.0, PixelOffsetModeHighSpeed
, image_100
},
3837 { 1.2, PixelOffsetModeHighSpeed
, image_120
},
3838 { 1.5, PixelOffsetModeHighSpeed
, image_150
},
3839 { 1.8, PixelOffsetModeHighSpeed
, image_180
},
3840 { 2.0, PixelOffsetModeHighSpeed
, image_200
},
3841 { 2.5, PixelOffsetModeHighSpeed
, image_250
},
3843 { 0.8, PixelOffsetModeHalf
, image_080
}, /* 14 */
3844 { 1.0, PixelOffsetModeHalf
, image_100
},
3845 { 1.2, PixelOffsetModeHalf
, image_120_half
, TRUE
},
3846 { 1.5, PixelOffsetModeHalf
, image_150_half
, TRUE
},
3847 { 1.8, PixelOffsetModeHalf
, image_180
},
3848 { 2.0, PixelOffsetModeHalf
, image_200_half
, TRUE
},
3849 { 2.5, PixelOffsetModeHalf
, image_250_half
, TRUE
},
3851 { 0.8, PixelOffsetModeHighQuality
, image_080
}, /* 21 */
3852 { 1.0, PixelOffsetModeHighQuality
, image_100
},
3853 { 1.2, PixelOffsetModeHighQuality
, image_120_half
, TRUE
},
3854 { 1.5, PixelOffsetModeHighQuality
, image_150_half
, TRUE
},
3855 { 1.8, PixelOffsetModeHighQuality
, image_180
},
3856 { 2.0, PixelOffsetModeHighQuality
, image_200_half
, TRUE
},
3857 { 2.5, PixelOffsetModeHighQuality
, image_250_half
, TRUE
},
3859 BYTE src_2x1
[6] = { 0x80,0x80,0x80,0x80,0x80,0x80 };
3867 GpGraphics
*graphics
;
3871 status
= GdipCreateBitmapFromScan0(2, 1, 4, PixelFormat24bppRGB
, src_2x1
, &u1
.bitmap
);
3873 status
= GdipBitmapSetResolution(u1
.bitmap
, 100.0, 100.0);
3876 status
= GdipCreateBitmapFromScan0(8, 1, 24, PixelFormat24bppRGB
, dst_8x1
, &u2
.bitmap
);
3878 status
= GdipBitmapSetResolution(u2
.bitmap
, 100.0, 100.0);
3880 status
= GdipGetImageGraphicsContext(u2
.image
, &graphics
);
3882 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3885 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3887 status
= GdipSetPixelOffsetMode(graphics
, td
[i
].pixel_offset_mode
);
3890 status
= GdipCreateMatrix2(td
[i
].scale_x
, 0.0, 0.0, 1.0, 0.0, 0.0, &matrix
);
3892 status
= GdipSetWorldTransform(graphics
, matrix
);
3894 GdipDeleteMatrix(matrix
);
3896 memcpy(dst_8x1
, back_8x1
, sizeof(dst_8x1
));
3897 status
= GdipDrawImageI(graphics
, u1
.image
, 1, 0);
3900 match
= memcmp(dst_8x1
, td
[i
].image
, sizeof(dst_8x1
)) == 0;
3901 if (!match
&& td
[i
].todo
)
3902 todo_wine
ok(match
, "%d: data should match\n", i
);
3904 ok(match
, "%d: data should match\n", i
);
3907 UINT i
, size
= sizeof(dst_8x1
);
3908 const BYTE
*bits
= dst_8x1
;
3909 for (i
= 0; i
< size
; i
++)
3910 printf(" %02x", bits
[i
]);
3915 status
= GdipDeleteGraphics(graphics
);
3917 status
= GdipDisposeImage(u1
.image
);
3919 status
= GdipDisposeImage(u2
.image
);
3923 static const BYTE animatedgif
[] = {
3924 'G','I','F','8','9','a',0x01,0x00,0x01,0x00,0xA1,0x02,0x00,
3925 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,
3926 /*0x21,0xFF,0x0B,'A','N','I','M','E','X','T','S','1','.','0',*/
3927 0x21,0xFF,0x0B,'N','E','T','S','C','A','P','E','2','.','0',
3928 0x03,0x01,0x05,0x00,0x00,
3929 0x21,0xFE,0x0C,'H','e','l','l','o',' ','W','o','r','l','d','!',0x00,
3930 0x21,0x01,0x0D,'a','n','i','m','a','t','i','o','n','.','g','i','f',0x00,
3931 0x21,0xF9,0x04,0xff,0x0A,0x00,0x08,0x00,
3932 0x2C,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,
3933 0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,
3934 0x02,0x02,0x4C,0x01,0x00,
3935 0x21,0xFE,0x08,'i','m','a','g','e',' ','#','1',0x00,
3936 0x21,0x01,0x0C,'p','l','a','i','n','t','e','x','t',' ','#','1',0x00,
3937 0x21,0xF9,0x04,0x00,0x14,0x00,0x01,0x00,
3938 0x2C,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,
3939 0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,
3940 0x02,0x02,0x44,0x01,0x00,
3941 0x21,0xFE,0x08,'i','m','a','g','e',' ','#','2',0x00,
3942 0x21,0x01,0x0C,'p','l','a','i','n','t','e','x','t',' ','#','2',0x00,0x3B
3945 static void test_gif_properties(void)
3947 static const struct test_data
3949 ULONG type
, id
, length
;
3950 const BYTE value
[13];
3953 { PropertyTagTypeLong
, PropertyTagFrameDelay
, 8, { 10,0,0,0,20,0,0,0 } },
3954 { PropertyTagTypeASCII
, PropertyTagExifUserComment
, 13, { 'H','e','l','l','o',' ','W','o','r','l','d','!',0 } },
3955 { PropertyTagTypeShort
, PropertyTagLoopCount
, 2, { 5,0 } },
3956 { PropertyTagTypeByte
, PropertyTagGlobalPalette
, 12, { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c } },
3957 { PropertyTagTypeByte
, PropertyTagIndexBackground
, 1, { 2 } },
3958 { PropertyTagTypeByte
, PropertyTagIndexTransparent
, 1, { 8 } }
3963 UINT dim_count
, frame_count
, prop_count
, prop_size
, i
;
3964 UINT total_size
, total_count
;
3966 PropertyItem
*prop_item
;
3967 const char *item_data
;
3969 image
= load_image(animatedgif
, sizeof(animatedgif
));
3970 if (!image
) /* XP fails to load this GIF image */
3972 trace("Failed to load GIF image data\n");
3976 status
= GdipImageGetFrameDimensionsCount(image
, &dim_count
);
3978 expect(1, dim_count
);
3980 status
= GdipImageGetFrameDimensionsList(image
, &guid
, 1);
3982 expect_guid(&FrameDimensionTime
, &guid
, __LINE__
, FALSE
);
3984 status
= GdipImageGetFrameCount(image
, &guid
, &frame_count
);
3986 expect(2, frame_count
);
3988 status
= GdipImageSelectActiveFrame(image
, &guid
, 1);
3991 status
= GdipGetPropertyCount(image
, &prop_count
);
3994 ok(prop_count
== sizeof(td
)/sizeof(td
[0]) || broken(prop_count
== 1) /* before win7 */,
3995 "expected property count %u, got %u\n", (UINT
)(sizeof(td
)/sizeof(td
[0])), prop_count
);
3997 if (prop_count
!= sizeof(td
)/sizeof(td
[0]))
3999 GdipDisposeImage(image
);
4003 prop_id
= HeapAlloc(GetProcessHeap(), 0, prop_count
* sizeof(*prop_id
));
4005 status
= GdipGetPropertyIdList(image
, prop_count
, prop_id
);
4009 for (i
= 0; i
< prop_count
; i
++)
4012 status
= GdipGetPropertyItemSize(image
, prop_id
[i
], &size
);
4014 if (status
!= Ok
) break;
4015 ok(size
> sizeof(*prop_item
), "%u: too small item length %u\n", i
, size
);
4019 prop_item
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
4020 status
= GdipGetPropertyItem(image
, prop_id
[i
], size
, prop_item
);
4022 ok(prop_item
->value
== prop_item
+ 1, "expected item->value %p, got %p\n", prop_item
+ 1, prop_item
->value
);
4023 ok(td
[i
].type
== prop_item
->type
,
4024 "%u: expected type %u, got %u\n", i
, td
[i
].type
, prop_item
->type
);
4025 ok(td
[i
].id
== prop_item
->id
, "%u: expected id %#x, got %#x\n", i
, td
[i
].id
, prop_item
->id
);
4026 size
-= sizeof(*prop_item
);
4027 ok(prop_item
->length
== size
, "%u: expected length %u, got %u\n", i
, size
, prop_item
->length
);
4028 ok(td
[i
].length
== prop_item
->length
, "%u: expected length %u, got %u\n", i
, td
[i
].length
, prop_item
->length
);
4029 if (td
[i
].length
== prop_item
->length
)
4031 int match
= memcmp(td
[i
].value
, prop_item
->value
, td
[i
].length
) == 0;
4032 ok(match
, "%u: data mismatch\n", i
);
4036 BYTE
*data
= prop_item
->value
;
4037 printf("id %#x:", prop_item
->id
);
4038 for (j
= 0; j
< prop_item
->length
; j
++)
4039 printf(" %02x", data
[j
]);
4043 HeapFree(GetProcessHeap(), 0, prop_item
);
4046 HeapFree(GetProcessHeap(), 0, prop_id
);
4048 status
= GdipGetPropertySize(NULL
, &total_size
, &total_count
);
4049 expect(InvalidParameter
, status
);
4050 status
= GdipGetPropertySize(image
, &total_size
, NULL
);
4051 expect(InvalidParameter
, status
);
4052 status
= GdipGetPropertySize(image
, NULL
, &total_count
);
4053 expect(InvalidParameter
, status
);
4054 status
= GdipGetPropertySize(image
, NULL
, NULL
);
4055 expect(InvalidParameter
, status
);
4056 total_size
= 0xdeadbeef;
4057 total_count
= 0xdeadbeef;
4058 status
= GdipGetPropertySize(image
, &total_size
, &total_count
);
4060 ok(prop_count
== total_count
,
4061 "expected total property count %u, got %u\n", prop_count
, total_count
);
4062 ok(prop_size
== total_size
,
4063 "expected total property size %u, got %u\n", prop_size
, total_size
);
4065 prop_item
= HeapAlloc(GetProcessHeap(), 0, prop_size
);
4067 status
= GdipGetAllPropertyItems(image
, 0, prop_count
, prop_item
);
4068 expect(InvalidParameter
, status
);
4069 status
= GdipGetAllPropertyItems(image
, prop_size
, 1, prop_item
);
4070 expect(InvalidParameter
, status
);
4071 status
= GdipGetAllPropertyItems(image
, prop_size
, prop_count
, NULL
);
4072 expect(InvalidParameter
, status
);
4073 status
= GdipGetAllPropertyItems(image
, prop_size
, prop_count
, NULL
);
4074 expect(InvalidParameter
, status
);
4075 status
= GdipGetAllPropertyItems(image
, 0, 0, NULL
);
4076 expect(InvalidParameter
, status
);
4077 status
= GdipGetAllPropertyItems(image
, prop_size
+ 1, prop_count
, prop_item
);
4078 expect(InvalidParameter
, status
);
4079 status
= GdipGetAllPropertyItems(image
, prop_size
, prop_count
, prop_item
);
4082 item_data
= (const char *)(prop_item
+ prop_count
);
4083 for (i
= 0; i
< prop_count
; i
++)
4085 ok(prop_item
[i
].value
== item_data
, "%u: expected value %p, got %p\n",
4086 i
, item_data
, prop_item
[i
].value
);
4087 ok(td
[i
].type
== prop_item
[i
].type
,
4088 "%u: expected type %u, got %u\n", i
, td
[i
].type
, prop_item
[i
].type
);
4089 ok(td
[i
].id
== prop_item
[i
].id
, "%u: expected id %#x, got %#x\n", i
, td
[i
].id
, prop_item
[i
].id
);
4090 ok(td
[i
].length
== prop_item
[i
].length
, "%u: expected length %u, got %u\n", i
, td
[i
].length
, prop_item
[i
].length
);
4091 if (td
[i
].length
== prop_item
[i
].length
)
4093 int match
= memcmp(td
[i
].value
, prop_item
[i
].value
, td
[i
].length
) == 0;
4094 ok(match
, "%u: data mismatch\n", i
);
4098 BYTE
*data
= prop_item
[i
].value
;
4099 printf("id %#x:", prop_item
[i
].id
);
4100 for (j
= 0; j
< prop_item
[i
].length
; j
++)
4101 printf(" %02x", data
[j
]);
4105 item_data
+= prop_item
[i
].length
;
4108 HeapFree(GetProcessHeap(), 0, prop_item
);
4110 GdipDisposeImage(image
);
4115 struct GdiplusStartupInput gdiplusStartupInput
;
4116 ULONG_PTR gdiplusToken
;
4118 gdiplusStartupInput
.GdiplusVersion
= 1;
4119 gdiplusStartupInput
.DebugEventCallback
= NULL
;
4120 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
4121 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
4123 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
4125 test_DrawImage_scale();
4126 test_image_format();
4128 test_GdipDrawImagePointRect();
4130 test_tiff_palette();
4131 test_GdipGetAllPropertyItems();
4132 test_tiff_properties();
4133 test_gif_properties();
4134 test_image_properties();
4137 test_GetImageDimension();
4138 test_GdipImageGetFrameDimensionsCount();
4139 test_LoadingImages();
4140 test_SavingImages();
4143 test_LockBits_UserBuf();
4144 test_GdipCreateBitmapFromHBITMAP();
4145 test_GdipGetImageFlags();
4146 test_GdipCloneImage();
4149 test_getrawformat();
4151 test_createfromwmf();
4153 test_createhbitmap();
4154 test_getthumbnail();
4159 test_multiframegif();
4165 GdiplusShutdown(gdiplusToken
);