… | |
… | |
292 | int rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
292 | int rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
293 | int channels = gdk_pixbuf_get_n_channels (pixbuf); |
293 | int channels = gdk_pixbuf_get_n_channels (pixbuf); |
294 | 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; |
295 | char *line = ximage->data; |
295 | char *line = ximage->data; |
296 | |
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 | |
|
|
309 | for (int y = 0; y < height; y++) |
297 | for (int y = 0; y < height; y++) |
310 | { |
298 | { |
311 | for (int x = 0; x < width; x++) |
299 | for (int x = 0; x < width; x++) |
312 | { |
300 | { |
313 | unsigned char *pixel = row + x * channels; |
301 | unsigned char *pixel = row + x * channels; |
… | |
… | |
315 | unsigned char r, g, b, a; |
303 | unsigned char r, g, b, a; |
316 | |
304 | |
317 | if (channels == 4) |
305 | if (channels == 4) |
318 | { |
306 | { |
319 | a = pixel[3]; |
307 | a = pixel[3]; |
320 | r = (pixel[0] * a + c.r * (0xff - a)) / 0xff; |
308 | r = pixel[0] * a / 0xff; |
321 | g = (pixel[1] * a + c.g * (0xff - a)) / 0xff; |
309 | g = pixel[1] * a / 0xff; |
322 | b = (pixel[2] * a + c.b * (0xff - a)) / 0xff; |
310 | b = pixel[2] * a / 0xff; |
323 | } |
311 | } |
324 | else |
312 | else |
325 | { |
313 | { |
326 | a = 0xff; |
314 | a = 0xff; |
327 | r = pixel[0]; |
315 | r = pixel[0]; |
… | |
… | |
451 | XRenderFreePicture (dpy, dst); |
439 | XRenderFreePicture (dpy, dst); |
452 | |
440 | |
453 | return img; |
441 | return img; |
454 | } |
442 | } |
455 | |
443 | |
|
|
444 | rxvt_img * |
|
|
445 | rxvt_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 | |
456 | #endif |
470 | #endif |
457 | |
471 | |