… | |
… | |
5 | #define HAVE_IMG 1 |
5 | #define HAVE_IMG 1 |
6 | #endif |
6 | #endif |
7 | |
7 | |
8 | #if HAVE_IMG |
8 | #if HAVE_IMG |
9 | |
9 | |
|
|
10 | #define float_to_component(d) ((d) * 65535.99) |
|
|
11 | |
10 | #include <X11/extensions/Xrender.h> |
12 | #include <X11/extensions/Xrender.h> |
11 | |
13 | |
12 | struct rxvt_img |
14 | struct rxvt_img |
13 | { |
15 | { |
14 | rxvt_screen *s; |
16 | rxvt_screen *s; |
15 | Pixmap pm; |
17 | Pixmap pm; |
16 | int w, h; |
18 | int x, y, w, h, repeat; |
17 | XRenderPictFormat *format; |
19 | XRenderPictFormat *format; |
18 | bool shared; // true if we don't own it |
20 | bool shared; // true if we don't own it |
19 | |
21 | |
20 | rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height); |
22 | rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height); |
21 | rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); |
23 | rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); |
… | |
… | |
29 | shared = true; |
31 | shared = true; |
30 | return pm; |
32 | return pm; |
31 | } |
33 | } |
32 | |
34 | |
33 | // inplace |
35 | // inplace |
|
|
36 | void move (int dx, int dy) |
|
|
37 | { |
|
|
38 | x += dx; |
|
|
39 | y += dy; |
|
|
40 | } |
|
|
41 | |
|
|
42 | void repeat_mode (int repeat) |
|
|
43 | { |
|
|
44 | this->repeat = repeat; |
|
|
45 | } |
|
|
46 | |
34 | void unshare (); // create a copy of the pixmap if !shared |
47 | void unshare (); // create a copy of the pixmap if !shared |
35 | void fill (const rxvt_color &c); |
48 | void fill (const rxvt_color &c); |
36 | void blur (int rh, int rv); |
49 | void brightness (unsigned short r, unsigned short g, unsigned short b, unsigned short a); |
|
|
50 | void contrast (unsigned short r, unsigned short g, unsigned short b, unsigned short a); |
|
|
51 | |
37 | void brightness (double r, double g, double b, double a = 1.); |
52 | void brightness (double r, double g, double b, double a = 1.) |
|
|
53 | { |
|
|
54 | brightness (float_to_component (r), |
|
|
55 | float_to_component (g), |
|
|
56 | float_to_component (b), |
|
|
57 | float_to_component (a)); |
|
|
58 | } |
|
|
59 | |
38 | void contrast (double r, double g, double b, double a = 1.); |
60 | void contrast (double r, double g, double b, double a = 1.) |
|
|
61 | { |
|
|
62 | contrast (float_to_component (r), |
|
|
63 | float_to_component (g), |
|
|
64 | float_to_component (b), |
|
|
65 | float_to_component (a)); |
|
|
66 | } |
|
|
67 | |
39 | void render (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y); |
68 | bool render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y); |
40 | |
69 | |
41 | // copy |
70 | // copy |
|
|
71 | rxvt_img *blur (int rh, int rv); |
42 | rxvt_img *clone (); |
72 | rxvt_img *clone (); |
|
|
73 | rxvt_img *sub_rect (int x, int y, int width, int height); |
|
|
74 | rxvt_img *transform (int new_width, int new_height, double matrix[9]); |
43 | rxvt_img *scale (int new_width, int new_height); |
75 | rxvt_img *scale (int new_width, int new_height); |
44 | rxvt_img *transform (int new_width, int new_height, int repeat, double matrix[9]); |
76 | rxvt_img *rotate (int new_width, int new_height, int x, int y, double phi); |
45 | rxvt_img *convert_to (XRenderPictFormat *format); |
77 | rxvt_img *convert_to (XRenderPictFormat *format, const rxvt_color &bg); |
|
|
78 | rxvt_img *blend (rxvt_img *img, double factor); |
46 | }; |
79 | }; |
47 | |
80 | |
48 | #endif |
81 | #endif |
49 | |
82 | |
50 | #endif |
83 | #endif |