< prev index next >

src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -172,11 +172,12 @@
      * @return color of the pixel
      */
     @Override
     public int getRGBPixel(int x, int y) {
         int c[] = new int[1];
-        getScreenPixels(new Rectangle(x, y, 1, 1), c);
+        double scale = fDevice.getScaleFactor();
+        getScreenPixels(new Rectangle(x, y, (int) scale, (int) scale), c);
         return c[0];
     }
 
     /**
      * Creates an image containing pixels read from the screen.

@@ -196,9 +197,10 @@
                                    int buttonsState,
                                    boolean isButtonsDownState,
                                    boolean isMouseMove);
     private native void keyEvent(int javaKeyCode, boolean keydown);
     private void getScreenPixels(Rectangle r, int[] pixels){
-        nativeGetScreenPixels(r.x, r.y, r.width, r.height, pixels);
+        double scale = fDevice.getScaleFactor();
+        nativeGetScreenPixels(r.x, r.y, r.width, r.height, scale, pixels);
     }
-    private native void nativeGetScreenPixels(int x, int y, int width, int height, int[] pixels);
+    private native void nativeGetScreenPixels(int x, int y, int width, int height, double scale, int[] pixels);
 }
< prev index next >