1 |
#include "../config.h" |
2 |
#include "rxvt.h" |
3 |
|
4 |
#if HAVE_IMG |
5 |
|
6 |
rxvt_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 |
|
12 |
rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap) |
13 |
: s(screen), pm(pixmap), w(width), h(height), format(format), shared(false) |
14 |
{ |
15 |
} |
16 |
|
17 |
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 |
img->render (pb, 0, 0, img->w, img->h, 0, 0); |
34 |
|
35 |
return img; |
36 |
} |
37 |
|
38 |
rxvt_img::~rxvt_img () |
39 |
{ |
40 |
if (!shared) |
41 |
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 |
XFreeGC (s->display->dpy, gc); |
52 |
} |
53 |
|
54 |
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 |
{ |
69 |
//TODO |
70 |
} |
71 |
|
72 |
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 |
#endif |
103 |
|