JRE-299 [followup] [windows] ColorPicker crashes
diff --git a/src/share/classes/java/awt/Robot.java b/src/share/classes/java/awt/Robot.java
index d689760..b346341 100644
--- a/src/share/classes/java/awt/Robot.java
+++ b/src/share/classes/java/awt/Robot.java
@@ -434,20 +434,15 @@
         int pixels[];
         int[] bandmasks = new int[3];
 
-        pixels = peer.getRGBPixels(screenRect);
+        Rectangle devScreenRect = screenRect.getBounds();
+        pixels = peer.getRGBPixels(devScreenRect); // devScreenRect is IN/OUT param
         buffer = new DataBufferInt(pixels, pixels.length);
 
         bandmasks[0] = screenCapCM.getRedMask();
         bandmasks[1] = screenCapCM.getGreenMask();
         bandmasks[2] = screenCapCM.getBlueMask();
 
-        assert pixels != null;
-        int arraySize = screenRect.width * screenRect.height;
-        double devScale = arraySize != 0 ? Math.sqrt(pixels.length / arraySize) : 1;
-        int devScreenWidth = (int)Math.ceil(screenRect.width * devScale);
-        int devScreenHeight = (int)Math.ceil(screenRect.height * devScale);
-
-        raster = Raster.createPackedRaster(buffer, devScreenWidth, devScreenHeight, devScreenWidth, bandmasks, null);
+        raster = Raster.createPackedRaster(buffer, devScreenRect.width, devScreenRect.height, devScreenRect.width, bandmasks, null);
         SunWritableRaster.makeTrackable(buffer);
 
         image = new BufferedImage(screenCapCM, raster, false, null);
diff --git a/src/windows/classes/sun/awt/windows/WRobotPeer.java b/src/windows/classes/sun/awt/windows/WRobotPeer.java
index 5e5ae8b..7ab8d12 100644
--- a/src/windows/classes/sun/awt/windows/WRobotPeer.java
+++ b/src/windows/classes/sun/awt/windows/WRobotPeer.java
@@ -69,9 +69,5 @@
     }
 
     @Override
-    public int [] getRGBPixels(Rectangle bounds) {
-        return getRGBPixels(bounds.x, bounds.y, bounds.width, bounds.height);
-    }
-
-    private native int[] getRGBPixels(int x, int y, int width, int height);
+    public native int[] getRGBPixels(Rectangle bounds);
 }
diff --git a/src/windows/native/sun/windows/awt_Robot.cpp b/src/windows/native/sun/windows/awt_Robot.cpp
index bf98189..3cace8b 100644
--- a/src/windows/native/sun/windows/awt_Robot.cpp
+++ b/src/windows/native/sun/windows/awt_Robot.cpp
@@ -26,6 +26,7 @@
 #include "awt.h"
 #include "awt_Toolkit.h"
 #include "awt_Component.h"
+#include "awt_Rectangle.h"
 #include "awt_Robot.h"
 #include "sun_awt_windows_WRobotPeer.h"
 #include "java_awt_event_InputEvent.h"
@@ -197,7 +198,7 @@
     return value;
 }
 
-jintArray AwtRobot::GetRGBPixels(jint x, jint y, jint width, jint height)
+jintArray AwtRobot::GetRGBPixels(jobject bounds) // bounds is IN/OUT param
 {
     DASSERT(width > 0 && height > 0);
 
@@ -208,12 +209,23 @@
     HPALETTE hOldPalette = NULL;
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
+    jint x = env->GetIntField(bounds, AwtRectangle::xID);
+    jint y = env->GetIntField(bounds, AwtRectangle::yID);
+    jint width = env->GetIntField(bounds, AwtRectangle::widthID);
+    jint height = env->GetIntField(bounds, AwtRectangle::heightID);
+
     AwtWin32GraphicsDevice* device = AwtWin32GraphicsDevice::GetDeviceByBounds(RECT_BOUNDS(x, y, width, height));
     x = (device == NULL) ? x : device->ScaleUpDX(x);
     y = (device == NULL) ? y : device->ScaleUpDY(y);
     width = (device == NULL) ? width : device->ScaleUpX(width);
     height = (device == NULL) ? height : device->ScaleUpY(height);
 
+    // set the device bounds to return
+    env->SetIntField(bounds, AwtRectangle::xID, x);
+    env->SetIntField(bounds, AwtRectangle::yID, y);
+    env->SetIntField(bounds, AwtRectangle::widthID, width);
+    env->SetIntField(bounds, AwtRectangle::heightID, height);
+
     // create an offscreen bitmap
     hbitmap = ::CreateCompatibleBitmap(hdcScreen, width, height);
     if (hbitmap == NULL) {
@@ -409,11 +421,11 @@
 }
 
 JNIEXPORT jintArray JNICALL Java_sun_awt_windows_WRobotPeer_getRGBPixels(
-    JNIEnv *env, jobject self, jint x, jint y, jint width, jint height)
+    JNIEnv *env, jobject self, jobject bounds)
 {
     TRY;
 
-    return AwtRobot::GetRobot(self)->GetRGBPixels(x, y, width, height);
+    return AwtRobot::GetRobot(self)->GetRGBPixels(bounds);
 
     CATCH_BAD_ALLOC_RET(NULL);
 }
diff --git a/src/windows/native/sun/windows/awt_Robot.h b/src/windows/native/sun/windows/awt_Robot.h
index 8438bfe..d059c4f 100644
--- a/src/windows/native/sun/windows/awt_Robot.h
+++ b/src/windows/native/sun/windows/awt_Robot.h
@@ -44,7 +44,7 @@
         void MouseWheel(jint wheelAmt);
         jint getNumberOfButtons();
 
-        jintArray GetRGBPixels(jint x, jint y, jint width, jint height);
+        jintArray GetRGBPixels(jobject bounds);
 
         void KeyPress( jint key );
         void KeyRelease( jint key );