Here you can find the source of getRgbFromImage(BufferedImage image)
Parameter | Description |
---|---|
image | Image |
public static List<int[][]> getRgbFromImage(BufferedImage image)
//package com.java2s; //License from project: Open Source License import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; public class Main { /**/* w w w . j ava 2s.co m*/ * Get RGB data array from given image * * @param image Image * @return List with three elements of two-dimensional int's - R, G and B */ public static List<int[][]> getRgbFromImage(BufferedImage image) { List<int[][]> rgb = new ArrayList<int[][]>(); int[][] r = null; int[][] g = null; int[][] b = null; int width = 0; int height = 0; width = image.getWidth(); height = image.getHeight(); r = new int[height][width]; g = new int[height][width]; b = new int[height][width]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { r[i][j] = (image.getRGB(j, i) >> 16) & 0xFF; g[i][j] = (image.getRGB(j, i) >> 8) & 0xFF; b[i][j] = (image.getRGB(j, i) >> 0) & 0xFF; } } rgb.add(r); rgb.add(g); rgb.add(b); return rgb; } }