changeset 2822:05ce1a10c53f

RT-28283 and RT-28284: HiDPI robot support
author Anthony Petrov <anthony.petrov@oracle.com>
date Thu, 07 Mar 2013 15:35:36 +0400
parents 1a825fa0340f
children 8e27b105aa5f
files glass/glass-lib-macosx/src/GlassApplication.m glass/glass-lib-macosx/src/GlassRobot.m glass/glass-lib-macosx/src/GlassStatics.h glass/glass/src/com/sun/glass/ui/Application.java glass/glass/src/com/sun/glass/ui/Pixels.java glass/glass/src/com/sun/glass/ui/Robot.java glass/glass/src/com/sun/glass/ui/gtk/GtkApplication.java glass/glass/src/com/sun/glass/ui/gtk/GtkPixels.java glass/glass/src/com/sun/glass/ui/gtk/GtkRobot.java glass/glass/src/com/sun/glass/ui/ios/IosApplication.java glass/glass/src/com/sun/glass/ui/ios/IosPixels.java glass/glass/src/com/sun/glass/ui/ios/IosRobot.java glass/glass/src/com/sun/glass/ui/lens/LensApplication.java glass/glass/src/com/sun/glass/ui/lens/LensPixels.java glass/glass/src/com/sun/glass/ui/lens/LensRobot.java glass/glass/src/com/sun/glass/ui/mac/MacApplication.java glass/glass/src/com/sun/glass/ui/mac/MacPixels.java glass/glass/src/com/sun/glass/ui/mac/MacRobot.java glass/glass/src/com/sun/glass/ui/swt/SWTApplication.java glass/glass/src/com/sun/glass/ui/swt/SWTPixels.java glass/glass/src/com/sun/glass/ui/swt/SWTRobot.java glass/glass/src/com/sun/glass/ui/win/WinApplication.java glass/glass/src/com/sun/glass/ui/win/WinPixels.java glass/glass/src/com/sun/glass/ui/win/WinRobot.java
diffstat 24 files changed, 234 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/glass/glass-lib-macosx/src/GlassApplication.m	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass-lib-macosx/src/GlassApplication.m	Thu Mar 07 15:35:36 2013 +0400
@@ -707,6 +707,14 @@
 {
     LOG("Java_com_sun_glass_ui_mac_MacApplication__1initIDs");
 
+    javaIDs.Application.createPixels = (*env)->GetStaticMethodID(env,
+            jClass,
+            "createPixels", "(II[IF)Lcom/sun/glass/ui/Pixels;");
+
+    javaIDs.Application.getScaleFactor = (*env)->GetStaticMethodID(env,
+            jClass,
+            "getScaleFactor", "(IIII)F");
+
     if (jRunnableRun == NULL)
     {
         jRunnableRun = (*env)->GetMethodID(env, (*env)->FindClass(env, "java/lang/Runnable"), "run", "()V");
--- a/glass/glass-lib-macosx/src/GlassRobot.m	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass-lib-macosx/src/GlassRobot.m	Thu Mar 07 15:35:36 2013 +0400
@@ -30,6 +30,7 @@
 
 #import "GlassMacros.h"
 #import "GlassKey.h"
+#import "GlassHelper.h"
 
 //#define VERBOSE
 #ifndef VERBOSE
@@ -439,41 +440,75 @@
 /*
  * Class:     com_sun_glass_ui_mac_MacRobot
  * Method:    _getScreenCapture
- * Signature: (IIII[I;)V
+ * Signature: (IIIIZ)Lcom/sun/glass/ui/Pixels;
  */
-JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacRobot__1getScreenCapture
-(JNIEnv *env, jobject jrobot, jint x, jint y, jint width, jint height, jintArray pixelArray)
+JNIEXPORT jobject JNICALL Java_com_sun_glass_ui_mac_MacRobot__1getScreenCapture
+(JNIEnv *env, jobject jrobot, jint x, jint y, jint width, jint height, jboolean isHiDPI)
 {
     LOG("Java_com_sun_glass_ui_mac_MacRobot__1getScreenCapture");
     
+    jobject pixels = NULL;
+
     GLASS_ASSERT_MAIN_JAVA_THREAD(env);
     GLASS_POOL_ENTER
     {
-        jint *javaPixels = (jint*)(*env)->GetIntArrayElements(env, pixelArray, 0);
-        if (javaPixels != NULL)
+        CGRect bounds = CGRectMake((CGFloat)x, (CGFloat)y, (CGFloat)width, (CGFloat)height);
+        CGImageRef screenImage = CGWindowListCreateImage(bounds, kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault);
+        if (screenImage != NULL)
         {
-            CGRect bounds = CGRectMake((CGFloat)x, (CGFloat)y, (CGFloat)width, (CGFloat)height);
-            CGImageRef screenImage = CGWindowListCreateImage(bounds, kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault);
-            if (screenImage != NULL)
+            jint pixWidth, pixHeight;
+
+            if (isHiDPI) {
+                pixWidth = (jint)CGImageGetWidth(screenImage);
+                pixHeight = (jint)CGImageGetHeight(screenImage);
+            } else {
+                pixWidth = width;
+                pixHeight = height;
+            }
+
+            jintArray pixelArray = (*env)->NewIntArray(env, (jsize)pixWidth*pixHeight);
+            if (pixelArray)
             {
-                CGDataProviderRef provider = CGImageGetDataProvider(screenImage);
-                if (provider != NULL)
+                jint *javaPixels = (jint*)(*env)->GetIntArrayElements(env, pixelArray, 0);
+                if (javaPixels != NULL)
                 {
-                    CFDataRef data = CGDataProviderCopyData(provider);
-                    if (data != NULL)
-                    {
-                        jint *screenPixels = (jint*)CFDataGetBytePtr(data);
-                        if (screenPixels != NULL)
-                        {
-                            memcpy(javaPixels, screenPixels, width*height);
-                        }
-                    }
-                    CFRelease(data);
+                    // create a graphics context around the Java int array
+                    CGColorSpaceRef picColorSpace = CGColorSpaceCreateWithName(
+                            kCGColorSpaceGenericRGB);
+                    CGContextRef jPicContextRef = CGBitmapContextCreate(
+                            javaPixels,
+                            pixWidth, pixHeight,
+                            8, pixWidth * sizeof(jint),
+                            picColorSpace,
+                            kCGBitmapByteOrder32Host |
+                            kCGImageAlphaPremultipliedFirst);
+
+                    CGColorSpaceRelease(picColorSpace);
+
+                    // flip, scale, and color correct the screen image into the Java pixels
+                    CGRect zeroBounds = { { 0, 0 }, { pixWidth, pixHeight } };
+                    CGContextDrawImage(jPicContextRef, zeroBounds, screenImage);
+                    CGContextFlush(jPicContextRef);
+
+                    // cleanup
+                    CGContextRelease(jPicContextRef);
+                    (*env)->ReleaseIntArrayElements(env, pixelArray, javaPixels, 0);
+
+                    jfloat scale = (*env)->CallStaticFloatMethod(env,
+                            [GlassHelper ClassForName:"com.sun.glass.ui.Application" withEnv:env],
+                            javaIDs.Application.getScaleFactor, x, y, width, height);
+
+                    // create Pixels
+                    pixels = (*env)->CallStaticObjectMethod(env,
+                            [GlassHelper ClassForName:"com.sun.glass.ui.Application" withEnv:env],
+                            javaIDs.Application.createPixels, pixWidth, pixHeight, pixelArray, scale);
                 }
-                CGImageRelease(screenImage);
             }
+
+            CGImageRelease(screenImage);
         }
-        (*env)->ReleaseIntArrayElements(env, pixelArray, javaPixels, 0);
     }
     GLASS_POOL_EXIT;
+
+    return pixels;
 }
--- a/glass/glass-lib-macosx/src/GlassStatics.h	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass-lib-macosx/src/GlassStatics.h	Thu Mar 07 15:35:36 2013 +0400
@@ -116,6 +116,10 @@
     struct {
         jmethodID init;
     } File;
+    struct {
+        jmethodID createPixels;
+        jmethodID getScaleFactor;
+    } Application;
 } JavaIDs;
 extern JavaIDs javaIDs;
 
--- a/glass/glass/src/com/sun/glass/ui/Application.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/Application.java	Thu Mar 07 15:35:36 2013 +0400
@@ -538,8 +538,29 @@
 
     public abstract Pixels createPixels(int width, int height, ByteBuffer data);
     public abstract Pixels createPixels(int width, int height, IntBuffer data);
+    public abstract Pixels createPixels(int width, int height, IntBuffer data, float scale);
     protected abstract int staticPixels_getNativeFormat();
 
+    /* utility method called from native code */
+    static Pixels createPixels(int width, int height, int[] data, float scale) {
+        return Application.GetApplication().createPixels(width, height, IntBuffer.wrap(data), scale);
+    }
+
+    /* utility method called from native code */
+    static float getScaleFactor(final int x, final int y, final int w, final int h) {
+        float scale = 0.0f;
+        // Find the maximum scale for screens this area overlaps
+        for (Screen s : Screen.getScreens()) {
+            final int sx = s.getX(), sy = s.getY(), sw = s.getWidth(), sh = s.getHeight();
+            if (x < (sx + sw) && (x + w) > sx && y < (sy + sh) && (y + h) > sy) {
+                if (scale < s.getScale()) {
+                    scale = s.getScale();
+                }
+            }
+        }
+        return scale == 0.0f ? 1.0f : scale;
+    }
+
 
     public abstract Robot createRobot();
 
--- a/glass/glass/src/com/sun/glass/ui/Pixels.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/Pixels.java	Thu Mar 07 15:35:36 2013 +0400
@@ -78,6 +78,8 @@
     protected final ByteBuffer bytes;
     protected final IntBuffer ints;
 
+    private final float scale;
+
     protected Pixels(final int width, final int height, final ByteBuffer pixels) {
         //Application.checkEventThread(); // Quantum
         this.width = width;
@@ -89,6 +91,7 @@
         }
         
         this.ints = null;
+        this.scale = 1.0f;
     }
     
     protected Pixels(final int width, final int height, IntBuffer pixels) {
@@ -102,6 +105,26 @@
         }
         
         this.bytes = null;
+        this.scale = 1.0f;
+    }
+
+    protected Pixels(final int width, final int height, IntBuffer pixels, float scale) {
+        //Application.checkEventThread(); // Quantum
+        this.width = width;
+        this.height = height;
+        this.bytesPerComponent = 4;
+        this.ints = pixels.slice();
+        if ((this.width <= 0) || (this.height <= 0) || ((this.width * this.height) > this.ints.capacity())) {
+            throw new IllegalArgumentException("Too small int buffer size "+this.width+"x"+this.height+" ["+(this.width*this.height)+"] > "+this.ints.capacity());
+        }
+        
+        this.bytes = null;
+        this.scale = scale;
+    }
+
+    public final float getScale() {
+        Application.checkEventThread();
+        return this.scale;
     }
 
     public final int getWidth() {
--- a/glass/glass/src/com/sun/glass/ui/Robot.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/Robot.java	Thu Mar 07 15:35:36 2013 +0400
@@ -150,16 +150,34 @@
         return _getPixelColor(x, y);
     }
 
-    protected abstract void _getScreenCapture(int x, int y, int width, int height, int[] data);
+    protected abstract Pixels _getScreenCapture(int x, int y, int width, int height, boolean isHiDPI);
+    /**
+     * Returns a capture of the specified rectangular area of the screen.
+     *
+     * If {@code isHiDPI} argument is {@code true}, the returned Pixels object
+     * dimensions may differ from the requested {@code width} and {@code
+     * height} depending on how many physical pixels the area occupies on the
+     * screen.  E.g. in HiDPI mode on the Mac (aka Retina display) the pixels
+     * are doubled, and thus a screen capture of an area of size (10x10) pixels
+     * will result in a Pixels object with dimensions (20x20). Calling code
+     * should use the returned objects's getWidth() and getHeight() methods
+     * to determine the image size.
+     *
+     * If (@code isHiDPI) is {@code false}, the returned Pixels object is of
+     * the requested size. Note that in this case the image may be scaled in
+     * order to fit to the requested dimensions if running on a HiDPI display.
+     */
+    public Pixels getScreenCapture(int x, int y, int width, int height, boolean isHiDPI) {
+        Application.checkEventThread();
+        return _getScreenCapture(x, y, width, height, isHiDPI);
+    }
+
     /**
      * Returns a capture of the specified area of the screen.
+     * It is equivalent to calling getScreenCapture(x, y, width, height, false),
+     * i.e. this method takes a "LowDPI" screen shot.
      */
     public Pixels getScreenCapture(int x, int y, int width, int height) {
-        Application.checkEventThread();
-        int data[] = new int[width * height];
-
-        _getScreenCapture(x, y, width, height, data);
-
-        return Application.GetApplication().createPixels(width, height, IntBuffer.wrap(data));
+        return getScreenCapture(x, y, width, height, false);
     }
 }
--- a/glass/glass/src/com/sun/glass/ui/gtk/GtkApplication.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/gtk/GtkApplication.java	Thu Mar 07 15:35:36 2013 +0400
@@ -250,6 +250,11 @@
     }
 
     @Override
+    public Pixels createPixels(int width, int height, IntBuffer data, float scale) {
+        return new GtkPixels(width, height, data, scale);
+    }
+
+    @Override
     protected int staticPixels_getNativeFormat() {
         return Pixels.Format.BYTE_BGRA_PRE; // TODO
     }
--- a/glass/glass/src/com/sun/glass/ui/gtk/GtkPixels.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/gtk/GtkPixels.java	Thu Mar 07 15:35:36 2013 +0400
@@ -39,6 +39,10 @@
         super(width, height, data);
     }
 
+    public GtkPixels(int width, int height, IntBuffer data, float scale) {
+        super(width, height, data, scale);
+    }
+
     @Override
     protected void _fillDirectByteBuffer(ByteBuffer bb) {
         // Taken from MacPixels
--- a/glass/glass/src/com/sun/glass/ui/gtk/GtkRobot.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/gtk/GtkRobot.java	Thu Mar 07 15:35:36 2013 +0400
@@ -24,7 +24,8 @@
  */
 package com.sun.glass.ui.gtk;
 
-import com.sun.glass.ui.Robot;
+import com.sun.glass.ui.*;
+import java.nio.IntBuffer;
 
 final class GtkRobot extends Robot {
 
@@ -69,7 +70,10 @@
         return result[0];
     }
 
-    @Override
-    protected native void _getScreenCapture(int x, int y, int width, int height, int[] data);
-    
+    native private void _getScreenCapture(int x, int y, int width, int height, int[] data);
+    @Override protected Pixels _getScreenCapture(int x, int y, int width, int height, boolean isHiDPI) {
+        int data[] = new int[width * height];
+        _getScreenCapture(x, y, width, height, data);
+        return Application.GetApplication().createPixels(width, height, IntBuffer.wrap(data));
+    }
 }
--- a/glass/glass/src/com/sun/glass/ui/ios/IosApplication.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/ios/IosApplication.java	Thu Mar 07 15:35:36 2013 +0400
@@ -147,6 +147,11 @@
     }
 
     @Override
+    public Pixels createPixels(int width, int height, IntBuffer data, float scale) {
+        return new IosPixels(width, height, data, scale);
+    }
+
+    @Override
     protected int staticPixels_getNativeFormat() {
         return 0;
     }
--- a/glass/glass/src/com/sun/glass/ui/ios/IosPixels.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/ios/IosPixels.java	Thu Mar 07 15:35:36 2013 +0400
@@ -42,6 +42,10 @@
         super(width, height, data);
     }
     
+    protected IosPixels(int width, int height, IntBuffer data, float scale) {
+        super(width, height, data, scale);
+    }
+
     @Override
     protected void _fillDirectByteBuffer(ByteBuffer bb) { }
 
--- a/glass/glass/src/com/sun/glass/ui/ios/IosRobot.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/ios/IosRobot.java	Thu Mar 07 15:35:36 2013 +0400
@@ -25,7 +25,8 @@
 
 package com.sun.glass.ui.ios;
 
-import com.sun.glass.ui.Robot;
+import com.sun.glass.ui.*;
+import java.nio.IntBuffer;
 
 /**
  * iOS platform implementation class of test automation Robot.
@@ -127,12 +128,14 @@
     }
 
     // capture bitmap image of (x, y, x + width, y + height) area
-    private native void _getScreenCapture(long ptr, int x, int y, int width, int height, int[] data);
-    @Override protected void _getScreenCapture(int x, int y, int width, int height, int[] data) {
+    native private void _getScreenCapture(long ptr, int x, int y, int width, int height, int[] data);
+    @Override protected Pixels _getScreenCapture(int x, int y, int width, int height, boolean isHiDPI) {
         if (ptr == 0) {
-            return;
+            return null;
         }
+        int data[] = new int[width * height];
         _getScreenCapture(ptr, x, y, width, height, data);
+        return Application.GetApplication().createPixels(width, height, IntBuffer.wrap(data));
     }
 }
 
--- a/glass/glass/src/com/sun/glass/ui/lens/LensApplication.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/lens/LensApplication.java	Thu Mar 07 15:35:36 2013 +0400
@@ -1433,6 +1433,11 @@
     }
 
     @Override
+    public Pixels createPixels(int width, int height, IntBuffer data, float scale) {
+        return new LensPixels(width, height, data, scale);
+    }
+
+    @Override
     protected int staticPixels_getNativeFormat() {
         return LensPixels.getNativeFormat_impl();
     }
--- a/glass/glass/src/com/sun/glass/ui/lens/LensPixels.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/lens/LensPixels.java	Thu Mar 07 15:35:36 2013 +0400
@@ -40,6 +40,10 @@
         super(width, height, data);
     }
 
+    protected LensPixels(int width, int height, IntBuffer data, float scale) {
+        super(width, height, data, scale);
+    }
+
     static int getNativeFormat_impl() {
         LensLogger.getLogger().config("Querying native format");
         // All our implementations use ARGB_PRE and convert to the native pixel
--- a/glass/glass/src/com/sun/glass/ui/lens/LensRobot.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/lens/LensRobot.java	Thu Mar 07 15:35:36 2013 +0400
@@ -25,10 +25,10 @@
 
 package com.sun.glass.ui.lens;
 
-import com.sun.glass.ui.Application;
-import com.sun.glass.ui.Robot;
+import com.sun.glass.ui.*;
 import com.sun.glass.events.KeyEvent;
 import com.sun.glass.events.MouseEvent;
+import java.nio.IntBuffer;
 
 final class LensRobot extends Robot {
 
@@ -104,9 +104,12 @@
     private native int getMouseLocation(int axsis);
 
     @Override native protected int _getPixelColor(int x, int y);
-    @Override native protected void _getScreenCapture(int x, int y,
-                                                      int width, int height,
-                                                      int[] data);
 
+    native private void _getScreenCapture(int x, int y, int width, int height, int[] data);
+    @Override protected Pixels _getScreenCapture(int x, int y, int width, int height, boolean isHiDPI) {
+        int data[] = new int[width * height];
+        _getScreenCapture(x, y, width, height, data);
+        return Application.GetApplication().createPixels(width, height, IntBuffer.wrap(data));
+    }
 }
 
--- a/glass/glass/src/com/sun/glass/ui/mac/MacApplication.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/mac/MacApplication.java	Thu Mar 07 15:35:36 2013 +0400
@@ -181,6 +181,11 @@
         return new MacPixels(width, height, data);
     }
 
+    @Override
+    public Pixels createPixels(int width, int height, IntBuffer data, float scale) {
+        return new MacPixels(width, height, data, scale);
+    }
+
     @Override protected int staticPixels_getNativeFormat() {
         return MacPixels.getNativeFormat_impl();
     }
--- a/glass/glass/src/com/sun/glass/ui/mac/MacPixels.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/mac/MacPixels.java	Thu Mar 07 15:35:36 2013 +0400
@@ -57,6 +57,10 @@
         super(width, height, data);
     }
     
+    protected MacPixels(int width, int height, IntBuffer data, float scale) {
+        super(width, height, data, scale);
+    }
+
     @Override
     protected void _fillDirectByteBuffer(ByteBuffer bb) {
         if (this.bytes != null) {
--- a/glass/glass/src/com/sun/glass/ui/mac/MacRobot.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/mac/MacRobot.java	Thu Mar 07 15:35:36 2013 +0400
@@ -24,8 +24,7 @@
  */
 package com.sun.glass.ui.mac;
 
-import com.sun.glass.ui.Application;
-import com.sun.glass.ui.Robot;
+import com.sun.glass.ui.*;
 
 /**
  * MacOSX platform implementation class for Robot.
@@ -94,7 +93,6 @@
     }
 
     @Override native protected int _getPixelColor(int x, int y);
-    @Override native protected void _getScreenCapture(int x, int y, int width, int height, int[] data);
-
+    @Override native protected Pixels _getScreenCapture(int x, int y, int width, int height, boolean isHiDPI);
 }
 
--- a/glass/glass/src/com/sun/glass/ui/swt/SWTApplication.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/swt/SWTApplication.java	Thu Mar 07 15:35:36 2013 +0400
@@ -233,6 +233,11 @@
     }
 
     @Override
+    public Pixels createPixels(int width, int height, IntBuffer data, float scale) {
+        return new SWTPixels(width, height, data, scale);
+    }
+
+    @Override
     protected int staticPixels_getNativeFormat() {
         return Pixels.Format.BYTE_BGRA_PRE;
     }
--- a/glass/glass/src/com/sun/glass/ui/swt/SWTPixels.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/swt/SWTPixels.java	Thu Mar 07 15:35:36 2013 +0400
@@ -38,6 +38,10 @@
         super(width, height, data);
     }
     
+    protected SWTPixels(int width, int height, IntBuffer data, float scale) {
+        super(width, height, data, scale);
+    }
+
     @Override
     protected void _fillDirectByteBuffer(ByteBuffer bb) {
         //TODO - not implemented
--- a/glass/glass/src/com/sun/glass/ui/swt/SWTRobot.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/swt/SWTRobot.java	Thu Mar 07 15:35:36 2013 +0400
@@ -24,7 +24,9 @@
  */
 package com.sun.glass.ui.swt;
 
-import com.sun.glass.ui.Robot;
+import com.sun.glass.ui.*;
+
+import java.nio.IntBuffer;
 
 import org.eclipse.swt.*;
 import org.eclipse.swt.graphics.*;
@@ -106,7 +108,7 @@
         return imageData.getPixel(x, y);
     }
     
-    @Override protected void _getScreenCapture(int x, int y, int width, int height, int[] data) {
+    private void _getScreenCapture(int x, int y, int width, int height, int[] data) {
 //        Display display = Display.getDefault();
 //        GC gc = new GC(display);
 //        final Image image = new Image(display, display.getBounds());
@@ -115,5 +117,10 @@
 //        ImageData imageData = image.getImageData();
         //TODO - put bits into data
     }
+    @Override protected Pixels _getScreenCapture(int x, int y, int width, int height, boolean isHiDPI) {
+        int data[] = new int[width * height];
+        _getScreenCapture(x, y, width, height, data);
+        return Application.GetApplication().createPixels(width, height, IntBuffer.wrap(data));
+    }
 }
 
--- a/glass/glass/src/com/sun/glass/ui/win/WinApplication.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/win/WinApplication.java	Thu Mar 07 15:35:36 2013 +0400
@@ -175,6 +175,11 @@
         return new WinPixels(width, height, data);
     }
 
+    @Override
+    public Pixels createPixels(int width, int height, IntBuffer data, float scale) {
+        return new WinPixels(width, height, data, scale);
+    }
+
     @Override protected int staticPixels_getNativeFormat() {
         return WinPixels.getNativeFormat_impl();
     }
--- a/glass/glass/src/com/sun/glass/ui/win/WinPixels.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/win/WinPixels.java	Thu Mar 07 15:35:36 2013 +0400
@@ -50,6 +50,10 @@
         super(width, height, data);
     }
 
+    protected WinPixels(int width, int height, IntBuffer data, float scale) {
+        super(width, height, data, scale);
+    }
+
     static int getNativeFormat_impl() {
         return nativeFormat;
     }
--- a/glass/glass/src/com/sun/glass/ui/win/WinRobot.java	Wed Mar 06 18:16:42 2013 -0800
+++ b/glass/glass/src/com/sun/glass/ui/win/WinRobot.java	Thu Mar 07 15:35:36 2013 +0400
@@ -24,7 +24,8 @@
  */
 package com.sun.glass.ui.win;
 
-import com.sun.glass.ui.Robot;
+import com.sun.glass.ui.*;
+import java.nio.IntBuffer;
 
 /**
  * MS Windows platform implementation class for Robot.
@@ -50,7 +51,12 @@
     @Override native protected int _getMouseY();
 
     @Override native protected int _getPixelColor(int x, int y);
-    @Override native protected void _getScreenCapture(int x, int y, int width, int height, int[] data);
+    native private void _getScreenCapture(int x, int y, int width, int height, int[] data);
+    @Override protected Pixels _getScreenCapture(int x, int y, int width, int height, boolean isHiDPI) {
+        int data[] = new int[width * height];
+        _getScreenCapture(x, y, width, height, data);
+        return Application.GetApplication().createPixels(width, height, IntBuffer.wrap(data));
+    }
 
 }