Question

Given an image that is in grayscale, how would I get the pixel values of the grayscale at that location?

This outputs temp as -16777216 (black) all the time.

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);
        }
    }
}

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top