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.1 by root, Sun Jun 3 09:59:58 2012 UTC vs.
Revision 1.5 by root, Sun Jun 3 18:33:46 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{
15 argb = gdk_pixbuf_get_has_alpha (pixbuf); 20 GError *err;
16 depth = gdk_pixbuf_get_bits_per_sample (pixbuf); 21 GdkPixbuf *pb = gdk_pixbuf_new_from_file (filename, &err);
22
23 if (!pb)
24 return 0;
25
26 rxvt_img *img = new rxvt_img (
27 s,
28 XRenderFindStandardFormat (s->display->dpy, gdk_pixbuf_get_has_alpha (pb) ? PictStandardARGB32 : PictStandardRGB24),
29 gdk_pixbuf_get_width (pb),
30 gdk_pixbuf_get_height (pb)
31 );
32
33 img->render (pb, 0, 0, img->w, img->h, 0, 0);
34
35 return img;
17} 36}
18 37
19rxvt_img::~rxvt_img () 38rxvt_img::~rxvt_img ()
20{ 39{
21 if (pm) 40 if (!shared)
22 XFreePixmap (s->display->dpy, pm); 41 XFreePixmap (s->display->dpy, pm);
23} 42}
24 43
25void 44void
26rxvt_img::fill (const rxvt_color &c) 45rxvt_img::fill (const rxvt_color &c)
27{ 46{
28 XGCValues gcv; 47 XGCValues gcv;
29 gcv.foreground = c; 48 gcv.foreground = c;
30 GC gc = XCreateGC (s->display->dpy, pm, GCForeground, &gcv); 49 GC gc = XCreateGC (s->display->dpy, pm, GCForeground, &gcv);
31 XFillRectangle (s->display->dpy, pm, gc, 0, 0, w, h); 50 XFillRectangle (s->display->dpy, pm, gc, 0, 0, w, h);
51 XFreeGC (s->display->dpy, gc);
32} 52}
33 53
34rxvt_img *copy () 54void
55rxvt_img::blur (int rh, int rv)
35{ 56{
36 Pixmap pm2 = XCreatePixmap (s->display->dpy, pm, w, h, depth); 57 //TODO
37 XCopyArea (s->display->dpy, pm, pm2, 0, 0, w, h, 0, 0);
38 return new rxvt_img (s, pm2, format, w, h);
39} 58}
59
60void
61rxvt_img::brightness (double r, double g, double b, double a)
62{
63 //TODO
64}
65
66void
67rxvt_img::contrast (double r, double g, double b, double a)
68{
69 //TODO
70}
71
72void
73rxvt_img::render (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y)
74{
75 //TODO
76}
77
78rxvt_img *
79rxvt_img::copy ()
80{
81 GC gc = XCreateGC (s->display->dpy, pm, 0, 0);
82 Pixmap pm2 = XCreatePixmap (s->display->dpy, pm, w, h, format->depth);
83 XCopyArea (s->display->dpy, pm, pm2, gc, 0, 0, w, h, 0, 0);
84 XFreeGC (s->display->dpy, gc);
85 return new rxvt_img (s, format, w, h, pm2);
86}
87
88rxvt_img *
89rxvt_img::transform (int new_width, int new_height, double matrix[16])
90{
91 //TODO
92}
93
94rxvt_img *
95rxvt_img::scale (int new_width, int new_height)
96{
97 // use transform
98 //TODO
99}
100
40 101
41#endif 102#endif
42 103

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines