tags:

views:

97

answers:

2

how to read a image in java and convert it to buffered image?

+2  A: 

See ImageIO.read().

extraneon
+5  A: 

You need the Java 2D API for this. Here's a Sun tutorial about the subject. In the "Working with Images" chapter you can learn how to read/load an image. Here's an extract of the tutorial:

BufferedImage img = null;
try {
    img = ImageIO.read(new File("strawberry.jpg"));
} catch (IOException e) {

}
BalusC
my answer... but please add at least a `e.printStackTrace()` in the catch block.
Carlos Heuberger
Tell that the Sun guys ;) It was an 1:1 copypaste. But indeed certainly you need to handle the exception somehow instead of ignoring it.
BalusC