ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtimg.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtimg.C (file contents):
Revision 1.53 by root, Thu Jun 7 20:22:40 2012 UTC vs.
Revision 1.54 by root, Thu Jun 7 20:24:39 2012 UTC

71 71
72 // since we require rgb24/argb32 formats from xrender we assume 72 // since we require rgb24/argb32 formats from xrender we assume
73 // that both 24 and 32 bpp MUST be supported by any screen that supports xrender 73 // that both 24 and 32 bpp MUST be supported by any screen that supports xrender
74 int depth = gdk_pixbuf_get_has_alpha (pb) ? 32 : 24; 74 int depth = gdk_pixbuf_get_has_alpha (pb) ? 32 : 24;
75 75
76 int byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
77
76 XImage xi; 78 XImage xi;
77 79
78 xi.width = width; 80 xi.width = width;
79 xi.height = height; 81 xi.height = height;
80 xi.xoffset = 0; 82 xi.xoffset = 0;
81 xi.format = ZPixmap; 83 xi.format = ZPixmap;
82 xi.byte_order = LSBFirst; // maybe go for host byte order, because servers are usually local? 84 xi.byte_order = ImageByteOrder (dpy);
83 xi.bitmap_unit = 32; //XY only, unused 85 xi.bitmap_unit = 32; //XY only, unused
84 xi.bitmap_bit_order = LSBFirst; //XY only, unused 86 xi.bitmap_bit_order = LSBFirst; //XY only, unused
85 xi.bitmap_pad = BitmapPad (dpy); 87 xi.bitmap_pad = BitmapPad (dpy);
86 xi.depth = depth; 88 xi.depth = depth;
87 xi.bytes_per_line = 0; 89 xi.bytes_per_line = 0;
89 xi.red_mask = 0x00000000; //Z only, unused 91 xi.red_mask = 0x00000000; //Z only, unused
90 xi.green_mask = 0x00000000; //Z only, unused 92 xi.green_mask = 0x00000000; //Z only, unused
91 xi.blue_mask = 0x00000000; //Z only, unused 93 xi.blue_mask = 0x00000000; //Z only, unused
92 xi.obdata = 0; // probably unused 94 xi.obdata = 0; // probably unused
93 95
96 bool byte_order_mismatch = byte_order != xi.byte_order;
97
94 if (!XInitImage (&xi)) 98 if (!XInitImage (&xi))
95 rxvt_fatal ("unable to initialise ximage, please report.\n"); 99 rxvt_fatal ("unable to initialise ximage, please report.\n");
96 100
97 if (height > INT_MAX / xi.bytes_per_line) 101 if (height > INT_MAX / xi.bytes_per_line)
98 rxvt_fatal ("rxvt_img::new_from_pixbuf: image too big for Xlib.\n"); 102 rxvt_fatal ("rxvt_img::new_from_pixbuf: image too big for Xlib.\n");
120 uint32_t v = (r << 16) | (g << 8) | b; 124 uint32_t v = (r << 16) | (g << 8) | b;
121 125
122 if (ecb_big_endian ()) 126 if (ecb_big_endian ())
123 v = ecb_bswap32 (v); 127 v = ecb_bswap32 (v);
124 128
129 if (byte_order_mismatch)
130 v = ecb_bswap32 (v);
131
125 *dst++ = v; 132 *dst++ = v;
126 } 133 }
127 else 134 else
128 for (int x = 0; x < width; x++) 135 for (int x = 0; x < width; x++)
129 { 136 {
131 138
132 if (ecb_little_endian ()) 139 if (ecb_little_endian ())
133 v = ecb_bswap32 (v); 140 v = ecb_bswap32 (v);
134 141
135 v = ecb_rotr32 (v, 8); 142 v = ecb_rotr32 (v, 8);
143
144 if (byte_order_mismatch)
145 v = ecb_bswap32 (v);
136 146
137 *dst++ = v; 147 *dst++ = v;
138 } 148 }
139 149
140 row += rowstride; 150 row += rowstride;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines