【发布时间】:2011-11-16 14:39:27
【问题描述】:
给定一张灰度的图像,我如何获得该位置的灰度像素值?
这始终将 temp 输出为 -16777216(黑色)。
public void testMethod()
{
int width = imgMazeImage.getWidth();
int height = imgMazeImage.getHeight();
//Assign class variable as a new image with RGB formatting
imgMazeImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
for(int i=0; i < width; i ++){
for(int j=0; j < height; j++)
{
//Grab and set the colors one-by-one
inttemp = imgMazeImage.getRGB(j, i);
System.out.println(temp);
}
}
}
【问题讨论】:
标签: java bufferedimage grayscale