ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtimg.h
Revision: 1.17
Committed: Thu Jun 7 07:53:12 2012 UTC (11 years, 11 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.16: +14 -6 lines
Log Message:
preliminary recounting

File Contents

# User Rev Content
1 root 1.1 #ifndef IMG_H
2     #define IMG_H
3    
4 root 1.8 #if HAVE_BG_PIXMAP && BG_IMAGE_FROM_FILE && ENABLE_TRANSPARENCY && HAVE_PIXBUF
5 root 1.1 #define HAVE_IMG 1
6     #endif
7    
8     #if HAVE_IMG
9    
10 sf-exg 1.16 #define float_to_component(d) ((d) * 65535.99)
11    
12 root 1.1 #include <X11/extensions/Xrender.h>
13    
14 root 1.17 class rxvt_img
15 root 1.1 {
16 root 1.17 void alloc ();
17     void destroy ();
18    
19     public:
20 root 1.1 rxvt_screen *s;
21     Pixmap pm;
22 root 1.17 int *refcnt; // shared refcnt
23 root 1.15 int x, y, w, h, repeat;
24 root 1.1 XRenderPictFormat *format;
25    
26     rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height);
27 root 1.17 rxvt_img (const rxvt_img &img);
28    
29     //rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap);
30 root 1.5 static rxvt_img *new_from_root (rxvt_screen *s); // get root pixmap
31 root 1.6 static rxvt_img *new_from_file (rxvt_screen *s, const char *filename); // from pixbuf
32 root 1.4
33 root 1.1 ~rxvt_img ();
34    
35 root 1.17 // TODO: steal should not do what it does, and this todo should be more specific
36 root 1.1 Pixmap steal ()
37     {
38 root 1.17 Pixmap retval = pm;
39     pm = None;
40     return retval;
41 root 1.1 }
42    
43     // inplace
44 root 1.15 void move (int dx, int dy)
45     {
46     x += dx;
47     y += dy;
48     }
49    
50     void repeat_mode (int repeat)
51     {
52     this->repeat = repeat;
53     }
54    
55 root 1.17 void unshare (); // prepare for write
56 root 1.1 void fill (const rxvt_color &c);
57 sf-exg 1.16 void brightness (unsigned short r, unsigned short g, unsigned short b, unsigned short a);
58     void contrast (unsigned short r, unsigned short g, unsigned short b, unsigned short a);
59    
60     void brightness (double r, double g, double b, double a = 1.)
61     {
62     brightness (float_to_component (r),
63     float_to_component (g),
64     float_to_component (b),
65     float_to_component (a));
66     }
67    
68     void contrast (double r, double g, double b, double a = 1.)
69     {
70     contrast (float_to_component (r),
71     float_to_component (g),
72     float_to_component (b),
73     float_to_component (a));
74     }
75    
76 root 1.9 bool render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y);
77 root 1.1
78     // copy
79 sf-exg 1.12 rxvt_img *blur (int rh, int rv);
80 root 1.8 rxvt_img *clone ();
81 root 1.15 rxvt_img *sub_rect (int x, int y, int width, int height);
82     rxvt_img *transform (int new_width, int new_height, double matrix[9]);
83 root 1.1 rxvt_img *scale (int new_width, int new_height);
84 root 1.15 rxvt_img *rotate (int new_width, int new_height, int x, int y, double phi);
85 root 1.14 rxvt_img *convert_to (XRenderPictFormat *format, const rxvt_color &bg);
86 sf-exg 1.13 rxvt_img *blend (rxvt_img *img, double factor);
87 root 1.1 };
88    
89     #endif
90    
91     #endif
92