9
8
copy_n_rows (const GdkPixbuf *dest, const gint n,
10
9
const gint row_size, const gint offset)
12
guchar * const pixels = gdk_pixbuf_get_pixels (dest);
11
guchar *pixels = gdk_pixbuf_get_pixels (dest);
13
12
memcpy (pixels + offset, pixels, n * row_size);
46
filter_opacity (const GdkPixbuf *pbuf, const gfloat opacity)
49
gint x, y, rowstride, height;
51
data = gdk_pixbuf_get_pixels (pbuf);
53
rowstride = gdk_pixbuf_get_rowstride (pbuf);
54
height = gdk_pixbuf_get_height (pbuf);
55
for (x = 3; x < rowstride; x += 4) {
56
for (y = 0; y < height; y++) {
57
data[y * rowstride + x] *= opacity;
47
render_to_image (GtkImage *image, GdkPixbuf *pbuf, gint width, gint height,
48
gfloat opacity, gfloat saturation)
63
render_to_image (GtkImage *image, GdkPixbuf *pbuf,
64
const gint width, const gint height,
65
const gfloat opacity, const gfloat saturation)
62
79
filter_opacity (scaled, opacity);
64
81
/* set saturation */
65
filter_saturation (scaled, saturation);
82
gdk_pixbuf_saturate_and_pixelate (scaled, scaled, saturation, FALSE);
68
85
gtk_image_set_from_pixbuf (image, scaled);
106
123
render_background_fallback (GdkPixbuf *destination,
107
gint x, gint y, gint width, gint height)
124
const gint x, const gint y,
125
const gint width, const gint height)
113
XSetWindowAttributes attrs = { ParentRelative, 0L, 0, 0L, 0, 0, Always, 0L,
114
0L, False, ExposureMask, 0L, True, 0, 0 };
130
XSetWindowAttributes attrs = { ParentRelative, 0L, 0, 0L, 0, 0, Always,
131
0L, 0L, False, ExposureMask, 0L, True, 0, 0 };
117
133
/* create overrideredirect window with CopyFromParent at the desired place */
118
dpy = gdk_x11_get_default_xdisplay ();
119
screen = DefaultScreen (dpy);
120
src = XCreateWindow (dpy, RootWindow (dpy, screen), x, y,
134
dpy = gdk_x11_get_default_xdisplay ();
135
const gint screen = DefaultScreen (dpy);
136
const Window src = XCreateWindow (dpy, RootWindow (dpy, screen), x, y,
121
137
width, height, 0, CopyFromParent, CopyFromParent,
122
138
CopyFromParent, CWBackPixmap | CWBackingStore |
123
139
CWOverrideRedirect | CWEventMask,
148
164
glong wallpaper_id, gint x, gint y, gint width, gint height)
151
gint pwidth, pheight, sx, sy;
167
gint pwidth, pheight;
152
168
GdkColormap *cmap;
171
/* get root window */
172
const GdkWindow *rootwin = gdk_get_default_root_window ();
173
/* get colormap of root window */
174
cmap = gdk_drawable_get_colormap (GDK_DRAWABLE (rootwin));
156
175
/* get pixmap from X server */
157
176
pmap = gdk_pixmap_foreign_new ((GdkNativeWindow) wallpaper_id);
158
178
gdk_drawable_get_size (GDK_DRAWABLE (pmap), &pwidth, &pheight);
160
rootwin = gdk_get_default_root_window ();
161
cmap = gdk_drawable_get_colormap (GDK_DRAWABLE (rootwin));
163
180
/* tile wallpaper over pixbuf */
165
sy = - (y % pheight);
181
const gint sx = - (x % pwidth);
182
const gint sy = - (y % pheight);
166
183
for (x = sx; x < width; x += pwidth) {
167
184
for (y = sy; y < height; y += pheight) {
168
gint dstx = MAX (0, x);
169
gint dsty = MAX (0, y);
170
gint srcx = dstx - x;
171
gint srcy = dsty - y;
172
gint w = MIN (pwidth - srcx, width - dstx);
173
gint h = MIN (pheight - srcy, height - dsty);
185
const gint dstx = MAX (0, x);
186
const gint dsty = MAX (0, y);
187
const gint srcx = dstx - x;
188
const gint srcy = dsty - y;
189
const gint w = MIN (pwidth - srcx, width - dstx);
190
const gint h = MIN (pheight - srcy, height - dsty);
174
191
gdk_pixbuf_get_from_drawable (destination, pmap, cmap, srcx, srcy,
175
192
dstx, dsty, w, h);