Hello, i want to know how to open an image in java? For example, I already have an image .jpg, and i need to open it in java so that i can do the image processing. Anybody can help me?
Printable View
Hello, i want to know how to open an image in java? For example, I already have an image .jpg, and i need to open it in java so that i can do the image processing. Anybody can help me?
Have a look at the ImageIO class; it has methods that can read image files and create a BufferedImage out of them. You can also try to use the ImageIcon class ...
kind regards,
Jos
I have try this coding, but i can't open the image. I don't know why.
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
File file = new File("sign.jpg");
BufferedImage img;
img = ImageIO.read(file);
Maybe your program runs in a directory different from where your sign.jpg file is stored; try to use an absolute path name, e.g. "c:/usr/foo/sign.jpg". If you want to see where your program is running, add the following line:
kind regards,Code:System.out.println(System.getProperty("user.dir"));
Jos
It still have error. Is it have different kind of coding if I use drjava software? Here i attach a picture shown the error when I compile it Attachment 1912Attachment 1913
Where is your class?
Where is your methods?
class? method? I'm sorry but I have zero knowledge about java. :=(: