ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtimg.C
Revision: 1.5
Committed: Sun Jun 3 18:33:46 2012 UTC (11 years, 11 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.4: +1 -4 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #include "../config.h"
2     #include "rxvt.h"
3    
4     #if HAVE_IMG
5    
6 root 1.3 rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height)
7 root 1.4 : s(screen), w(width), h(height), format(format), shared(false)
8 root 1.1 {
9 root 1.3 pm = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth);
10 root 1.1 }
11    
12 root 1.3 rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap)
13 root 1.4 : s(screen), pm(pixmap), w(width), h(height), format(format), shared(false)
14 root 1.1 {
15     }
16    
17 root 1.4 rxvt_img *
18     rxvt_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     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 root 1.5 img->render (pb, 0, 0, img->w, img->h, 0, 0);
34 root 1.4
35     return img;
36     }
37    
38 root 1.1 rxvt_img::~rxvt_img ()
39     {
40 root 1.4 if (!shared)
41 root 1.1 XFreePixmap (s->display->dpy, pm);
42     }
43    
44     void
45     rxvt_img::fill (const rxvt_color &c)
46     {
47     XGCValues gcv;
48     gcv.foreground = c;
49     GC gc = XCreateGC (s->display->dpy, pm, GCForeground, &gcv);
50     XFillRectangle (s->display->dpy, pm, gc, 0, 0, w, h);
51 root 1.3 XFreeGC (s->display->dpy, gc);
52 root 1.1 }
53    
54 root 1.3 void
55     rxvt_img::blur (int rh, int rv)
56     {
57     //TODO
58     }
59    
60     void
61     rxvt_img::brightness (double r, double g, double b, double a)
62     {
63     //TODO
64     }
65    
66     void
67     rxvt_img::contrast (double r, double g, double b, double a)
68 root 1.1 {
69 root 1.3 //TODO
70 root 1.1 }
71    
72 root 1.3 void
73     rxvt_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    
78     rxvt_img *
79     rxvt_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    
88     rxvt_img *
89     rxvt_img::transform (int new_width, int new_height, double matrix[16])
90     {
91     //TODO
92     }
93    
94     rxvt_img *
95     rxvt_img::scale (int new_width, int new_height)
96     {
97     // use transform
98     //TODO
99     }
100    
101    
102 root 1.1 #endif
103