… | |
… | |
59 | } |
59 | } |
60 | |
60 | |
61 | rxvt_img * |
61 | rxvt_img * |
62 | rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb) |
62 | rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb) |
63 | { |
63 | { |
|
|
64 | Display *dpy = s->display->dpy; |
|
|
65 | |
64 | int width = gdk_pixbuf_get_width (pb); |
66 | int width = gdk_pixbuf_get_width (pb); |
65 | int height = gdk_pixbuf_get_height (pb); |
67 | int height = gdk_pixbuf_get_height (pb); |
66 | |
68 | |
67 | if (width > 32767 || height > 32767) // well, we *could* upload in chunks |
69 | if (width > 32767 || height > 32767) // well, we *could* upload in chunks |
68 | rxvt_fatal ("rxvt_img::new_from_pixbuf: image too big (maximum size 32768x32768).\n"); |
70 | rxvt_fatal ("rxvt_img::new_from_pixbuf: image too big (maximum size 32768x32768).\n"); |
… | |
… | |
78 | xi.xoffset = 0; |
80 | xi.xoffset = 0; |
79 | xi.format = ZPixmap; |
81 | xi.format = ZPixmap; |
80 | xi.byte_order = MSBFirst; // maybe go for host byte order, because servers are usually local? |
82 | xi.byte_order = MSBFirst; // maybe go for host byte order, because servers are usually local? |
81 | xi.bitmap_unit = 32; |
83 | xi.bitmap_unit = 32; |
82 | xi.bitmap_bit_order = MSBFirst; |
84 | xi.bitmap_bit_order = MSBFirst; |
83 | xi.bitmap_pad = 32; |
85 | xi.bitmap_pad = BitmapPad (dpy); |
84 | xi.depth = depth; |
86 | xi.depth = depth; |
85 | xi.bytes_per_line = 0; |
87 | xi.bytes_per_line = 0; |
86 | xi.bits_per_pixel = 32; |
88 | xi.bits_per_pixel = 32; |
87 | xi.red_mask = 0x00ff0000; |
89 | xi.red_mask = 0x00ff0000; |
88 | xi.green_mask = 0x0000ff00; |
90 | xi.green_mask = 0x0000ff00; |
… | |
… | |
119 | *line++ = b; |
121 | *line++ = b; |
120 | } |
122 | } |
121 | else |
123 | else |
122 | for (int x = 0; x < width; x++) |
124 | for (int x = 0; x < width; x++) |
123 | { |
125 | { |
124 | r = *data++; |
126 | uint32_t v = *(uint32_t *)data; data += 4; |
125 | g = *data++; |
127 | v = ecb_big_endian () ? ecb_rotr32 (v, 8) : ecb_rotl32 (v, 8); |
126 | b = *data++; |
128 | *(uint32_t *)line = x; line += 4; |
127 | a = *data++; |
|
|
128 | *line++ = a; |
|
|
129 | *line++ = r; |
|
|
130 | *line++ = g; |
|
|
131 | *line++ = b; |
|
|
132 | } |
129 | } |
133 | |
130 | |
134 | row += rowstride; |
131 | row += rowstride; |
135 | } |
132 | } |
136 | |
|
|
137 | Display *dpy = s->display->dpy; |
|
|
138 | |
133 | |
139 | rxvt_img *img = new rxvt_img (s, XRenderFindStandardFormat (dpy, depth == 24 ? PictStandardRGB24 : PictStandardARGB32), 0, 0, width, height); |
134 | rxvt_img *img = new rxvt_img (s, XRenderFindStandardFormat (dpy, depth == 24 ? PictStandardRGB24 : PictStandardARGB32), 0, 0, width, height); |
140 | img->alloc (); |
135 | img->alloc (); |
141 | |
136 | |
142 | GC gc = XCreateGC (dpy, img->pm, 0, 0); |
137 | GC gc = XCreateGC (dpy, img->pm, 0, 0); |