唯一的區別是存在兩個不同的作物位置。 問題是爲什麼我得到這個錯誤?線程「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限制 - 看起來很明顯。 –
(除了實際提出問題之外,還應該將異常堆棧跟蹤複製到您的問題中,並確定代碼中與異常相對應的行。) –