src/macosx/classes/sun/lwawt/macosx/CImage.java

Print this page

        

@@ -222,28 +222,15 @@
 
         Dimension2D[] sizes
                 = nativeGetNSImageRepresentationSizes(ptr,
                         size.getWidth(), size.getHeight());
 
-        if (sizes == null || sizes.length < 2) {
-            return toImage(w, h, w, h);
-        }
-
-        BufferedImage[] images = new BufferedImage[sizes.length];
-        int currentImageIndex = 0;
-
-        for (int i = 0; i < sizes.length; i++) {
-            int imageRepWidth = (int) sizes[i].getWidth();
-            int imageRepHeight = (int) sizes[i].getHeight();
+        BufferedImage baseImage = toImage(w, h, w, h);
 
-            if(imageRepHeight <= w && imageRepHeight <= h){
-                currentImageIndex = i;
-            }
-            images[i] = toImage(w, h, imageRepWidth, imageRepHeight);
-        }
-        return new MultiResolutionBufferedImage(BufferedImage.TYPE_INT_ARGB_PRE,
-                currentImageIndex, images);
+        return sizes == null || sizes.length < 2 ? baseImage
+                : new MultiResolutionBufferedImage(baseImage, sizes,
+                        (width, height) -> toImage(w, h, width, height));
     }
 
     private BufferedImage toImage(int srcWidth, int srcHeight, int dstWidth, int dstHeight) {
         final BufferedImage bimg = new BufferedImage(dstWidth, dstHeight, BufferedImage.TYPE_INT_ARGB_PRE);
         final DataBufferInt dbi = (DataBufferInt)bimg.getRaster().getDataBuffer();