Java examples for 2D Graphics:BufferedImage Pixel
image To Pixels
import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.PixelGrabber; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.JFrame; import javax.swing.JPanel; import org.apache.log4j.Logger; public class Main{ public static int[] imageToPixels(BufferedImage source) { PixelGrabber pixelGrabber = new PixelGrabber(source, 0, 0, source.getWidth(), source.getHeight(), true); pixelGrabber.startGrabbing();// w w w .j a va 2 s. c o m int[] pixels = (int[]) pixelGrabber.getPixels(); return pixels; } }