Signed-off-by: Jiajin Cui cuijiajin@uniontech.com
-- v2: user32: fix PNG cursor bitmap row alignment
From: Jiajin Cui cuijiajin@uniontech.com
Fixed bitmap row alignment calculation in PNG cursor loading to ensure proper 32-bit DWORD alignment. Changed rowbytes calculation from (width * bpp + 7) / 8 to (width * bpp + 31) / 32 * 4 for correct byte alignment. Also fixed mask_size calculation to use proper DWORD alignment. Removed the incorrect height doubling in biHeight field since the bitmap and mask are now properly aligned and don't require separate height allocation.
Signed-off-by: Jiajin Cui cuijiajin@uniontech.com --- dlls/user32/cursoricon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index 552504accc4..2fbd949f4f2 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -383,10 +383,10 @@ static BITMAPINFO *load_png(const char *png_data, DWORD *size) width = png_get_image_width(png_ptr, info_ptr); height = png_get_image_height(png_ptr, info_ptr);
- rowbytes = (width * bpp + 7) / 8; + rowbytes = (width * bpp + 31) / 32 * 4; image_size = height * rowbytes; if (bpp != 32) /* add a mask if there is no alpha */ - mask_size = (width + 7) / 8 * height; + mask_size = (width + 31) / 32 * 4 * height;
info = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(BITMAPINFOHEADER) + image_size + mask_size); if (!info) @@ -416,7 +416,7 @@ static BITMAPINFO *load_png(const char *png_data, DWORD *size)
info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); info->bmiHeader.biWidth = width; - info->bmiHeader.biHeight = height * 2; + info->bmiHeader.biHeight = height; info->bmiHeader.biPlanes = 1; info->bmiHeader.biBitCount = bpp; info->bmiHeader.biCompression = BI_RGB;