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 |
|
|
struct rxvt_img |
15 |
|
|
{ |
16 |
|
|
rxvt_screen *s; |
17 |
|
|
Pixmap pm; |
18 |
root |
1.15 |
int x, y, w, h, repeat; |
19 |
root |
1.1 |
XRenderPictFormat *format; |
20 |
root |
1.6 |
bool shared; // true if we don't own it |
21 |
root |
1.1 |
|
22 |
|
|
rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height); |
23 |
root |
1.3 |
rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); |
24 |
root |
1.5 |
static rxvt_img *new_from_root (rxvt_screen *s); // get root pixmap |
25 |
root |
1.6 |
static rxvt_img *new_from_file (rxvt_screen *s, const char *filename); // from pixbuf |
26 |
root |
1.4 |
|
27 |
root |
1.1 |
~rxvt_img (); |
28 |
|
|
|
29 |
|
|
Pixmap steal () |
30 |
|
|
{ |
31 |
root |
1.6 |
shared = true; |
32 |
|
|
return pm; |
33 |
root |
1.1 |
} |
34 |
|
|
|
35 |
|
|
// inplace |
36 |
root |
1.15 |
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 |
|
|
|
47 |
root |
1.8 |
void unshare (); // create a copy of the pixmap if !shared |
48 |
root |
1.1 |
void fill (const rxvt_color &c); |
49 |
sf-exg |
1.16 |
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 |
|
|
|
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 |
|
|
|
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 |
|
|
|
68 |
root |
1.9 |
bool render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y); |
69 |
root |
1.1 |
|
70 |
|
|
// copy |
71 |
sf-exg |
1.12 |
rxvt_img *blur (int rh, int rv); |
72 |
root |
1.8 |
rxvt_img *clone (); |
73 |
root |
1.15 |
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]); |
75 |
root |
1.1 |
rxvt_img *scale (int new_width, int new_height); |
76 |
root |
1.15 |
rxvt_img *rotate (int new_width, int new_height, int x, int y, double phi); |
77 |
root |
1.14 |
rxvt_img *convert_to (XRenderPictFormat *format, const rxvt_color &bg); |
78 |
sf-exg |
1.13 |
rxvt_img *blend (rxvt_img *img, double factor); |
79 |
root |
1.1 |
}; |
80 |
|
|
|
81 |
|
|
#endif |
82 |
|
|
|
83 |
|
|
#endif |
84 |
|
|
|