--- rxvt-unicode/src/rxvtimg.C 2012/06/07 19:06:26 1.47 +++ rxvt-unicode/src/rxvtimg.C 2012/06/07 20:04:54 1.51 @@ -61,6 +61,8 @@ rxvt_img * rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb) { + Display *dpy = s->display->dpy; + int width = gdk_pixbuf_get_width (pb); int height = gdk_pixbuf_get_height (pb); @@ -77,16 +79,17 @@ xi.height = height; xi.xoffset = 0; xi.format = ZPixmap; - xi.byte_order = MSBFirst; // maybe go for host byte order, because servers are usually local? - xi.bitmap_unit = 32; - xi.bitmap_bit_order = MSBFirst; - xi.bitmap_pad = 32; + xi.byte_order = LSBFirst; // maybe go for host byte order, because servers are usually local? + xi.bitmap_unit = 32; //XY only, unused + xi.bitmap_bit_order = LSBFirst; //XY only, unused + xi.bitmap_pad = BitmapPad (dpy); xi.depth = depth; xi.bytes_per_line = 0; - xi.bits_per_pixel = 32; - xi.red_mask = 0x00ff0000; - xi.green_mask = 0x0000ff00; - xi.blue_mask = 0x000000ff; + xi.bits_per_pixel = 32; //Z only + xi.red_mask = 0x000000ff; //Z only + xi.green_mask = 0x0000ff00; //Z only + xi.blue_mask = 0x00ff0000; //Z only + xi.obdata = 0; // probbaly unused if (!XInitImage (&xi)) rxvt_fatal ("unable to initialise ximage, please report.\n"); @@ -104,38 +107,38 @@ for (int y = 0; y < height; y++) { - unsigned char r, g, b, a; - unsigned char *data = row; + unsigned char *src = row; + uint32_t *dst = (uint32_t *)line; if (depth == 24) for (int x = 0; x < width; x++) { - r = *data++; - g = *data++; - b = *data++; - *line++ = 0; - *line++ = r; - *line++ = g; - *line++ = b; + uint8_t r = *src++; + uint8_t g = *src++; + uint8_t b = *src++; + + uint32_t v = r | (g << 8) | (b << 16); + + if (ecb_big_endian ()) + v = ecb_bswap32 (v); + + *dst++ = v; } else for (int x = 0; x < width; x++) { - r = *data++; - g = *data++; - b = *data++; - a = *data++; - *line++ = a; - *line++ = r; - *line++ = g; - *line++ = b; + uint32_t v = *(uint32_t *)src; src += 4; + + if (ecb_big_endian ()) + v = ecb_bswap32 (v); + + *dst++ = v; } row += rowstride; + line += xi.bytes_per_line; } - Display *dpy = s->display->dpy; - rxvt_img *img = new rxvt_img (s, XRenderFindStandardFormat (dpy, depth == 24 ? PictStandardRGB24 : PictStandardARGB32), 0, 0, width, height); img->alloc ();