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
23 #include "wine/test.h"
26 #define expect(expected, got) ok(((UINT)got) == ((UINT)expected), "Expected %.8x, got %.8x\n", (UINT)expected, (UINT)got)
28 static void test_Scan0(void)
35 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bm
);
37 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
39 GdipDisposeImage((GpImage
*)bm
);
41 bm
= (GpBitmap
*)0xdeadbeef;
42 stat
= GdipCreateBitmapFromScan0(10, -10, 10, PixelFormat24bppRGB
, NULL
, &bm
);
43 expect(InvalidParameter
, stat
);
47 bm
= (GpBitmap
*)0xdeadbeef;
48 stat
= GdipCreateBitmapFromScan0(-10, 10, 10, PixelFormat24bppRGB
, NULL
, &bm
);
49 expect(InvalidParameter
, stat
);
53 bm
= (GpBitmap
*)0xdeadbeef;
54 stat
= GdipCreateBitmapFromScan0(10, 0, 10, PixelFormat24bppRGB
, NULL
, &bm
);
55 expect(InvalidParameter
, stat
);
60 stat
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, buff
, &bm
);
62 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
64 GdipDisposeImage((GpImage
*)bm
);
66 bm
= (GpBitmap
*) 0xdeadbeef;
67 stat
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, buff
, &bm
);
68 expect(InvalidParameter
, stat
);
71 bm
= (GpBitmap
*)0xdeadbeef;
72 stat
= GdipCreateBitmapFromScan0(10, 10, 0, PixelFormat24bppRGB
, buff
, &bm
);
73 expect(InvalidParameter
, stat
);
74 expect(0xdeadbeef, bm
);
77 static void test_GetImageDimension(void)
81 const REAL WIDTH
= 10.0, HEIGHT
= 20.0;
84 bm
= (GpBitmap
*)0xdeadbeef;
85 stat
= GdipCreateBitmapFromScan0(WIDTH
, HEIGHT
, 0, PixelFormat24bppRGB
,NULL
, &bm
);
87 ok((GpBitmap
*)0xdeadbeef != bm
, "Expected bitmap to not be 0xdeadbeef\n");
88 ok(NULL
!= bm
, "Expected bitmap to not be NULL\n");
90 stat
= GdipGetImageDimension(NULL
,&w
,&h
);
91 expect(InvalidParameter
, stat
);
93 stat
= GdipGetImageDimension((GpImage
*)bm
,NULL
,&h
);
94 expect(InvalidParameter
, stat
);
96 stat
= GdipGetImageDimension((GpImage
*)bm
,&w
,NULL
);
97 expect(InvalidParameter
, stat
);
101 stat
= GdipGetImageDimension((GpImage
*)bm
,&w
,&h
);
103 ok(fabs(WIDTH
- w
) < 0.0001, "Width wrong");
104 ok(fabs(HEIGHT
- h
) < 0.0001, "Height wrong");
105 GdipDisposeImage((GpImage
*)bm
);
110 struct GdiplusStartupInput gdiplusStartupInput
;
111 ULONG_PTR gdiplusToken
;
113 gdiplusStartupInput
.GdiplusVersion
= 1;
114 gdiplusStartupInput
.DebugEventCallback
= NULL
;
115 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
116 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
118 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
121 test_GetImageDimension();
123 GdiplusShutdown(gdiplusToken
);