Search code examples
javaimageimage-processingbufferedimagecolor-channel

What is the difference between the ways to read an Image file in Java?


There are various ways of reading an image file in java such as BufferedImage and ImageIcon to name a few. I want to know what is the difference between these cases? Are they context dependent that in a particular case only one of them can be used?

What would be the best way of reading a image selected by JFileChooser by the user and separating the color channels of an image?


Solution

  • A good way is to use the different ImageIO.read methods, which return BufferedImage objects.

    Image is an abstract class, so I think the real question is which subclass is more efficient for your program. Use VolatileImage if you need hardware acceleration. More on that here.