< prev index next >

modules/graphics/src/main/java/com/sun/javafx/iio/common/ImageTools.java

Print this page
rev 8890 : RT-40778

*** 27,36 **** --- 27,37 ---- import com.sun.javafx.geom.Point2D; import com.sun.javafx.geom.Rectangle; import com.sun.javafx.iio.ImageFrame; import com.sun.javafx.iio.ImageMetadata; + import com.sun.javafx.iio.ImageStorage; import com.sun.javafx.iio.ImageStorage.ImageType; import java.io.EOFException; import java.io.File; import java.io.FileInputStream; import java.io.IOException;
*** 690,699 **** --- 691,736 ---- } return new int[]{finalWidth, finalHeight}; } + + public static ImageFrame scaleImageFrame(ImageFrame src, + int destWidth, int destHeight, boolean isSmooth) + { + int numBands = ImageStorage.getNumBands(src.getImageType()); + ByteBuffer dst = scaleImage((ByteBuffer) src.getImageData(), + src.getWidth(), src.getHeight(), numBands, + destWidth, destHeight, isSmooth); + return new ImageFrame(src.getImageType(), dst, + destWidth, destHeight, destWidth * numBands, null, src.getMetadata()); + } + + public static ByteBuffer scaleImage(ByteBuffer src, + int sourceWidth, int sourceHeight, int numBands, + int destWidth, int destHeight, boolean isSmooth) + { + PushbroomScaler scaler = ScalerFactory.createScaler( + sourceWidth, sourceHeight, numBands, + destWidth, destHeight, isSmooth); + + int stride = sourceWidth * numBands; + if (src.hasArray()) { + byte image[] = src.array(); + for (int y = 0; y != sourceHeight; ++y) { + scaler.putSourceScanline(image, y * stride); + } + } else { + byte scanline[] = new byte[stride]; + for (int y = 0; y != sourceHeight; ++y) { + src.get(scanline); + scaler.putSourceScanline(scanline, 0); + } + } + + return scaler.getDestination(); + } // public static final java.awt.image.BufferedImage getAsBufferedImage(Image prismImage) { // java.awt.image.BufferedImage image = null; // // int width = prismImage.getWidth(); // int height = prismImage.getHeight();
< prev index next >