What would be the best way to get pixel information from a picture shown in a jlabel? I am using NetBeans 5.5.1.
posted 9 years ago
If you used a BufferedImage for the ImageIcon in the JLabel you can get a reference to it and use the getRGB(int x, int y) method to get the int (Color) value for any pixel. Then you can unpack the color components from the int. If you didn't use a BufferedImage in the ImageIcon you have a couple of options: 1 - get a reference to the image and draw it into a BufferedImage to use as above; 2 - use the image and the PixelGrabber class to get the pixels from the image and carry on as before. The PixelGrabber class has an example including how to unpack the color components from the int value.