我有一个宽度为 512px 的图像。这段代码会抛出
RasterFormatException (x+width) is outside Raster
我不明白我做错了什么,当我检查光栅大小时,它说它是 512
private void automaticStaticSpriteLoader(String loadedName, String imgLoc, BufferedImage[] biArray, int numberOfSpritesToLoad, int numberOfSpritesInImage, int percentComplete){
try {
temporaryBigImg = ImageIO.read(getClass().getResource(imgLoc + ".png"));
} catch (IOException e) {
System.out.println(classNumber + " Error Loading Sprite Images. Shutting Down.");
e.printStackTrace();
}
for(int i = 0; i<numberOfSpritesToLoad;i++){
biArray[i] = temporaryBigImg.getSubimage(counterX, counterY, 32, 32);
System.out.println("CounterX = " + counterX + " CounterY = " + counterY + " Current Index = " + i);
if(counterX == 512){
counterY += 32;
counterX = -32;
}
counterX+=32;
}
}