• Post Reply Bookmark Topic Watch Topic
  • New Topic

ImageIO.write gives me Exception_Access_Violation

 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I am trying to open images with the BufferedImage and then write the file using ImageIO.write(...). Sometimes it works, sometimes it loads the file at a bizarre angle and sometimes it throws me right out of the program with an Exception_Access_Violation.

Please could someone help me find a solution for this.

Thanks
rachel
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you could show us the code that is causing problems for you, that would be a big help to us so we can help you. Otherwise we just play a guessing game and get nothing accomplished.
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, here it is... I've narrowed the problem down to this area of code.
(Everything is correctly declared and in a try block)

BufferedImage image = ImageIO.read(chooser.getSelectedFile().toURL());
if (image == null) {
//System.err.println("Invalid input file format");
}
boolean found = ImageIO.write(image, "jpg", outputFile);

BufferedImage newImage = ImageIO.read(outputFile);
theImage = new ImageIcon(newImage);
return theImage;

And like I said, sometimes it works, sometimes the image is loaded at a wierd angle and sometimes it throws that Exception. What I found is that it was occuring primarily when I was trying to open a jpg like this. I solved the problem but checking for if it was a jpg that was trying to be opened and if it is, I simple copy the file and load that instead. Still, I don't know why it was happening and I was hoping someone could tell me.

Thanks!
Rachel
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!