I'm trying to write some simple code to resize an image, and I am getting a JVM crash. As far as I can tell I'm using the APIs correctly. Here is the code:
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
public class Resizer {
public static void main(String[] args) {
BufferedImage img = null;
try {
img = ImageIO.read(new File("C:\\Users\\Owner\\Desktop\\export\\10.jpg"));
} catch (IOException e) {
System.out.println(e);
return;
}
RescaleOp ro = new RescaleOp(1.25f, 0.0f, null);
BufferedImage output = ro.filter(img, null); //JVM CRASHES ON THIS LINE
// Also crashes if I use these lines instead:
//BufferedImage output = ro.createCompatibleDestImage(img, img.getColorModel());
//ro.filter(img, output);
try {
ImageIO.write(output, "png", new File("C:\\Users\\Owner\\Desktop\\export\\10.output.png"));
} catch (IOException ioe) {
System.out.println(ioe);
return;
}
}
}
And I'm getting this error:
# # An unexpected error has been detected by Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d524c5d, pid=13076, tid=11172 # # Java VM: Java HotSpot(TM) Client VM (10.0-b23 mixed mode windows-x86) # Problematic frame: # C [mlib_image.dll+0x54c5d] # # An error report file with more information is saved as: # C:\Users\Owner\Documents\src\Java\ImageSizer\hs_err_pid13076.log # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. #