Java examples for 2D Graphics:BufferedImage Pixel
BufferedImage to Pixel Matrix
//package com.java2s; import java.awt.image.BufferedImage; public class Main { public static int[][] toPixelMatrix(BufferedImage G) { int m = G.getWidth(); int n = G.getHeight(); int[][] pixelMatrix = new int[m][n]; for (int i = 0; i < m; ++i) { for (int j = 0; j < n; ++j) { // Getting negatives with JavaFX Image to BufferedImage?? pixelMatrix[i][j] = Math.abs(G.getRGB(i, j)); }// w w w .j av a 2 s.c om } return pixelMatrix; } }