开发者

How to read big bufferedimage

开发者 https://www.devze.com 2023-03-10 04:58 出处:网络
I am reading a 100 MB pict开发者_如何学Goure into my app. It works fine inside Eclipse, but not when I export project to a JAR. Then, I get \"Can\'t read input file!\"

I am reading a 100 MB pict开发者_如何学Goure into my app. It works fine inside Eclipse, but not when I export project to a JAR. Then, I get "Can't read input file!"

Since I need to edit it, I used BufferedImage.

private String str = "images/1.png";
BufferedImage imageMap;
//in constructor
imageMap = ImageIO.read(new File(str));

I have tried this, but the project image does not load inside Eclipse:

imageMap = ImageIO.read(this.getClass().getClassLoader().getResource(str));


Check you working directory if the image is loaded from the file system. Then you see if your relative path "images/1.png" is valid. Or you directly check the path of your png

System.out.println(new File("."));
File f = new File("images/1.png");
System.out.println(f.getAbsolutePath());
0

精彩评论

暂无评论...
验证码 换一张
取 消