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.3 by root, Sun Jun 3 10:14:44 2012 UTC vs.
Revision 1.4 by root, Sun Jun 3 18:14:13 2012 UTC

2#include "rxvt.h" 2#include "rxvt.h"
3 3
4#if HAVE_IMG 4#if HAVE_IMG
5 5
6rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) 6rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height)
7: s(screen), w(width), h(height), format(format) 7: s(screen), w(width), h(height), format(format), shared(false)
8{ 8{
9 pm = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth); 9 pm = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth);
10} 10}
11 11
12rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap) 12rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap)
13: s(screen), pm(pixmap), w(width), h(height), format(format) 13: s(screen), pm(pixmap), w(width), h(height), format(format), shared(false)
14{ 14{
15}
16
17rxvt_img *
18rxvt_img::new_from_file (rxvt_screen *s, const char *filename)
19{
20 GError *err;
21 GdkPixbuf *pb = gdk_pixbuf_new_from_file (filename, &err);
22
23 if (!pb)
24 return 0;
25
26 int w = gdk_pixbuf_get_width (pb);
27 int h = gdk_pixbuf_get_height (pb);
28
29 rxvt_img *img = new rxvt_img (
30 s,
31 XRenderFindStandardFormat (s->display->dpy, gdk_pixbuf_get_has_alpha (pb) ? PictStandardARGB32 : PictStandardRGB24),
32 gdk_pixbuf_get_width (pb),
33 gdk_pixbuf_get_height (pb)
34 );
35
36 img->render (pb, 0, 0, w, h, 0, 0);
37
38 return img;
15} 39}
16 40
17rxvt_img::~rxvt_img () 41rxvt_img::~rxvt_img ()
18{ 42{
19 if (pm) 43 if (!shared)
20 XFreePixmap (s->display->dpy, pm); 44 XFreePixmap (s->display->dpy, pm);
21} 45}
22 46
23void 47void
24rxvt_img::fill (const rxvt_color &c) 48rxvt_img::fill (const rxvt_color &c)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines