From: Fabian Maurer Subject: [PATCH v3 3/3] user32: For monochrome icon, write bits line by line This fixes a regression from db2b266c57b73e1a16785213ce923b749c84400e. Message-Id: <20210911183947.66609-3-dark.shadow4@web.de> Date: Sat, 11 Sep 2021 20:39:47 +0200 In-Reply-To: <20210911183947.66609-1-dark.shadow4@web.de> References: <20210911183947.66609-1-dark.shadow4@web.de> This is needed because we need to write bottom to top, and to avoid issues with line padding. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51296 Signed-off-by: Fabian Maurer --- dlls/user32/cursoricon.c | 11 +++++++++-- dlls/user32/tests/cursoricon.c | 9 ++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index cc7219f39d0..acd50724523 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -1559,6 +1559,9 @@ static HBITMAP create_masked_bitmap( int width, int height, const void *and, con { HDC dc = CreateCompatibleDC( 0 ); HBITMAP bitmap; + int line_size = width/8; + const char* and2 = (const char*)and; + const char* xor2 = (const char*)xor; char buffer[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 2] = {0}; BITMAPINFO *bitmap_info = (BITMAPINFO*)buffer; @@ -1572,8 +1575,12 @@ static HBITMAP create_masked_bitmap( int width, int height, const void *and, con bitmap_info->bmiColors[1].rgbBlue = 255; bitmap = CreateBitmap( width, height * 2, 1, 1, NULL ); - SetDIBits( dc, bitmap, 0, height, and, bitmap_info, FALSE ); - SetDIBits( dc, bitmap, height, height, xor, bitmap_info, FALSE ); + + for (int i = 0; i < height; i++) + { + SetDIBits( dc, bitmap, height - i - 1, 1, &xor2[i*line_size], bitmap_info, FALSE ); + SetDIBits( dc, bitmap, 2*height - i - 1, 1, &and2[i*line_size], bitmap_info, FALSE ); + } DeleteDC( dc ); return bitmap; } diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index 68e4f5320ff..31411bab330 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -3127,7 +3127,7 @@ static HBITMAP create_masked_bitmap( int width, int height, const void *and, con return bitmap; } -static void check_monochrome_icon(HICON icon, int draw_flag, int line, BOOL todo) +static void check_monochrome_icon(HICON icon, int draw_flag, int line) { HDC dc = CreateCompatibleDC(0); HBITMAP canvas = CreateCompatibleBitmap(dc, 32, 32); @@ -3140,7 +3140,6 @@ static void check_monochrome_icon(HICON icon, int draw_flag, int line, BOOL todo { COLORREF color = GetPixel(dc, i, 8); int expect = i % 2 == 0 ? 0 : 0xFFFFFF; - todo_wine_if(todo && (i%2 != 1)) ok_(__FILE__,line)(color == expect, "At index %d got %x\n", i, color); } DeleteObject(canvas); @@ -3165,17 +3164,17 @@ static void test_monochrome_icon_creation(void) cursor = CreateCursor(0, 8, 8, 16, 16, monochrome_bits, &monochrome_bits[32]); ok(cursor != NULL, "CreateCursor failed\n"); - check_monochrome_icon(cursor, DI_NORMAL, __LINE__, TRUE); + check_monochrome_icon(cursor, DI_NORMAL, __LINE__); DestroyCursor(cursor); icon = CreateIcon(0, 16, 16, 1, 1, monochrome_bits, &monochrome_bits[32]); ok(icon != NULL, "CreateIcon failed\n"); - check_monochrome_icon(icon, DI_NORMAL, __LINE__, TRUE); + check_monochrome_icon(icon, DI_NORMAL, __LINE__); DestroyIcon(icon); icon = CreateIconIndirect(&iconinfo); ok(icon != NULL, "CreateIconIndirect failed\n"); - check_monochrome_icon(icon, DI_NORMAL, __LINE__, FALSE); + check_monochrome_icon(icon, DI_NORMAL, __LINE__); DestroyIcon(icon); } -- 2.33.0