< prev index next >

modules/graphics/src/main/native-glass/gtk/GlassRobot.cpp

Print this page
rev 9734 : 8087516: Conditional support for GTK 3 on Linux
Reviewed-by:


 230     (void)obj;
 231 
 232     jint y;
 233     glass_gdk_display_get_pointer(gdk_display_get_default(), NULL, &y);
 234     return y;
 235 }
 236 
 237 /*
 238  * Class:     com_sun_glass_ui_gtk_GtkRobot
 239  * Method:    _getScreenCapture
 240  * Signature: (IIII[I)V
 241  */
 242 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkRobot__1getScreenCapture
 243   (JNIEnv * env, jobject obj, jint x, jint y, jint width, jint height, jintArray data)
 244 {
 245     (void)obj;
 246 
 247     GdkPixbuf *screenshot, *tmp;
 248     GdkWindow *root_window = gdk_get_default_root_window();
 249 
 250     tmp = gdk_pixbuf_get_from_drawable (NULL, root_window, NULL,
 251                                            x, y, 0, 0, width, height);
 252     screenshot = gdk_pixbuf_add_alpha(tmp, FALSE, 0, 0, 0);
 253     g_object_unref(tmp);
 254 
 255     jint *pixels = (jint *)convert_BGRA_to_RGBA((int*)gdk_pixbuf_get_pixels(screenshot), width * 4, height);
 256     env->SetIntArrayRegion(data, 0, height * width, pixels);
 257     g_free(pixels);
 258 
 259     g_object_unref(screenshot);
 260 }
 261 
 262 } // extern "C"


 230     (void)obj;
 231 
 232     jint y;
 233     glass_gdk_display_get_pointer(gdk_display_get_default(), NULL, &y);
 234     return y;
 235 }
 236 
 237 /*
 238  * Class:     com_sun_glass_ui_gtk_GtkRobot
 239  * Method:    _getScreenCapture
 240  * Signature: (IIII[I)V
 241  */
 242 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkRobot__1getScreenCapture
 243   (JNIEnv * env, jobject obj, jint x, jint y, jint width, jint height, jintArray data)
 244 {
 245     (void)obj;
 246 
 247     GdkPixbuf *screenshot, *tmp;
 248     GdkWindow *root_window = gdk_get_default_root_window();
 249 
 250     tmp = glass_pixbuf_from_window(root_window, x, y, width, height);

 251     screenshot = gdk_pixbuf_add_alpha(tmp, FALSE, 0, 0, 0);
 252     g_object_unref(tmp);
 253 
 254     jint *pixels = (jint *)convert_BGRA_to_RGBA((int*)gdk_pixbuf_get_pixels(screenshot), width * 4, height);
 255     env->SetIntArrayRegion(data, 0, height * width, pixels);
 256     g_free(pixels);
 257 
 258     g_object_unref(screenshot);
 259 }
 260 
 261 } // extern "C"
< prev index next >