[Bug 42727] New: obsolete 128MB bitmap size limit
https://bugs.winehq.org/show_bug.cgi?id=42727 Bug ID: 42727 Summary: obsolete 128MB bitmap size limit Product: Wine Version: unspecified Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdi32 Assignee: wine-bugs(a)winehq.org Reporter: claude(a)mathr.co.uk Distribution: --- Created attachment 57708 --> https://bugs.winehq.org/attachment.cgi?id=57708 source code to probe supported bitmap size The current WINE bitmap implementation has a size limit of 128MiB dating back to 2008 with a comment about Windows XP: https://source.winehq.org/git/wine.git/blob/39935fe5ad889d537d828cc82771bdb9... 197 /* XP doesn't allow creating bitmaps larger than 128 MB */ 198 if (bm.bmHeight > 128 * 1024 * 1024 / bm.bmWidthBytes) 199 { 200 SetLastError( ERROR_NOT_ENOUGH_MEMORY ); 201 return 0; 202 } However, recent versions of Windows seem to have a higher limit, of 2GiB. Attached source code tries to create bitmaps with increasing sizes (each just under 2^N bytes) and prints successes and eventual failure. The bitmap test code seems to have a test for individual maximum dimension (width), but not for maximum total bitmap size: https://source.winehq.org/git/wine.git/blob/39935fe5ad889d537d828cc82771bdb9... Thanks for testing to users at http://www.fractalforums.com/windows-fractal-software/windows-bitmap-size-te... - I'll attach their results after submitting. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=42727 --- Comment #1 from Claude Heiland-Allen <claude(a)mathr.co.uk> --- Created attachment 57709 --> https://bugs.winehq.org/attachment.cgi?id=57709 test results -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=42727 --- Comment #2 from Claude Heiland-Allen <claude(a)mathr.co.uk> --- Created attachment 57710 --> https://bugs.winehq.org/attachment.cgi?id=57710 test results for wine-development 2.0-3 on Debian Stretch amd64 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=42727 --- Comment #3 from Claude Heiland-Allen <claude(a)mathr.co.uk> --- Created attachment 57711 --> https://bugs.winehq.org/attachment.cgi?id=57711 test results for Windows 10 Pro 64bit -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=42727 --- Comment #4 from Claude Heiland-Allen <claude(a)mathr.co.uk> --- Created attachment 57712 --> https://bugs.winehq.org/attachment.cgi?id=57712 test results for Windows 10 Pro 64bit running 32bit test -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=42727 --- Comment #5 from Claude Heiland-Allen <claude(a)mathr.co.uk> --- Created attachment 57713 --> https://bugs.winehq.org/attachment.cgi?id=57713 test results for Windows 7 Ultimate -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=42727 Claude Heiland-Allen <claude(a)mathr.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #57709|test results |test results for wine description| |1.8.6-5 on Debian Stretch | |amd64 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=42727 --- Comment #6 from Claude Heiland-Allen <claude(a)mathr.co.uk> --- Possible fix? /* Windows doesn't allow creating bitmaps larger than 2GiB */ if (bm.bmHeight >= 2LL * 1024 * 1024 * 1024 / bm.bmWidthBytes) { SetLastError( ERROR_NOT_ENOUGH_MEMORY ); return 0; } -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=42727 --- Comment #7 from Claude Heiland-Allen <claude(a)mathr.co.uk> --- here's a workaround, avoiding the code path with the bogus 128MB limit: #include <windows.h> // based on: https://source.winehq.org/git/wine.git/blob/39935fe5ad889d537d828cc82771bdb9... static inline long long get_bitmap_stride_ll(long long width, long long bpp) { return ((width * bpp + 15LL) >> 3LL) & ~1LL; } // workaround https://bugs.winehq.org/show_bug.cgi?id=42727 // "obsolete 128MB bitmap size limit" // see also: http://www.fractalforums.com/windows-fractal-software/windows-bitmap-size-te... HBITMAP create_bitmap(HDC hdc, int width, int height) { long long stride = get_bitmap_stride_ll(width, 24LL); long long bytes = stride * height; if (bytes >= 2LL * 1024LL * 1024LL * 1024LL || bytes <= 0LL) { return 0; } BITMAPINFO bmi; bmi.bmiHeader.biSize = sizeof(bmi); bmi.bmiHeader.biWidth = width; bmi.bmiHeader.biHeight = height; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 24; bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biSizeImage = bytes; bmi.bmiHeader.biXPelsPerMeter = 2835; // 72 dpi bmi.bmiHeader.biYPelsPerMeter = 2835; // 72 dpi bmi.bmiHeader.biClrUsed = 0; bmi.bmiHeader.biClrImportant = 0; return CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, 0, 0, 0); } -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
wine-bugs@winehq.org