gdi32: CreateBitmapIndirect should ignore the provided
bm.bmWidthBytes
Dmitry Timoshkov
dmitry at codeweavers.com
Fri Feb 16 03:02:12 CST 2007
Hello,
Feng Yuan's book mentions an obscure fact that CreateBitmapIndirect ignores
the provided bm.bmWidthBytes and calculates it on its own. The test shows
that it's true.
Changelog:
gdi32: CreateBitmapIndirect should ignore the provided bm.bmWidthBytes.
---
dlls/gdi32/bitmap.c | 3 +++
dlls/gdi32/tests/bitmap.c | 14 ++++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c
index 22384de..e02a1f0 100644
--- a/dlls/gdi32/bitmap.c
+++ b/dlls/gdi32/bitmap.c
@@ -263,6 +263,9 @@ HBITMAP WINAPI CreateBitmapIndirect( const BITMAP *bmp )
return NULL;
}
+ /* Windows ignores the provided bm.bmWidthBytes */
+ bm.bmWidthBytes = BITMAP_GetWidthBytes( bm.bmWidth, bm.bmBitsPixel );
+
/* Create the BITMAPOBJ */
bmpobj = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC,
(HGDIOBJ *)&hbitmap, &bitmap_funcs );
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index ee4abc3..67f3e7c 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -1637,6 +1637,7 @@ static void test_mono_1x1_bmp_dbg(HBITMAP hbmp, int line)
static void test_CreateBitmap(void)
{
+ BITMAP bmp;
HDC screenDC = GetDC(0);
HDC hdc = CreateCompatibleDC(screenDC);
@@ -1684,6 +1685,19 @@ static void test_CreateBitmap(void)
DeleteDC(hdc);
ReleaseDC(0, screenDC);
+
+ /* show that Windows ignores the provided bm.bmWidthBytes */
+ bmp.bmType = 0;
+ bmp.bmWidth = 1;
+ bmp.bmHeight = 1;
+ bmp.bmWidthBytes = 28;
+ bmp.bmPlanes = 1;
+ bmp.bmBitsPixel = 1;
+ bmp.bmBits = NULL;
+ bm = CreateBitmapIndirect(&bmp);
+ ok(bm != 0, "CreateBitmapIndirect error %u\n", GetLastError());
+ test_mono_1x1_bmp(bm);
+ DeleteObject(bm);
}
START_TEST(bitmap)
--
1.5.0
More information about the wine-patches
mailing list