如何访问索引图像(png8或gif)的图像数据(调色板索引数组)?
示例:
我需要的是:
ArrayList<Integer> getImageData(File image) {
/* ??? */
}
答案 0 :(得分:0)
以下代码会将图片数据读入imageData
int
数组。
BufferedImage image = ImageIO.read(imageFile);
int width = image.getWidth();
int height = image.getHeight();
int[] imageData = new int[width * height * image.getColorModel().getNumComponents()];
imageData = image.getData().getPixels(0, 0, width, height, imageData);