如何检查图像中特定像素的颜色?
我正在寻找的示例是从 link 中的 png 文件生成 map 。
最佳答案
Google 上的首次点击:Getting and Setting Pixels in a Buffered Image
// Get a pixel
int rgb = bufferedImage.getRGB(x, y);
// Get all the pixels
int w = bufferedImage.getWidth(null);
int h = bufferedImage.getHeight(null);
int[] rgbs = new int[w*h];
bufferedImage.getRGB(0, 0, w, h, rgbs, 0, w);
您还可以使用 bufferedImage.getRaster().getPixel(...)
方法。
关于java - 从图像文件中识别像素颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7166722/