Display pixel value
I'm planning of loading a black and white 10X10 gif
then I want to print value of each pixel (like black 1; white 0)
I have coded till this much. after grabbing the pixels using my object called pixelGrabber,
I read in oracle that the method grabPixels() returns only an object. which class's object is it returning?
how can I print each pixels' data?
Please do help. :(sweat):
I am new in java I cant understand very complex stuff. :(nod):
public static void main(String args)throws Exception
img = ImageIO.read(new File("abc.gif"));
int Width = img.getWidth();
int Height = img.getHeight();
PixelGrabber pixelGrabber=new PixelGrabber(img,0,0,Width,Height,false);
Re: Display pixel value
There is no need to use pixel grabber. BufferedImage has a method - getRGB() which returns an RGB int value of the pixel at the supplied coordinates. You can use the Color methods to interrogate the returned int value.