< prev index next >

modules/graphics/src/main/java/com/sun/javafx/iio/png/PNGImageLoader2.java

Print this page
rev 8890 : RT-40778

@@ -293,17 +293,10 @@
     }
 
     public void dispose() {
     }
 
-    private ImageMetadata updateMetadata() {
-        ImageMetadata metaData = new ImageMetadata(null, true,
-                null, null, null, null, null, width, height, null, null, null);
-        updateImageMetadata(metaData);
-        return metaData;
-    }
-
     private ImageStorage.ImageType getType() {
         switch (colorType) {
             case PNG_COLOR_GRAY:
                 return tRNS_present
                         ? ImageStorage.ImageType.GRAY_ALPHA

@@ -645,13 +638,20 @@
         if (dataSize == 0) {
             emitWarning("No image data in PNG");
             return null;
         }
 
+        int[] outWH = ImageTools.computeDimensions(width, height, rWidth, rHeight, preserveAspectRatio);
+        rWidth = outWH[0];
+        rHeight = outWH[1];
+        
+        ImageMetadata metaData = new ImageMetadata(null, true,
+                null, null, null, null, null, rWidth, rHeight, null, null, null);
+        updateImageMetadata(metaData);
+
         int bpp = bpp();
         ByteBuffer bb = ByteBuffer.allocate(bpp * width * height);
-        ImageMetadata metadata = updateMetadata();
 
         PNGIDATChunkInputStream iDat = new PNGIDATChunkInputStream(stream, dataSize);
         Inflater inf = new Inflater();
         InputStream data = new BufferedInputStream(new InflaterInputStream(iDat, inf));
 

@@ -664,33 +664,15 @@
                 inf.end();
             }
         }
 
         ImageFrame imgPNG = colorType == PNG_COLOR_PALETTE
-                ? decodePalette(bb.array(), metadata)
-                : new ImageFrame(getType(), bb, width, height, bpp * width, palette, metadata);
+                ? decodePalette(bb.array(), metaData)
+                : new ImageFrame(getType(), bb, width, height, bpp * width, palette, metaData);
 
-        // need remove scaler form loader
-        int[] outWH = ImageTools.computeDimensions(width, height, rWidth, rHeight, preserveAspectRatio);
-
-        if (width != outWH[0] || height != outWH[1]) {
-            imgPNG = scaleImage(imgPNG, outWH[0], outWH[1], smooth);
+        if (width != rWidth || height != rHeight) {
+            imgPNG = ImageTools.scaleImageFrame(imgPNG, rWidth, rHeight, smooth);
         }
 
         return imgPNG;
     }
-
-    private ImageFrame scaleImage(ImageFrame imgPNG, int rWidth, int rHeight, boolean smooth) {
-        byte image[] = ((ByteBuffer) imgPNG.getImageData()).array();
-        int bpp = ImageStorage.getNumBands(imgPNG.getImageType());
-
-        PushbroomScaler scaler = ScalerFactory.createScaler(width, height, bpp,
-                rWidth, rHeight, smooth);
-
-        for (int y = 0; y != height; ++y) {
-            scaler.putSourceScanline(image, y * width * bpp);
-        }
-
-        return new ImageFrame(imgPNG.getImageType(), scaler.getDestination(),
-                rWidth, rHeight, rWidth * bpp, null, imgPNG.getMetadata());
-    }
 }
< prev index next >