I'm working on an application which reloads an image every once in a while. I did that so I could make changes on the go externally. I'm using ImageIO.read(path) to read the image file.
Now when I want to change the image with my paint.NET and try to save(overwrite) the image, paint.NET throws an IOException. This is probably because ImageIO just claims the image to be his while the process is running. But that's what I think.
The Code is here:
public int width, height;
public int[] pixels;
public Sprite(String ref) {
try {
BufferedImage image = ImageIO.read(new FileInputStream(ref));
width = image.getWidth();
height = image.getHeight();
pixels = new int[width * height];
pixels = image.getRGB(0, 0, width, height, pixels, 0, width);
} catch (IOException e) {
e.printStackTrace();
}
}
Anyone knows how to fix this?
Thanks!