2 * Unit test suite for bitmaps
4 * Copyright 2004 Huw Davies
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "wine/test.h"
32 static void test_createdibitmap(void)
35 BITMAPINFOHEADER bmih;
37 HBITMAP hbm, hbm_colour, hbm_old;
41 screen_depth = GetDeviceCaps(hdc, BITSPIXEL);
42 memset(&bmih, 0, sizeof(bmih));
43 bmih.biSize = sizeof(bmih);
48 bmih.biCompression = BI_RGB;
50 /* First create an un-initialised bitmap. The depth of the bitmap
51 should match that of the hdc and not that supplied in bmih.
54 /* First try 32 bits */
55 hbm = CreateDIBitmap(hdc, &bmih, 0, NULL, NULL, 0);
56 ok(hbm != NULL, "CreateDIBitmap failed\n");
57 ok(GetObject(hbm, sizeof(bm), &bm), "GetObject failed\n");
59 ok(bm.bmBitsPixel == screen_depth, "CreateDIBitmap created bitmap of incorrect depth %d != %d\n", bm.bmBitsPixel, screen_depth);
64 hbm = CreateDIBitmap(hdc, &bmih, 0, NULL, NULL, 0);
65 ok(hbm != NULL, "CreateDIBitmap failed\n");
66 ok(GetObject(hbm, sizeof(bm), &bm), "GetObject failed\n");
68 ok(bm.bmBitsPixel == screen_depth, "CreateDIBitmap created bitmap of incorrect depth %d != %d\n", bm.bmBitsPixel, screen_depth);
73 hbm = CreateDIBitmap(hdc, &bmih, 0, NULL, NULL, 0);
74 ok(hbm != NULL, "CreateDIBitmap failed\n");
75 ok(GetObject(hbm, sizeof(bm), &bm), "GetObject failed\n");
77 ok(bm.bmBitsPixel == screen_depth, "CreateDIBitmap created bitmap of incorrect depth %d != %d\n", bm.bmBitsPixel, screen_depth);
80 /* Now with a monochrome dc we expect a monochrome bitmap */
81 hdcmem = CreateCompatibleDC(hdc);
83 /* First try 32 bits */
85 hbm = CreateDIBitmap(hdcmem, &bmih, 0, NULL, NULL, 0);
86 ok(hbm != NULL, "CreateDIBitmap failed\n");
87 ok(GetObject(hbm, sizeof(bm), &bm), "GetObject failed\n");
89 ok(bm.bmBitsPixel == 1, "CreateDIBitmap created bitmap of incorrect depth %d != %d\n", bm.bmBitsPixel, 1);
94 hbm = CreateDIBitmap(hdcmem, &bmih, 0, NULL, NULL, 0);
95 ok(hbm != NULL, "CreateDIBitmap failed\n");
96 ok(GetObject(hbm, sizeof(bm), &bm), "GetObject failed\n");
98 ok(bm.bmBitsPixel == 1, "CreateDIBitmap created bitmap of incorrect depth %d != %d\n", bm.bmBitsPixel, 1);
103 hbm = CreateDIBitmap(hdcmem, &bmih, 0, NULL, NULL, 0);
104 ok(hbm != NULL, "CreateDIBitmap failed\n");
105 ok(GetObject(hbm, sizeof(bm), &bm), "GetObject failed\n");
107 ok(bm.bmBitsPixel == 1, "CreateDIBitmap created bitmap of incorrect depth %d != %d\n", bm.bmBitsPixel, 1);
110 /* Now select a polychrome bitmap into the dc and we expect
111 screen_depth bitmaps again */
112 hbm_colour = CreateCompatibleBitmap(hdc, 1, 1);
113 hbm_old = SelectObject(hdcmem, hbm_colour);
115 /* First try 32 bits */
116 bmih.biBitCount = 32;
117 hbm = CreateDIBitmap(hdcmem, &bmih, 0, NULL, NULL, 0);
118 ok(hbm != NULL, "CreateDIBitmap failed\n");
119 ok(GetObject(hbm, sizeof(bm), &bm), "GetObject failed\n");
121 ok(bm.bmBitsPixel == screen_depth, "CreateDIBitmap created bitmap of incorrect depth %d != %d\n", bm.bmBitsPixel, screen_depth);
125 bmih.biBitCount = 16;
126 hbm = CreateDIBitmap(hdcmem, &bmih, 0, NULL, NULL, 0);
127 ok(hbm != NULL, "CreateDIBitmap failed\n");
128 ok(GetObject(hbm, sizeof(bm), &bm), "GetObject failed\n");
130 ok(bm.bmBitsPixel == screen_depth, "CreateDIBitmap created bitmap of incorrect depth %d != %d\n", bm.bmBitsPixel, screen_depth);
135 hbm = CreateDIBitmap(hdcmem, &bmih, 0, NULL, NULL, 0);
136 ok(hbm != NULL, "CreateDIBitmap failed\n");
137 ok(GetObject(hbm, sizeof(bm), &bm), "GetObject failed\n");
139 ok(bm.bmBitsPixel == screen_depth, "CreateDIBitmap created bitmap of incorrect depth %d != %d\n", bm.bmBitsPixel, screen_depth);
142 SelectObject(hdcmem, hbm_old);
143 DeleteObject(hbm_colour);
146 /* If hdc == 0 then we get a 1 bpp bitmap */
147 bmih.biBitCount = 32;
148 hbm = CreateDIBitmap(0, &bmih, 0, NULL, NULL, 0);
149 ok(hbm != NULL, "CreateDIBitmap failed\n");
150 ok(GetObject(hbm, sizeof(bm), &bm), "GetObject failed\n");
152 ok(bm.bmBitsPixel == 1, "CreateDIBitmap created bitmap of incorrect depth %d != %d\n", bm.bmBitsPixel, 1);
160 test_createdibitmap();