how to read a image in java and convert it to buffered image?
+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
2010-02-15 15:12:25
my answer... but please add at least a `e.printStackTrace()` in the catch block.
Carlos Heuberger
2010-02-15 16:27:55
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
2010-02-15 16:32:14