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.50 by root, Thu Jun 7 19:42:09 2012 UTC vs.
Revision 1.55 by root, Thu Jun 7 20:26:21 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; 85 xi.bitmap_unit = 0; //XY only, unused
84 xi.bitmap_bit_order = LSBFirst; 86 xi.bitmap_bit_order = 0; //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;
88 xi.bits_per_pixel = 32; 90 xi.bits_per_pixel = 32; //Z only
89 xi.red_mask = 0x000000ff; 91 xi.red_mask = 0x00000000; //Z only, unused
90 xi.green_mask = 0x0000ff00; 92 xi.green_mask = 0x00000000; //Z only, unused
91 xi.blue_mask = 0x00ff0000; 93 xi.blue_mask = 0x00000000; //Z only, unused
94 xi.obdata = 0; // probably unused
95
96 bool byte_order_mismatch = byte_order != xi.byte_order;
92 97
93 if (!XInitImage (&xi)) 98 if (!XInitImage (&xi))
94 rxvt_fatal ("unable to initialise ximage, please report.\n"); 99 rxvt_fatal ("unable to initialise ximage, please report.\n");
95 100
96 if (height > INT_MAX / xi.bytes_per_line) 101 if (height > INT_MAX / xi.bytes_per_line)
114 { 119 {
115 uint8_t r = *src++; 120 uint8_t r = *src++;
116 uint8_t g = *src++; 121 uint8_t g = *src++;
117 uint8_t b = *src++; 122 uint8_t b = *src++;
118 123
119 uint32_t v = r | (g << 8) | (b << 16); 124 uint32_t v = (r << 16) | (g << 8) | b;
120 125
121 if (ecb_big_endian ()) 126 if (ecb_big_endian ())
122 v = ecb_bswap32 (v); 127 v = ecb_bswap32 (v);
123 128
129 if (byte_order_mismatch)
130 v = ecb_bswap32 (v);
131
124 *dst++ = x; 132 *dst++ = v;
125 } 133 }
126 else 134 else
127 for (int x = 0; x < width; x++) 135 for (int x = 0; x < width; x++)
128 { 136 {
129 uint32_t v = *(uint32_t *)src; src += 4; 137 uint32_t v = *(uint32_t *)src; src += 4;
130 v = ecb_big_endian () ? ecb_rotr32 (v, 8) : ecb_rotl32 (v, 8); 138
139 if (ecb_little_endian ())
131 *dst++ = ecb_bswap32 (v); 140 v = ecb_bswap32 (v);
141
142 v = ecb_rotr32 (v, 8);
143
144 if (byte_order_mismatch)
145 v = ecb_bswap32 (v);
146
147 *dst++ = v;
132 } 148 }
133 149
134 row += rowstride; 150 row += rowstride;
135 line += xi.bytes_per_line; 151 line += xi.bytes_per_line;
136 } 152 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines