get BufferedImage Color Int Matrix - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Color

Description

get BufferedImage Color Int Matrix

Demo Code


//package com.java2s;

import java.awt.image.BufferedImage;

public class Main {
    public static int[][] getColorIntMatrix(BufferedImage image) {

        int height = image.getHeight();
        int width = image.getWidth();
        int[][] colorMatrix = new int[width][height];

        for (int i = 0; i < width; i++) {
            for (int j = 0; j < height; j++) {
                colorMatrix[i][j] = image.getRGB(i, j);
            }/*from  ww w .  j av  a  2s .  co m*/
        }

        return colorMatrix;

    }
}

Related Tutorials