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.24 by sf-exg, Tue Jun 5 18:52:48 2012 UTC vs.
Revision 1.29 by root, Wed Jun 6 20:55:36 2012 UTC

65 gdk_pixbuf_get_height (pb) 65 gdk_pixbuf_get_height (pb)
66 ); 66 );
67 67
68 img->render_pixbuf (pb, 0, 0, img->w, img->h, 0, 0); 68 img->render_pixbuf (pb, 0, 0, img->w, img->h, 0, 0);
69 69
70 g_object_unref (pb);
71
70 return img; 72 return img;
71} 73}
72 74
73rxvt_img::~rxvt_img () 75rxvt_img::~rxvt_img ()
74{ 76{
291 293
292 int rowstride = gdk_pixbuf_get_rowstride (pixbuf); 294 int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
293 int channels = gdk_pixbuf_get_n_channels (pixbuf); 295 int channels = gdk_pixbuf_get_n_channels (pixbuf);
294 unsigned char *row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels; 296 unsigned char *row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels;
295 char *line = ximage->data; 297 char *line = ximage->data;
296
297 rgba c (0, 0, 0);
298
299 if (channels == 4 && alpha_mask == 0)
300 {
301 //pix_colors[Color_bg].get (c);
302 //TODO
303 c.r = 0xffff; c.g = 0xc0c0; c.b = 0xcbcb;//D
304 c.r >>= 8;
305 c.g >>= 8;
306 c.b >>= 8;
307 }
308 298
309 for (int y = 0; y < height; y++) 299 for (int y = 0; y < height; y++)
310 { 300 {
311 for (int x = 0; x < width; x++) 301 for (int x = 0; x < width; x++)
312 { 302 {
315 unsigned char r, g, b, a; 305 unsigned char r, g, b, a;
316 306
317 if (channels == 4) 307 if (channels == 4)
318 { 308 {
319 a = pixel[3]; 309 a = pixel[3];
320 r = (pixel[0] * a + c.r * (0xff - a)) / 0xff; 310 r = pixel[0] * a / 0xff;
321 g = (pixel[1] * a + c.g * (0xff - a)) / 0xff; 311 g = pixel[1] * a / 0xff;
322 b = (pixel[2] * a + c.b * (0xff - a)) / 0xff; 312 b = pixel[2] * a / 0xff;
323 } 313 }
324 else 314 else
325 { 315 {
326 a = 0xff; 316 a = 0xff;
327 r = pixel[0]; 317 r = pixel[0];
435 425
436 return transform (new_width, new_height, matrix, repeat); 426 return transform (new_width, new_height, matrix, repeat);
437} 427}
438 428
439rxvt_img * 429rxvt_img *
440rxvt_img::convert_to (XRenderPictFormat *new_format) 430rxvt_img::convert_to (XRenderPictFormat *new_format, const rxvt_color &bg)
441{ 431{
442 rxvt_img *img = new rxvt_img (s, new_format, w, h); 432 rxvt_img *img = new rxvt_img (s, new_format, w, h);
443 433
444 Display *dpy = s->display->dpy; 434 Display *dpy = s->display->dpy;
445 Picture src = XRenderCreatePicture (dpy, pm, format, 0, 0); 435 Picture src = XRenderCreatePicture (dpy, pm, format, 0, 0);
446 Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0); 436 Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0);
437 int op = PictOpSrc;
447 438
439 if (format->direct.alphaMask && !new_format->direct.alphaMask)
440 {
441 // does it have to be that complicated
442 rgba c;
443 bg.get (c);
444
445 XRenderColor rc = { c.r, c.g, c.b, 0xffff };
446 XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h);
447
448 op = PictOpOver;
449 }
450
448 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); 451 XRenderComposite (dpy, op, src, None, dst, 0, 0, 0, 0, 0, 0, w, h);
449 452
450 XRenderFreePicture (dpy, src); 453 XRenderFreePicture (dpy, src);
451 XRenderFreePicture (dpy, dst); 454 XRenderFreePicture (dpy, dst);
452 455
453 return img; 456 return img;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines