2 * Unit test suite for images
4 * Copyright (C) 2007 Google (Evan Stade)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/test.h"
30 #define expect(expected, got) ok(((UINT)got) == ((UINT)expected), "Expected %.8x, got %.8x\n", (UINT)expected, (UINT)got)
31 #define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
33 static void expect_rawformat(REFGUID expected
, GpImage
*img
, int line
, BOOL todo
)
41 stat
= GdipGetImageRawFormat(img
, &raw
);
42 ok_(__FILE__
, line
)(stat
== Ok
, "GdipGetImageRawFormat failed with %d\n", stat
);
43 if(stat
!= Ok
) return;
44 StringFromGUID2(&raw
, bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]));
45 WideCharToMultiByte(CP_ACP
, 0, bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), buffer
, sizeof(buffer
), NULL
, NULL
);
46 StringFromGUID2(expected
, bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]));
47 WideCharToMultiByte(CP_ACP
, 0, bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), buffer2
, sizeof(buffer2
), NULL
, NULL
);
49 todo_wine
ok_(__FILE__
, line
)(IsEqualGUID(&raw
, expected
), "Expected format %s, got %s\n", buffer2
, buffer
);
51 ok_(__FILE__
, line
)(IsEqualGUID(&raw
, expected
), "Expected format %s, got %s\n", buffer2
, buffer
);
54 static void test_bufferrawformat(void* buff
, int size
, REFGUID expected
, int line
, BOOL todo
)
63 hglob
= GlobalAlloc (0, size
);
64 data
= GlobalLock (hglob
);
65 memcpy(data
, buff
, size
);
66 GlobalUnlock(hglob
); data
= NULL
;
68 hres
= CreateStreamOnHGlobal(hglob
, TRUE
, &stream
);
69 ok_(__FILE__
, line
)(hres
== S_OK
, "Failed to create a stream\n");
70 if(hres
!= S_OK
) return;
72 stat
= GdipCreateBitmapFromStream(stream
, &bmp
);
73 ok_(__FILE__
, line
)(stat
== Ok
, "Failed to create a Bitmap\n");
75 IStream_Release(stream
);
79 expect_rawformat(expected
, (GpImage
*)bmp
, line
, todo
);
81 GdipDisposeImage((GpImage
*)bmp
);
82 IStream_Release(stream
);
85 static void test_Scan0(void)
92 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bm
);
94 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
96 GdipDisposeImage((GpImage
*)bm
);
98 bm
= (GpBitmap
*)0xdeadbeef;
99 stat
= GdipCreateBitmapFromScan0(10, -10, 10, PixelFormat24bppRGB
, NULL
, &bm
);
100 expect(InvalidParameter
, stat
);
101 ok( !bm
, "expected null bitmap\n" );
103 bm
= (GpBitmap
*)0xdeadbeef;
104 stat
= GdipCreateBitmapFromScan0(-10, 10, 10, PixelFormat24bppRGB
, NULL
, &bm
);
105 expect(InvalidParameter
, stat
);
106 ok( !bm
, "expected null bitmap\n" );
108 bm
= (GpBitmap
*)0xdeadbeef;
109 stat
= GdipCreateBitmapFromScan0(10, 0, 10, PixelFormat24bppRGB
, NULL
, &bm
);
110 expect(InvalidParameter
, stat
);
111 ok( !bm
, "expected null bitmap\n" );
114 stat
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, buff
, &bm
);
116 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
118 GdipDisposeImage((GpImage
*)bm
);
120 bm
= (GpBitmap
*) 0xdeadbeef;
121 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, buff
, &bm
);
122 expect(InvalidParameter
, stat
);
123 ok( !bm
, "expected null bitmap\n" );
125 bm
= (GpBitmap
*)0xdeadbeef;
126 stat
= GdipCreateBitmapFromScan0(10, 10, 0, PixelFormat24bppRGB
, buff
, &bm
);
127 expect(InvalidParameter
, stat
);
128 ok( bm
== (GpBitmap
*)0xdeadbeef, "expected deadbeef bitmap\n" );
131 stat
= GdipCreateBitmapFromScan0(10, 10, -8, PixelFormat24bppRGB
, buff
, &bm
);
133 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
135 GdipDisposeImage((GpImage
*)bm
);
137 bm
= (GpBitmap
*)0xdeadbeef;
138 stat
= GdipCreateBitmapFromScan0(10, 10, -10, PixelFormat24bppRGB
, buff
, &bm
);
139 expect(InvalidParameter
, stat
);
140 ok( !bm
, "expected null bitmap\n" );
143 static void test_GetImageDimension(void)
147 const REAL WIDTH
= 10.0, HEIGHT
= 20.0;
150 bm
= (GpBitmap
*)0xdeadbeef;
151 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
,NULL
, &bm
);
153 ok((GpBitmap
*)0xdeadbeef != bm
, "Expected bitmap to not be 0xdeadbeef\n");
154 ok(NULL
!= bm
, "Expected bitmap to not be NULL\n");
156 stat
= GdipGetImageDimension(NULL
,&w
,&h
);
157 expect(InvalidParameter
, stat
);
159 stat
= GdipGetImageDimension((GpImage
*)bm
,NULL
,&h
);
160 expect(InvalidParameter
, stat
);
162 stat
= GdipGetImageDimension((GpImage
*)bm
,&w
,NULL
);
163 expect(InvalidParameter
, stat
);
167 stat
= GdipGetImageDimension((GpImage
*)bm
,&w
,&h
);
171 GdipDisposeImage((GpImage
*)bm
);
174 static void test_GdipImageGetFrameDimensionsCount(void)
178 const REAL WIDTH
= 10.0, HEIGHT
= 20.0;
181 bm
= (GpBitmap
*)0xdeadbeef;
182 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
,NULL
, &bm
);
184 ok((GpBitmap
*)0xdeadbeef != bm
, "Expected bitmap to not be 0xdeadbeef\n");
185 ok(NULL
!= bm
, "Expected bitmap to not be NULL\n");
187 stat
= GdipImageGetFrameDimensionsCount(NULL
,&w
);
188 expect(InvalidParameter
, stat
);
190 stat
= GdipImageGetFrameDimensionsCount((GpImage
*)bm
,NULL
);
191 expect(InvalidParameter
, stat
);
194 stat
= GdipImageGetFrameDimensionsCount((GpImage
*)bm
,&w
);
197 GdipDisposeImage((GpImage
*)bm
);
200 static void test_LoadingImages(void)
204 stat
= GdipCreateBitmapFromFile(0, 0);
205 expect(InvalidParameter
, stat
);
207 stat
= GdipCreateBitmapFromFile(0, (GpBitmap
**)0xdeadbeef);
208 expect(InvalidParameter
, stat
);
210 stat
= GdipLoadImageFromFile(0, 0);
211 expect(InvalidParameter
, stat
);
213 stat
= GdipLoadImageFromFile(0, (GpImage
**)0xdeadbeef);
214 expect(InvalidParameter
, stat
);
216 stat
= GdipLoadImageFromFileICM(0, 0);
217 expect(InvalidParameter
, stat
);
219 stat
= GdipLoadImageFromFileICM(0, (GpImage
**)0xdeadbeef);
220 expect(InvalidParameter
, stat
);
223 static void test_SavingImages(void)
229 const REAL WIDTH
= 10.0, HEIGHT
= 20.0;
231 ImageCodecInfo
*codecs
;
232 static const WCHAR filename
[] = { 'a','.','b','m','p',0 };
236 stat
= GdipSaveImageToFile(0, 0, 0, 0);
237 expect(InvalidParameter
, stat
);
240 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
246 stat
= GdipSaveImageToFile((GpImage
*)bm
, 0, 0, 0);
247 expect(InvalidParameter
, stat
);
249 stat
= GdipSaveImageToFile((GpImage
*)bm
, filename
, 0, 0);
250 expect(InvalidParameter
, stat
);
252 /* encoder tests should succeed -- already tested */
253 stat
= GdipGetImageEncodersSize(&n
, &s
);
254 if (stat
!= Ok
|| n
== 0) goto cleanup
;
256 codecs
= GdipAlloc(s
);
257 if (!codecs
) goto cleanup
;
259 stat
= GdipGetImageEncoders(n
, s
, codecs
);
260 if (stat
!= Ok
) goto cleanup
;
262 stat
= GdipSaveImageToFile((GpImage
*)bm
, filename
, &codecs
[0].Clsid
, 0);
265 GdipDisposeImage((GpImage
*)bm
);
268 /* re-load and check image stats */
269 stat
= GdipLoadImageFromFile(filename
, (GpImage
**)&bm
);
271 if (stat
!= Ok
) goto cleanup
;
273 stat
= GdipGetImageDimension((GpImage
*)bm
, &w
, &h
);
274 if (stat
!= Ok
) goto cleanup
;
282 GdipDisposeImage((GpImage
*)bm
);
283 ok(DeleteFileW(filename
), "Delete failed.\n");
286 static void test_encoders(void)
291 ImageCodecInfo
*codecs
;
295 static const WCHAR bmp_format
[] = {'B', 'M', 'P', 0};
297 stat
= GdipGetImageEncodersSize(&n
, &s
);
300 codecs
= GdipAlloc(s
);
304 stat
= GdipGetImageEncoders(n
, s
, NULL
);
305 expect(GenericError
, stat
);
307 stat
= GdipGetImageEncoders(0, s
, codecs
);
308 expect(GenericError
, stat
);
310 stat
= GdipGetImageEncoders(n
, s
-1, codecs
);
311 expect(GenericError
, stat
);
313 stat
= GdipGetImageEncoders(n
, s
+1, codecs
);
314 expect(GenericError
, stat
);
316 stat
= GdipGetImageEncoders(n
, s
, codecs
);
320 for (i
= 0; i
< n
; i
++)
322 if (CompareStringW(LOCALE_SYSTEM_DEFAULT
, 0,
323 codecs
[i
].FormatDescription
, -1,
324 bmp_format
, -1) == CSTR_EQUAL
) {
330 ok(FALSE
, "No BMP codec found.\n");
335 static void test_LockBits(void)
341 const INT WIDTH
= 10, HEIGHT
= 20;
344 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
353 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
357 stat
= GdipBitmapUnlockBits(bm
, &bd
);
361 /* read-only, with NULL rect -> whole bitmap lock */
362 stat
= GdipBitmapLockBits(bm
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
364 expect(bd
.Width
, WIDTH
);
365 expect(bd
.Height
, HEIGHT
);
368 stat
= GdipBitmapUnlockBits(bm
, &bd
);
372 /* read-only, consecutive */
373 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
377 stat
= GdipBitmapUnlockBits(bm
, &bd
);
381 stat
= GdipDisposeImage((GpImage
*)bm
);
383 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
387 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
389 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
390 expect(WrongState
, stat
);
392 stat
= GdipBitmapUnlockBits(bm
, &bd
);
395 stat
= GdipDisposeImage((GpImage
*)bm
);
397 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
400 /* write, no modification */
401 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeWrite
, PixelFormat24bppRGB
, &bd
);
405 stat
= GdipBitmapUnlockBits(bm
, &bd
);
409 /* write, consecutive */
410 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeWrite
, PixelFormat24bppRGB
, &bd
);
414 stat
= GdipBitmapUnlockBits(bm
, &bd
);
418 stat
= GdipDisposeImage((GpImage
*)bm
);
420 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
424 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeWrite
, PixelFormat24bppRGB
, &bd
);
429 ((char*)bd
.Scan0
)[2] = 0xff;
431 stat
= GdipBitmapUnlockBits(bm
, &bd
);
435 stat
= GdipDisposeImage((GpImage
*)bm
);
439 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
441 stat
= GdipBitmapLockBits(bm
, &rect
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
443 stat
= GdipDisposeImage((GpImage
*)bm
);
447 static void test_GdipCreateBitmapFromHBITMAP(void)
449 GpBitmap
* gpbm
= NULL
;
451 HPALETTE hpal
= NULL
;
454 LOGPALETTE
* LogPal
= NULL
;
456 const REAL WIDTH1
= 5;
457 const REAL HEIGHT1
= 15;
458 const REAL WIDTH2
= 10;
459 const REAL HEIGHT2
= 20;
463 stat
= GdipCreateBitmapFromHBITMAP(NULL
, NULL
, NULL
);
464 expect(InvalidParameter
, stat
);
466 hbm
= CreateBitmap(WIDTH1
, HEIGHT1
, 1, 1, NULL
);
467 stat
= GdipCreateBitmapFromHBITMAP(hbm
, NULL
, NULL
);
468 expect(InvalidParameter
, stat
);
470 stat
= GdipCreateBitmapFromHBITMAP(hbm
, NULL
, &gpbm
);
472 expect(Ok
, GdipGetImageDimension((GpImage
*) gpbm
, &width
, &height
));
473 expectf(WIDTH1
, width
);
474 expectf(HEIGHT1
, height
);
476 GdipDisposeImage((GpImage
*)gpbm
);
479 hbm
= CreateBitmap(WIDTH2
, HEIGHT2
, 1, 1, &buff
);
480 stat
= GdipCreateBitmapFromHBITMAP(hbm
, NULL
, &gpbm
);
483 expect_rawformat(&ImageFormatMemoryBMP
, (GpImage
*)gpbm
, __LINE__
, TRUE
);
485 expect(Ok
, GdipGetImageDimension((GpImage
*) gpbm
, &width
, &height
));
486 expectf(WIDTH2
, width
);
487 expectf(HEIGHT2
, height
);
489 GdipDisposeImage((GpImage
*)gpbm
);
492 hdc
= CreateCompatibleDC(0);
493 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
494 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
495 bmi
.bmiHeader
.biHeight
= HEIGHT1
;
496 bmi
.bmiHeader
.biWidth
= WIDTH1
;
497 bmi
.bmiHeader
.biBitCount
= 24;
498 bmi
.bmiHeader
.biPlanes
= 1;
499 bmi
.bmiHeader
.biCompression
= BI_RGB
;
501 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, NULL
, NULL
, 0);
502 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
504 stat
= GdipCreateBitmapFromHBITMAP(hbm
, NULL
, &gpbm
);
506 expect(Ok
, GdipGetImageDimension((GpImage
*) gpbm
, &width
, &height
));
507 expectf(WIDTH1
, width
);
508 expectf(HEIGHT1
, height
);
510 GdipDisposeImage((GpImage
*)gpbm
);
512 LogPal
= GdipAlloc(sizeof(LOGPALETTE
));
513 ok(LogPal
!= NULL
, "unable to allocate LOGPALETTE\n");
514 LogPal
->palVersion
= 0x300;
515 hpal
= CreatePalette(LogPal
);
516 ok(hpal
!= NULL
, "CreatePalette failed\n");
519 stat
= GdipCreateBitmapFromHBITMAP(hbm
, hpal
, &gpbm
);
525 GdipDisposeImage((GpImage
*)gpbm
);
531 static void test_GdipGetImageFlags(void)
537 img
= (GpImage
*)0xdeadbeef;
539 stat
= GdipGetImageFlags(NULL
, NULL
);
540 expect(InvalidParameter
, stat
);
542 stat
= GdipGetImageFlags(NULL
, &flags
);
543 expect(InvalidParameter
, stat
);
545 stat
= GdipGetImageFlags(img
, NULL
);
546 expect(InvalidParameter
, stat
);
549 static void test_GdipCloneImage(void)
555 GpImage
*image_src
, *image_dest
= NULL
;
556 const INT WIDTH
= 10, HEIGHT
= 20;
558 /* Create an image, clone it, delete the original, make sure the copy works */
559 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
, NULL
, &bm
);
561 expect_rawformat(&ImageFormatMemoryBMP
, (GpImage
*)bm
, __LINE__
, TRUE
);
563 image_src
= ((GpImage
*)bm
);
564 stat
= GdipCloneImage(image_src
, &image_dest
);
566 expect_rawformat(&ImageFormatMemoryBMP
, image_dest
, __LINE__
, TRUE
);
568 stat
= GdipDisposeImage((GpImage
*)bm
);
570 stat
= GdipGetImageBounds(image_dest
, &rectF
, &unit
);
573 /* Treat FP values carefully */
574 expectf((REAL
)WIDTH
, rectF
.Width
);
575 expectf((REAL
)HEIGHT
, rectF
.Height
);
577 stat
= GdipDisposeImage(image_dest
);
581 static void test_testcontrol(void)
587 stat
= GdipTestControl(TestControlGetBuildNumber
, ¶m
);
589 ok(param
!= 0, "Build number expected, got %u\n", param
);
592 static void test_fromhicon(void)
594 static const BYTE bmp_bits
[1024];
595 HBITMAP hbmMask
, hbmColor
;
599 GpBitmap
*bitmap
= NULL
;
605 stat
= GdipCreateBitmapFromHICON(NULL
, NULL
);
606 expect(InvalidParameter
, stat
);
607 stat
= GdipCreateBitmapFromHICON(NULL
, &bitmap
);
608 expect(InvalidParameter
, stat
);
610 /* color icon 1 bit */
611 hbmMask
= CreateBitmap(16, 16, 1, 1, bmp_bits
);
612 ok(hbmMask
!= 0, "CreateBitmap failed\n");
613 hbmColor
= CreateBitmap(16, 16, 1, 1, bmp_bits
);
614 ok(hbmColor
!= 0, "CreateBitmap failed\n");
618 info
.hbmMask
= hbmMask
;
619 info
.hbmColor
= hbmColor
;
620 hIcon
= CreateIconIndirect(&info
);
621 ok(hIcon
!= 0, "CreateIconIndirect failed\n");
622 DeleteObject(hbmMask
);
623 DeleteObject(hbmColor
);
625 stat
= GdipCreateBitmapFromHICON(hIcon
, &bitmap
);
628 /* check attributes */
629 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &dim
);
632 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &dim
);
635 stat
= GdipGetImageType((GpImage
*)bitmap
, &type
);
637 expect(ImageTypeBitmap
, type
);
638 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
639 expect(PixelFormat32bppARGB
, format
);
641 expect_rawformat(&ImageFormatMemoryBMP
, (GpImage
*)bitmap
, __LINE__
, TRUE
);
642 GdipDisposeImage((GpImage
*)bitmap
);
646 /* color icon 8 bpp */
647 hbmMask
= CreateBitmap(16, 16, 1, 8, bmp_bits
);
648 ok(hbmMask
!= 0, "CreateBitmap failed\n");
649 hbmColor
= CreateBitmap(16, 16, 1, 8, bmp_bits
);
650 ok(hbmColor
!= 0, "CreateBitmap failed\n");
654 info
.hbmMask
= hbmMask
;
655 info
.hbmColor
= hbmColor
;
656 hIcon
= CreateIconIndirect(&info
);
657 ok(hIcon
!= 0, "CreateIconIndirect failed\n");
658 DeleteObject(hbmMask
);
659 DeleteObject(hbmColor
);
661 stat
= GdipCreateBitmapFromHICON(hIcon
, &bitmap
);
664 /* check attributes */
665 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &dim
);
668 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &dim
);
671 stat
= GdipGetImageType((GpImage
*)bitmap
, &type
);
673 expect(ImageTypeBitmap
, type
);
674 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
675 expect(PixelFormat32bppARGB
, format
);
677 expect_rawformat(&ImageFormatMemoryBMP
, (GpImage
*)bitmap
, __LINE__
, TRUE
);
678 GdipDisposeImage((GpImage
*)bitmap
);
684 static const unsigned char pngimage
[285] = {
685 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
686 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,
687 0xde,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b,
688 0x13,0x01,0x00,0x9a,0x9c,0x18,0x00,0x00,0x00,0x07,0x74,0x49,0x4d,0x45,0x07,0xd5,
689 0x06,0x03,0x0f,0x07,0x2d,0x12,0x10,0xf0,0xfd,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,
690 0x54,0x08,0xd7,0x63,0xf8,0xff,0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,
691 0xe7,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
694 static const unsigned char gifimage
[35] = {
695 0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff,
696 0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
700 static const unsigned char bmpimage
[66] = {
701 0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
702 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
703 0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
704 0x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0x00,0x00,
708 static const unsigned char jpgimage
[285] = {
709 0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2c,
710 0x01,0x2c,0x00,0x00,0xff,0xdb,0x00,0x43,0x00,0x05,0x03,0x04,0x04,0x04,0x03,0x05,
711 0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x07,0x0c,0x08,0x07,0x07,0x07,0x07,0x0f,0x0b,
712 0x0b,0x09,0x0c,0x11,0x0f,0x12,0x12,0x11,0x0f,0x11,0x11,0x13,0x16,0x1c,0x17,0x13,
713 0x14,0x1a,0x15,0x11,0x11,0x18,0x21,0x18,0x1a,0x1d,0x1d,0x1f,0x1f,0x1f,0x13,0x17,
714 0x22,0x24,0x22,0x1e,0x24,0x1c,0x1e,0x1f,0x1e,0xff,0xdb,0x00,0x43,0x01,0x05,0x05,
715 0x05,0x07,0x06,0x07,0x0e,0x08,0x08,0x0e,0x1e,0x14,0x11,0x14,0x1e,0x1e,0x1e,0x1e,
716 0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
717 0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
718 0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0xff,0xc0,
719 0x00,0x11,0x08,0x00,0x01,0x00,0x01,0x03,0x01,0x22,0x00,0x02,0x11,0x01,0x03,0x11,
720 0x01,0xff,0xc4,0x00,0x15,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
721 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xff,0xc4,0x00,0x14,0x10,0x01,0x00,0x00,
722 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xc4,
723 0x00,0x14,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
724 0x00,0x00,0x00,0x00,0xff,0xc4,0x00,0x14,0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
725 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xda,0x00,0x0c,0x03,0x01,
726 0x00,0x02,0x11,0x03,0x11,0x00,0x3f,0x00,0xb2,0xc0,0x07,0xff,0xd9
728 static void test_getrawformat(void)
730 test_bufferrawformat((void*)pngimage
, sizeof(pngimage
), &ImageFormatPNG
, __LINE__
, TRUE
);
731 test_bufferrawformat((void*)gifimage
, sizeof(gifimage
), &ImageFormatGIF
, __LINE__
, TRUE
);
732 test_bufferrawformat((void*)bmpimage
, sizeof(bmpimage
), &ImageFormatBMP
, __LINE__
, FALSE
);
733 test_bufferrawformat((void*)jpgimage
, sizeof(jpgimage
), &ImageFormatJPEG
, __LINE__
, TRUE
);
738 struct GdiplusStartupInput gdiplusStartupInput
;
739 ULONG_PTR gdiplusToken
;
741 gdiplusStartupInput
.GdiplusVersion
= 1;
742 gdiplusStartupInput
.DebugEventCallback
= NULL
;
743 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
744 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
746 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
749 test_GetImageDimension();
750 test_GdipImageGetFrameDimensionsCount();
751 test_LoadingImages();
755 test_GdipCreateBitmapFromHBITMAP();
756 test_GdipGetImageFlags();
757 test_GdipCloneImage();
762 GdiplusShutdown(gdiplusToken
);