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

1#include "../config.h" 1#include "../config.h"
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, Pixmap *pm, 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), shared(false)
8{
9 pm = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth);
10}
11
12rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap)
7: s(screen), pm(pixmap) w(width), h(height), format(format) 13: s(screen), pm(pixmap), w(width), h(height), format(format), shared(false)
8{ 14{
9} 15}
10 16
11rxvt_img::rxvt_img (rxvt_screen *screen, GdkPixbuf *pixbuf, 17rxvt_img *
12 int x, int y, int width, int height) 18rxvt_img::new_from_file (rxvt_screen *s, const char *filename)
13: s(screen), w(width), h(height)
14{ 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)
25{ 49{
26 XGCValues gcv; 50 XGCValues gcv;
27 gcv.foreground = c; 51 gcv.foreground = c;
28 GC gc = XCreateGC (s->display->dpy, pm, GCForeground, &gcv); 52 GC gc = XCreateGC (s->display->dpy, pm, GCForeground, &gcv);
29 XFillRectangle (s->display->dpy, pm, gc, 0, 0, w, h); 53 XFillRectangle (s->display->dpy, pm, gc, 0, 0, w, h);
54 XFreeGC (s->display->dpy, gc);
30} 55}
31 56
32rxvt_img *copy () 57void
58rxvt_img::blur (int rh, int rv)
33{ 59{
34 Pixmap pm2 = XCreatePixmap (s->display->dpy, pm, w, h, depth); 60 //TODO
35 XCopyArea (s->display->dpy, pm, pm2, 0, 0, w, h, 0, 0);
36 return new rxvt_img (s, pm2, format, w, h);
37} 61}
62
63void
64rxvt_img::brightness (double r, double g, double b, double a)
65{
66 //TODO
67}
68
69void
70rxvt_img::contrast (double r, double g, double b, double a)
71{
72 //TODO
73}
74
75void
76rxvt_img::render (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y)
77{
78 //TODO
79}
80
81rxvt_img *
82rxvt_img::copy ()
83{
84 GC gc = XCreateGC (s->display->dpy, pm, 0, 0);
85 Pixmap pm2 = XCreatePixmap (s->display->dpy, pm, w, h, format->depth);
86 XCopyArea (s->display->dpy, pm, pm2, gc, 0, 0, w, h, 0, 0);
87 XFreeGC (s->display->dpy, gc);
88 return new rxvt_img (s, format, w, h, pm2);
89}
90
91rxvt_img *
92rxvt_img::transform (int new_width, int new_height, double matrix[16])
93{
94 //TODO
95}
96
97rxvt_img *
98rxvt_img::scale (int new_width, int new_height)
99{
100 // use transform
101 //TODO
102}
103
38 104
39#endif 105#endif
40 106

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines