Do not use imlib2 for taking screenshot (issue #574)
This commit is contained in:
parent
14716d41b9
commit
dcc163ec0b
1 changed files with 27 additions and 23 deletions
50
src/tint.c
50
src/tint.c
|
@ -567,38 +567,42 @@ void get_snapshot(const char *path)
|
||||||
|
|
||||||
XSync(server.display, False);
|
XSync(server.display, False);
|
||||||
|
|
||||||
DATA32 *pixels = calloc(panel->area.width * panel->area.height, sizeof(DATA32));
|
Imlib_Image img = NULL;
|
||||||
XImage *ximg =
|
XImage *ximg =
|
||||||
XGetImage(server.display, panel->temp_pmap, 0, 0, panel->area.width, panel->area.height, AllPlanes, ZPixmap);
|
XGetImage(server.display, panel->temp_pmap, 0, 0, panel->area.width, panel->area.height, AllPlanes, ZPixmap);
|
||||||
|
|
||||||
for (int x = 0; x < panel->area.width; x++) {
|
if (ximg) {
|
||||||
for (int y = 0; y < panel->area.height; y++) {
|
DATA32 *pixels = calloc(panel->area.width * panel->area.height, sizeof(DATA32));
|
||||||
DATA32 xpixel = XGetPixel(ximg, x, y);
|
for (int x = 0; x < panel->area.width; x++) {
|
||||||
|
for (int y = 0; y < panel->area.height; y++) {
|
||||||
|
DATA32 xpixel = XGetPixel(ximg, x, y);
|
||||||
|
|
||||||
DATA32 r = (xpixel >> 16) & 0xff;
|
DATA32 r = (xpixel >> 16) & 0xff;
|
||||||
DATA32 g = (xpixel >> 8) & 0xff;
|
DATA32 g = (xpixel >> 8) & 0xff;
|
||||||
DATA32 b = (xpixel >> 0) & 0xff;
|
DATA32 b = (xpixel >> 0) & 0xff;
|
||||||
DATA32 a = 0x0;
|
DATA32 a = 0x0;
|
||||||
|
|
||||||
DATA32 argb = (a << 24) | (r << 16) | (g << 8) | b;
|
DATA32 argb = (a << 24) | (r << 16) | (g << 8) | b;
|
||||||
pixels[y * panel->area.width + x] = argb;
|
pixels[y * panel->area.width + x] = argb;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
XDestroyImage(ximg);
|
||||||
|
img = imlib_create_image_using_data(panel->area.width, panel->area.height, pixels);
|
||||||
|
} else {
|
||||||
|
imlib_context_set_drawable(panel->temp_pmap);
|
||||||
|
img = imlib_create_image_from_drawable(0, 0, 0, panel->area.width, panel->area.height, 1);
|
||||||
}
|
}
|
||||||
XDestroyImage(ximg);
|
|
||||||
|
|
||||||
Imlib_Image img = imlib_create_image_using_data(panel->area.width, panel->area.height, pixels);
|
if (img) {
|
||||||
|
imlib_context_set_image(img);
|
||||||
// imlib_context_set_drawable(panel->temp_pmap);
|
if (!panel_horizontal) {
|
||||||
// Imlib_Image img = imlib_create_image_from_drawable(0, 0, 0, panel->area.width, panel->area.height, 1);
|
// rotate 90° vertical panel
|
||||||
|
imlib_image_flip_horizontal();
|
||||||
imlib_context_set_image(img);
|
imlib_image_flip_diagonal();
|
||||||
if (!panel_horizontal) {
|
}
|
||||||
// rotate 90° vertical panel
|
imlib_save_image(path);
|
||||||
imlib_image_flip_horizontal();
|
imlib_free_image();
|
||||||
imlib_image_flip_diagonal();
|
|
||||||
}
|
}
|
||||||
imlib_save_image(path);
|
|
||||||
imlib_free_image();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_action(Task *task, MouseAction action)
|
void window_action(Task *task, MouseAction action)
|
||||||
|
|
Loading…
Reference in a new issue