summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Massey <bart@cs.pdx.edu>2013-08-21 22:22:13 -0700
committerBart Massey <bart@cs.pdx.edu>2013-08-23 16:41:44 -0700
commit11483e141fbb5f6bedb3cb1957f9354ecf8cb48b (patch)
tree52da93ca728ac0e17f496c21dbd81734ebe385ca
parent8875ae01cda333edfccbfc683516b2e8b901f935 (diff)
downloadutil-image-11483e141fbb5f6bedb3cb1957f9354ecf8cb48b.tar.gz
Fixed get_image to handle xy format with nontrivial plane_mask.
Or at least made it work a little. There may still be many bugs here depending on endianness, size vs stride, etc.
-rw-r--r--image/xcb_image.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/image/xcb_image.c b/image/xcb_image.c
index 101aa4f..b09bfb9 100644
--- a/image/xcb_image.c
+++ b/image/xcb_image.c
@@ -325,25 +325,25 @@ xcb_image_get (xcb_connection_t * conn,
case XCB_IMAGE_FORMAT_XY_PIXMAP:
plane_mask &= xcb_mask(imrep->depth);
if (plane_mask != xcb_mask(imrep->depth)) {
- xcb_image_t * tmp_image =
- xcb_image_create_native(conn, width, height, format,
- imrep->depth, 0, 0, 0);
-
- if (!tmp_image) {
- free(imrep);
- return 0;
- }
-
int i;
uint32_t rpm = plane_mask;
- uint8_t * src_plane = image->data;
- uint8_t * dst_plane = tmp_image->data;
- uint32_t size = image->height * image->stride;
-
- if (tmp_image->bit_order == XCB_IMAGE_ORDER_MSB_FIRST)
+ uint32_t size;
+ uint8_t *src_plane = data;
+ uint8_t *dst_plane;
+
+ image = xcb_image_create_native(conn, width, height, format,
+ imrep->depth, 0, 0, 0);
+ if (!image) {
+ free(imrep);
+ return 0;
+ }
+ image->plane_mask = plane_mask;
+ size = image->height * image->stride;
+ dst_plane = image->data;
+ if (image->bit_order == XCB_IMAGE_ORDER_MSB_FIRST)
rpm = xcb_bit_reverse(plane_mask, imrep->depth);
for (i = 0; i < imrep->depth; i++) {
- if (rpm & 1) {
+ if (rpm & (1 << i)) {
memcpy(dst_plane, src_plane, size);
src_plane += size;
} else {
@@ -351,24 +351,22 @@ xcb_image_get (xcb_connection_t * conn,
}
dst_plane += size;
}
- tmp_image->plane_mask = plane_mask;
- image = tmp_image;
free(imrep);
break;
}
/* fall through */
case XCB_IMAGE_FORMAT_Z_PIXMAP:
image = xcb_image_create_native(conn, width, height, format,
- imrep->depth, imrep, bytes, data);
+ imrep->depth, imrep, bytes, data);
if (!image) {
- free(imrep);
- return 0;
+ free(imrep);
+ return 0;
}
+ assert(bytes == image->size);
break;
default:
assert(0);
}
- assert(bytes == image->size);
return image;
}