JRE-249 Icons in Messages are huge on Retina
diff --git a/src/macosx/classes/sun/lwawt/macosx/CImage.java b/src/macosx/classes/sun/lwawt/macosx/CImage.java
index 29dcaf9..9d2bd12 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CImage.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CImage.java
@@ -45,7 +45,7 @@
     private static native long nativeCreateNSImageFromImageName(String name);
     private static native long nativeCreateNSImageFromIconSelector(int selector);
     private static native byte[] nativeGetPlatformImageBytes(int[] buffer, int w, int h);
-    private static native void nativeCopyNSImageIntoArray(long image, int[] buffer, int sw, int sh, int dw, int dh);
+    private static native void nativeCopyNSImageIntoArray(long image, int[] buffer, int dw, int dh);
     private static native Dimension2D nativeGetNSImageSize(long image);
     private static native void nativeSetNSImageSize(long image, double w, double h);
     private static native void nativeResizeNSImageRepresentations(long image, double w, double h);
@@ -237,40 +237,36 @@
     private Image toImage() {
         if (ptr == 0) return null;
 
-        final Dimension2D size = nativeGetNSImageSize(ptr);
+        Dimension2D size = nativeGetNSImageSize(ptr);
         final int baseWidth = (int)size.getWidth();
         final int baseHeight = (int)size.getHeight();
 
         Dimension2D[] sizes = nativeGetNSImageRepresentationSizes(ptr, size.getWidth(), size.getHeight());
 
-        int dstW = baseWidth;
-        int dstH = baseHeight;
-
         // The image may be represented in the only size which differs from the base one.
         // For instance, the app's dock icon is represented in a Retina-scaled size on Retina.
         // Check if a single represenation has a bigger size and in that case use it as the dest size.
         if (sizes != null && sizes.length == 1 &&
             (sizes[0].getWidth() > baseWidth && sizes[0].getHeight() > baseHeight))
         {
-            dstW = (int)sizes[0].getWidth();
-            dstH = (int)sizes[0].getHeight();
+            size = sizes[0];
         }
-        final int dstWidth  = dstW;
-        final int dstHeight = dstH;
+        final int dstWidth  = (int)size.getWidth();
+        final int dstHeight = (int)size.getHeight();
 
 
         return sizes == null || sizes.length < 2 ?
                 new MultiResolutionCachedImage(baseWidth, baseHeight, (width, height)
-                        -> toImage(baseWidth, baseHeight, dstWidth, dstHeight))
+                        -> toImage(dstWidth, dstHeight))
                 : new MultiResolutionCachedImage(baseWidth, baseHeight, sizes, (width, height)
-                        -> toImage(baseWidth, baseHeight, width, height));
+                        -> toImage(width, height));
     }
 
-    private BufferedImage toImage(int srcWidth, int srcHeight, int dstWidth, int dstHeight) {
+    private BufferedImage toImage(int dstWidth, int dstHeight) {
         final BufferedImage bimg = new BufferedImage(dstWidth, dstHeight, BufferedImage.TYPE_INT_ARGB_PRE);
         final DataBufferInt dbi = (DataBufferInt)bimg.getRaster().getDataBuffer();
         final int[] buffer = SunWritableRaster.stealData(dbi, 0);
-        nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight);
+        nativeCopyNSImageIntoArray(ptr, buffer, dstWidth, dstHeight);
         SunWritableRaster.markDirty(dbi);
         return bimg;
     }
diff --git a/src/macosx/native/sun/awt/CImage.m b/src/macosx/native/sun/awt/CImage.m
index ae93d56..da1b952 100644
--- a/src/macosx/native/sun/awt/CImage.m
+++ b/src/macosx/native/sun/awt/CImage.m
@@ -272,24 +272,24 @@
 /*
  * Class:     sun_lwawt_macosx_CImage
  * Method:    nativeCopyNSImageIntoArray
- * Signature: (J[IIIII)V
+ * Signature: (J[III)V
  */
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CImage_nativeCopyNSImageIntoArray
-(JNIEnv *env, jclass klass, jlong nsImgPtr, jintArray buffer, jint sw, jint sh,
-                 jint dw, jint dh)
+        (JNIEnv *env, jclass klass, jlong nsImgPtr, jintArray buffer, jint dw, jint dh)
 {
-JNF_COCOA_ENTER(env);
+    JNF_COCOA_ENTER(env);
 
     NSImage *img = (NSImage *)jlong_to_ptr(nsImgPtr);
     jint *dst = (*env)->GetPrimitiveArrayCritical(env, buffer, NULL);
     if (dst) {
-        NSRect fromRect = NSMakeRect(0, 0, sw, sh);
+        NSSize size = [(NSImage *)jlong_to_ptr(nsImgPtr) size];
+        NSRect fromRect = NSMakeRect(0, 0, size.width, size.height);
         NSRect toRect = NSMakeRect(0, 0, dw, dh);
         CImage_CopyNSImageIntoArray(img, dst, fromRect, toRect);
         (*env)->ReleasePrimitiveArrayCritical(env, buffer, dst, JNI_ABORT);
     }
 
-JNF_COCOA_EXIT(env);
+    JNF_COCOA_EXIT(env);
 }
 
 /*