internal use - get buffer from image BufferedImage - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage

Description

internal use - get buffer from image BufferedImage

Demo Code


//package com.java2s;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;

public class Main {
    /**/*w  w  w  .jav  a 2  s .c o  m*/
     * internal use - get buffer from image
     * @param scaledImage
     * @param deviceXSize
     * @param deviceYSize
     * @return
     */
    private static int[] getPixelsFromImage(BufferedImage scaledImage,
            int deviceXSize, int deviceYSize) {
        //painfull slow!
        //return scaledImage.getRGB(0, 0, deviceXSize, deviceYSize, null, 0, deviceXSize);
        DataBufferInt buf = (DataBufferInt) scaledImage.getRaster()
                .getDataBuffer();
        return buf.getData();
    }
}

Related Tutorials