get Colors from BufferedImage - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Color

Description

get Colors from BufferedImage

Demo Code


import java.awt.Color;
import java.awt.image.BufferedImage;

public class Main{
    public static Color[][] getColors(final BufferedImage image) {
        final int w = image.getWidth();
        final int h = image.getHeight();
        final Color[][] colors = new Color[w][h];
        for (int x = 0; x < w; x++) {
            for (int y = 0; y < h; y++) {
                colors[x][y] = ImageUtil.getColorAt(image, x, y);
            }/*from w ww. j a v  a2  s .c o  m*/
        }
        return colors;
    }
}

Related Tutorials