x11_grab: Use correct depth when grabbing

Use queried drawable depth, not the context one.

Fixes grabbing of bitmaps (now using intended colormap) in the
usual 24 bit depth case.
May fix other issues as well(?).

Broken by 3ab9498777 (in v1.11.0).
This commit is contained in:
Kim Woelders 2023-09-21 07:14:34 +02:00
parent 3fd4347cfa
commit 1bd9920c07
3 changed files with 6 additions and 6 deletions

View File

@ -329,7 +329,8 @@ imlib_create_image_from_ximage(XImage * image, XImage * mask, int x, int y,
if (!im)
return NULL;
__imlib_GrabXImageToRGBA(&ctx->x11, im->data, 0, 0, width, height,
__imlib_GrabXImageToRGBA(&ctx->x11, image->depth, im->data,
0, 0, width, height,
image, mask, x, y, width, height, need_to_grab_x);
return im;
}

View File

@ -24,13 +24,13 @@ Tmp_HandleXError(Display * d, XErrorEvent * ev)
#define PTR(T, im_, y_) (T*)(void*)(im_->data + (im_->bytes_per_line * y_))
void
__imlib_GrabXImageToRGBA(const ImlibContextX11 * x11, uint32_t * data,
__imlib_GrabXImageToRGBA(const ImlibContextX11 * x11, int depth,
uint32_t * data,
int x_dst, int y_dst, int w_dst, int h_dst,
XImage * xim, XImage * mxim,
int x_src, int y_src, int w_src, int h_src, int grab)
{
int x, y, inx, iny;
int depth;
const uint32_t *src;
const uint16_t *s16;
uint32_t *ptr;
@ -58,7 +58,6 @@ __imlib_GrabXImageToRGBA(const ImlibContextX11 * x11, uint32_t * data,
/* go thru the XImage and convert */
depth = x11->depth;
if ((depth == 24) && (xim->bits_per_pixel == 32))
depth = 25; /* fake depth meaning 24 bit in 32 bpp ximage */
@ -814,7 +813,7 @@ __imlib_GrabDrawableToRGBA(const ImlibContextX11 * x11, uint32_t * data,
CLEAR(x_dst + w_src, w_dst, y_dst, y_dst + h_src);
}
__imlib_GrabXImageToRGBA(x11, data, x_dst, y_dst, w_dst, h_dst,
__imlib_GrabXImageToRGBA(x11, xatt.depth, data, x_dst, y_dst, w_dst, h_dst,
xim, mxim, x_src, y_src, w_src, h_src, 0);
/* destroy the Ximage */

View File

@ -26,7 +26,7 @@ int __imlib_GrabDrawableScaledToRGBA(const ImlibContextX11 *
bool clear);
void __imlib_GrabXImageToRGBA(const ImlibContextX11 * x11,
uint32_t * data,
int depth, uint32_t * data,
int x_dst, int y_dst,
int w_dst, int h_dst,
XImage * xim, XImage * mxim,