get Image Data - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage

Description

get Image Data

Demo Code


//package com.java2s;

import java.awt.image.BufferedImage;

public class Main {
    public static int[][] getImageData(BufferedImage image) {
        int width = image.getWidth();
        int height = image.getHeight();
        int[][] imageData = new int[width][height];
        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                imageData[x][y] = image.getRGB(x, y);
            }/*from w  w w. j av  a 2 s. c  o  m*/
        }
        return imageData;
    }
}

Related Tutorials