[gnome-shell] screen-grabber: Fix area screenshots
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] screen-grabber: Fix area screenshots
- Date: Fri, 2 Mar 2012 10:50:18 +0000 (UTC)
commit ca612872a602435913932f5a31e92cd011bea475
Author: Florian MÃllner <fmuellner gnome org>
Date: Tue Feb 28 15:59:35 2012 +0100
screen-grabber: Fix area screenshots
Our DBus API (and mostly every other API in existence) define an
area as the top-left corner and width/height; glReadPixels on the
other hand uses the bottom-left corner, so we have to transform the
coordinates before passing them to GL.
https://bugzilla.gnome.org/show_bug.cgi?id=670979
src/shell-screen-grabber.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/src/shell-screen-grabber.c b/src/shell-screen-grabber.c
index f8ddaa1..74caa89 100644
--- a/src/shell-screen-grabber.c
+++ b/src/shell-screen-grabber.c
@@ -107,6 +107,7 @@ shell_screen_grabber_grab (ShellScreenGrabber *grabber,
GLubyte *mapped_data;
GLint old_swap_bytes, old_lsb_first, old_row_length, old_skip_pixels, old_skip_rows, old_alignment;
GLint old_pack_invert = GL_FALSE;
+ GLint vp_size[4];
guchar *src_row, *dest_row;
int i;
@@ -165,6 +166,10 @@ shell_screen_grabber_grab (ShellScreenGrabber *grabber,
pf_glBindBufferARB (GL_PIXEL_PACK_BUFFER_ARB, grabber->pixel_buffer);
}
+ /* In OpenGL, (x,y) specifies the bottom-left corner rather than the
+ * top-left */
+ glGetIntegerv (GL_VIEWPORT, vp_size);
+ y = vp_size[3] - (y + height);
glReadPixels (x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, 0);
mapped_data = pf_glMapBufferARB (GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]