Java examples for 2D Graphics:Pixel
grab 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[] grabPixels(BufferedImage image, boolean forceRGB) { PixelGrabber pixelGrabber = new PixelGrabber(image, 0, 0, image.getWidth(), image.getHeight(), forceRGB); pixelGrabber.startGrabbing();/* w ww.j a va 2 s .com*/ int[] pixels = (int[]) pixelGrabber.getPixels(); return pixels; } public static int[] grabPixels(BufferedImage image) { return grabPixels(image, true); } }