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.49 by root, Thu Jun 7 19:24:13 2012 UTC vs.
Revision 1.52 by root, Thu Jun 7 20:20:35 2012 UTC

77 77
78 xi.width = width; 78 xi.width = width;
79 xi.height = height; 79 xi.height = height;
80 xi.xoffset = 0; 80 xi.xoffset = 0;
81 xi.format = ZPixmap; 81 xi.format = ZPixmap;
82 xi.byte_order = MSBFirst; // maybe go for host byte order, because servers are usually local? 82 xi.byte_order = LSBFirst; // maybe go for host byte order, because servers are usually local?
83 xi.bitmap_unit = 32; 83 xi.bitmap_unit = 32; //XY only, unused
84 xi.bitmap_bit_order = MSBFirst; 84 xi.bitmap_bit_order = LSBFirst; //XY only, unused
85 xi.bitmap_pad = BitmapPad (dpy); 85 xi.bitmap_pad = BitmapPad (dpy);
86 xi.depth = depth; 86 xi.depth = depth;
87 xi.bytes_per_line = 0; 87 xi.bytes_per_line = 0;
88 xi.bits_per_pixel = 32; 88 xi.bits_per_pixel = 32; //Z only
89 xi.red_mask = 0x00ff0000; 89 xi.red_mask = 0x00000000; //Z only, unused
90 xi.green_mask = 0x0000ff00; 90 xi.green_mask = 0x00000000; //Z only, unused
91 xi.blue_mask = 0x000000ff; 91 xi.blue_mask = 0x00000000; //Z only, unused
92 xi.obdata = 0; // probably unused
92 93
93 if (!XInitImage (&xi)) 94 if (!XInitImage (&xi))
94 rxvt_fatal ("unable to initialise ximage, please report.\n"); 95 rxvt_fatal ("unable to initialise ximage, please report.\n");
95 96
96 if (height > INT_MAX / xi.bytes_per_line) 97 if (height > INT_MAX / xi.bytes_per_line)
104 unsigned char *row = gdk_pixbuf_get_pixels (pb); 105 unsigned char *row = gdk_pixbuf_get_pixels (pb);
105 char *line = xi.data; 106 char *line = xi.data;
106 107
107 for (int y = 0; y < height; y++) 108 for (int y = 0; y < height; y++)
108 { 109 {
109 unsigned char r, g, b, a;
110 unsigned char *data = row; 110 unsigned char *src = row;
111 uint32_t *dst = (uint32_t *)line;
111 112
112 if (depth == 24) 113 if (depth == 24)
113 for (int x = 0; x < width; x++) 114 for (int x = 0; x < width; x++)
114 { 115 {
115 r = *data++; 116 uint8_t r = *src++;
116 g = *data++; 117 uint8_t g = *src++;
117 b = *data++; 118 uint8_t b = *src++;
119
120 uint32_t v = r | (g << 8) | (b << 16);
121
122 if (ecb_big_endian ())
123 v = ecb_bswap32 (v);
124
118 *line++ = 0; 125 *dst++ = v;
119 *line++ = r;
120 *line++ = g;
121 *line++ = b;
122 } 126 }
123 else 127 else
124 for (int x = 0; x < width; x++) 128 for (int x = 0; x < width; x++)
125 { 129 {
126 uint32_t v = *(uint32_t *)data; data += 4; 130 uint32_t v = *(uint32_t *)src; src += 4;
127 v = ecb_big_endian () ? ecb_rotr32 (v, 8) : ecb_rotl32 (v, 8); 131
128 *(uint32_t *)line = x; line += 4; 132 if (ecb_little_endian ())
133 v = ecb_bswap32 (v);
134
135 v = ecb_rotr32 (v, 8);
136
137 *dst++ = v;
129 } 138 }
130 139
131 row += rowstride; 140 row += rowstride;
141 line += xi.bytes_per_line;
132 } 142 }
133 143
134 rxvt_img *img = new rxvt_img (s, XRenderFindStandardFormat (dpy, depth == 24 ? PictStandardRGB24 : PictStandardARGB32), 0, 0, width, height); 144 rxvt_img *img = new rxvt_img (s, XRenderFindStandardFormat (dpy, depth == 24 ? PictStandardRGB24 : PictStandardARGB32), 0, 0, width, height);
135 img->alloc (); 145 img->alloc ();
136 146

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines