NtGdiCreateDIBSection will allocate a color table for 8bpp bitmap anyway and if biClrUsed isn't set, we will later fail any color lookup.
From: Rémi Bernon rbernon@codeweavers.com
NtGdiCreateDIBSection will allocate a color table for 8bpp bitmap anyway and if biClrUsed isn't set, we will later fail any color lookup.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57584 --- dlls/win32u/dce.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index d9c5f161385..23e67e3623e 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -526,6 +526,7 @@ static BOOL update_surface_shape( struct window_surface *surface, const RECT *re W32KAPI struct window_surface *window_surface_create( UINT size, const struct window_surface_funcs *funcs, HWND hwnd, const RECT *rect, BITMAPINFO *info, HBITMAP bitmap ) { + UINT usage = info->bmiHeader.biBitCount <= 8 ? DIB_PAL_COLORS : DIB_RGB_COLORS; struct window_surface *surface;
if (!(surface = calloc( 1, size ))) return NULL; @@ -538,7 +539,8 @@ W32KAPI struct window_surface *window_surface_create( UINT size, const struct wi surface->alpha_mask = 0; reset_bounds( &surface->bounds );
- if (!bitmap) bitmap = NtGdiCreateDIBSection( 0, NULL, 0, info, DIB_RGB_COLORS, 0, 0, 0, NULL ); + if (usage == DIB_PAL_COLORS) info->bmiHeader.biClrUsed = 1 << info->bmiHeader.biBitCount; + if (!bitmap) bitmap = NtGdiCreateDIBSection( 0, NULL, 0, info, usage, 0, 0, 0, NULL ); if (!(surface->color_bitmap = bitmap)) { free( surface );
Is there something wrong here? This is a very small corner case that's only used on X11 when host display is 8bpp or less. In addition, looking at the code I don't think creating a 8bpp bitmap without a color table is valid.
I don't see how DIB_PAL_COLORS can possibly work without a DC, and either way the caller needs to provide a BITMAPINFO with a valid color table.
Hmm right, I see... it possibly fixed the issue because the surface creation failed, sorry.