3
画像がのグレースケールにある場合、グレースケールのピクセル値はどのように取得されますか?BufferedImage - グレースケール
これは、いつも-16777216
(黒)として一時的に出力します。
imgMazeImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
ピクセルはデフォルト値を使用して作成し、その論理され、それらはすべて同じ色を持っていること(黒):あなたは、新しい空白のイメージを作成し、あなたのクラス変数に代入されている
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);
}
}
}