唯一的区别是存在两个不同的作物位置。 问题是为什么我得到这个错误?线程“Thread”中的异常java.lang.OutOfMemoryError:请求的数组大小超过VM限制
方法调用
CropRealOriginalImage1 orderName = new CropRealOriginalImage1();
FourAreaCropAgain1 orderNameFirst=new FourAreaCropAgain1();
orderNameFirst.orderNameFirst();
Decode decode= new Decode();
decode.inputImage("C:/TEMP/Image/Embed Image/Four Area/OrderFirst.png");
if(decode.s.equals("")){
System.out.println("OderFirst=null");
}else{
//put b into txt file
System.out.println("decode.s" +decode.s);
}
工作:
public void orderNameFirst(){
ImageIcon icon = new ImageIcon("C:/TEMP/Image/Embed Image/Really Original.png");
image = icon.getImage();
image = createImage(new FilteredImageSource(image.getSource(),
new CropImageFilter(icon.getIconWidth()-290, 0, 10, 33)));
//new CropImageFilter(icon.getIconWidth()/2, icon.getIconHeight()/2, icon.getIconWidth()/2, icon.getIconHeight()/2)));
BufferedImage bufferedImage = new BufferedImage(icon.getIconWidth(),
icon.getIconHeight(), BufferedImage.TYPE_INT_RGB);
Graphics graphics = bufferedImage.getGraphics();
graphics.drawImage(icon.getImage(), 0, 0, null);
Graphics2D g = bufferedImage.createGraphics();
g.setColor(Color.WHITE);
g.fillRect(icon.getIconWidth()-290, 0, 10, 33);
}
不起作用
public void orderNameFirst(){
ImageIcon icon = new ImageIcon("C:/TEMP/Image/Embed Image/Really Original.png");
image = icon.getImage();
image = createImage(new FilteredImageSource(image.getSource(),
new CropImageFilter(3*icon.getIconWidth()/8, 0, icon.getIconWidth()/8, icon.getIconHeight()/2)));
//new CropImageFilter(icon.getIconWidth()/2, icon.getIconHeight()/2, icon.getIconWidth()/2, icon.getIconHeight()/2)));
BufferedImage bufferedImage = new BufferedImage(icon.getIconWidth(),
icon.getIconHeight(), BufferedImage.TYPE_INT_RGB);
Graphics graphics = bufferedImage.getGraphics();
graphics.drawImage(icon.getImage(), 0, 0, null);
Graphics2D g = bufferedImage.createGraphics();
g.setColor(Color.WHITE);
g.fillRect(3*icon.getIconWidth()/8, 0, icon.getIconWidth()/8, icon.getIconHeight()/2);
}
错误:解码integerLength:2147483647 异常的线程“主题” java.lang.OutOfMemoryError:要求数组大小超过VM限制
你忘了问一个问题 – Durandal
请求的数组大小超过VM限制 - 看起来很明显。 –
(除了实际提出问题之外,还应该将异常堆栈跟踪复制到您的问题中,并确定代码中与异常相对应的行。) –