push 014043c4937c940c54cd1214c96e33a3b3c8cf7d
[wine/hacks.git] / dlls / gdiplus / tests / image.c
blobd0959e525089dcb62b60f4be97ae9f61eec92f64
1 /*
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
21 #include "windows.h"
22 #include "gdiplus.h"
23 #include "wine/test.h"
24 #include <math.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)
30 GpBitmap *bm;
31 GpStatus stat;
32 BYTE buff[360];
34 bm = NULL;
35 stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB, NULL, &bm);
36 expect(Ok, stat);
37 ok(NULL != bm, "Expected bitmap to be initialized\n");
38 if (stat == Ok)
39 GdipDisposeImage((GpImage*)bm);
41 bm = (GpBitmap*)0xdeadbeef;
42 stat = GdipCreateBitmapFromScan0(10, -10, 10, PixelFormat24bppRGB, NULL, &bm);
43 expect(InvalidParameter, stat);
45 expect(NULL, bm);
47 bm = (GpBitmap*)0xdeadbeef;
48 stat = GdipCreateBitmapFromScan0(-10, 10, 10, PixelFormat24bppRGB, NULL, &bm);
49 expect(InvalidParameter, stat);
51 expect(NULL, bm);
53 bm = (GpBitmap*)0xdeadbeef;
54 stat = GdipCreateBitmapFromScan0(10, 0, 10, PixelFormat24bppRGB, NULL, &bm);
55 expect(InvalidParameter, stat);
57 expect(NULL, bm);
59 bm = NULL;
60 stat = GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB, buff, &bm);
61 expect(Ok, stat);
62 ok(NULL != bm, "Expected bitmap to be initialized\n");
63 if (stat == Ok)
64 GdipDisposeImage((GpImage*)bm);
66 bm = (GpBitmap*) 0xdeadbeef;
67 stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB, buff, &bm);
68 expect(InvalidParameter, stat);
69 expect(NULL, bm);
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)
79 GpBitmap *bm;
80 GpStatus stat;
81 const REAL WIDTH = 10.0, HEIGHT = 20.0;
82 REAL w,h;
84 bm = (GpBitmap*)0xdeadbeef;
85 stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB,NULL, &bm);
86 expect(Ok,stat);
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);
99 w = -1;
100 h = -1;
101 stat = GdipGetImageDimension((GpImage*)bm,&w,&h);
102 expect(Ok, stat);
103 ok(fabs(WIDTH - w) < 0.0001, "Width wrong");
104 ok(fabs(HEIGHT - h) < 0.0001, "Height wrong");
105 GdipDisposeImage((GpImage*)bm);
108 START_TEST(image)
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);
120 test_Scan0();
121 test_GetImageDimension();
123 GdiplusShutdown(gdiplusToken);