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.22 by sf-exg, Tue Jun 5 15:18:23 2012 UTC vs.
Revision 1.25 by sf-exg, Tue Jun 5 22:00:15 2012 UTC

212 mask_c.blue = float_to_component (b); 212 mask_c.blue = float_to_component (b);
213 mask_c.alpha = float_to_component (a); 213 mask_c.alpha = float_to_component (a);
214 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1); 214 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1);
215 215
216 XRenderComposite (dpy, PictOpAdd, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); 216 XRenderComposite (dpy, PictOpAdd, src, None, dst, 0, 0, 0, 0, 0, 0, w, h);
217
218 XRenderFreePicture (dpy, src);
219 XRenderFreePicture (dpy, dst);
217} 220}
218 221
219void 222void
220rxvt_img::contrast (double r, double g, double b, double a) 223rxvt_img::contrast (double r, double g, double b, double a)
221{ 224{
232 mask_c.blue = float_to_component (b); 235 mask_c.blue = float_to_component (b);
233 mask_c.alpha = float_to_component (a); 236 mask_c.alpha = float_to_component (a);
234 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1); 237 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1);
235 238
236 XRenderComposite (dpy, PictOpMultiply, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); 239 XRenderComposite (dpy, PictOpMultiply, src, None, dst, 0, 0, 0, 0, 0, 0, w, h);
240
241 XRenderFreePicture (dpy, src);
242 XRenderFreePicture (dpy, dst);
237} 243}
238 244
239bool 245bool
240rxvt_img::render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y) 246rxvt_img::render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y)
241{ 247{
285 291
286 int rowstride = gdk_pixbuf_get_rowstride (pixbuf); 292 int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
287 int channels = gdk_pixbuf_get_n_channels (pixbuf); 293 int channels = gdk_pixbuf_get_n_channels (pixbuf);
288 unsigned char *row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels; 294 unsigned char *row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels;
289 char *line = ximage->data; 295 char *line = ximage->data;
290
291 rgba c (0, 0, 0);
292
293 if (channels == 4 && alpha_mask == 0)
294 {
295 //pix_colors[Color_bg].get (c);
296 //TODO
297 c.r = 0xffff; c.g = 0xc0c0; c.b = 0xcbcb;//D
298 c.r >>= 8;
299 c.g >>= 8;
300 c.b >>= 8;
301 }
302 296
303 for (int y = 0; y < height; y++) 297 for (int y = 0; y < height; y++)
304 { 298 {
305 for (int x = 0; x < width; x++) 299 for (int x = 0; x < width; x++)
306 { 300 {
309 unsigned char r, g, b, a; 303 unsigned char r, g, b, a;
310 304
311 if (channels == 4) 305 if (channels == 4)
312 { 306 {
313 a = pixel[3]; 307 a = pixel[3];
314 r = (pixel[0] * a + c.r * (0xff - a)) / 0xff; 308 r = pixel[0] * a / 0xff;
315 g = (pixel[1] * a + c.g * (0xff - a)) / 0xff; 309 g = pixel[1] * a / 0xff;
316 b = (pixel[2] * a + c.b * (0xff - a)) / 0xff; 310 b = pixel[2] * a / 0xff;
317 } 311 }
318 else 312 else
319 { 313 {
320 a = 0xff; 314 a = 0xff;
321 r = pixel[0]; 315 r = pixel[0];
445 XRenderFreePicture (dpy, dst); 439 XRenderFreePicture (dpy, dst);
446 440
447 return img; 441 return img;
448} 442}
449 443
444rxvt_img *
445rxvt_img::blend (rxvt_img *img, double factor)
446{
447 rxvt_img *img2 = clone ();
448 Display *dpy = s->display->dpy;
449 Picture src = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0);
450 Picture dst = XRenderCreatePicture (dpy, img2->pm, img2->format, 0, 0);
451 Picture mask = create_xrender_mask (dpy, img->pm, False);
452
453 XRenderColor mask_c;
454
455 mask_c.alpha = float_to_component (factor);
456 mask_c.red =
457 mask_c.green =
458 mask_c.blue = 0;
459 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1);
460
461 XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, w, h);
462
463 XRenderFreePicture (dpy, src);
464 XRenderFreePicture (dpy, dst);
465 XRenderFreePicture (dpy, mask);
466
467 return img2;
468}
469
450#endif 470#endif
451 471

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines