I have made a small piece of code to split spritesheets into seperate images...
private BufferedImage sheet, dirt, grass, rock, tree, water;
int width = 64, height = 64;
public void split() {
dirt = sheet.getSubimage(0,0,width,height);
grass = sheet.getSubimage(width,0,width*2,height);
rock = sheet.getSubimage(width*2,0,width*3,height);
tree = sheet.getSubimage(0,height,width,height*2);
water = sheet.getSubimage(width,height,width*2,height*2);
}
Now, the first two (dirt and grass) go well as expected. However, the issue is with the rock cropping line. For some reason it drops an exception...
"
Exception in thread "Thread-0" java.awt.image.RasterFormatException: (x + width) is outside of Raster
at sun.awt.image.ByteInterleavedRaster.createWritableChild(ByteInterleavedRaster.java:1245)
"
So apparently the issue is to do with the x value being "out of bounds". But the x value is (width * 2), so 128pix, which is well in bounds of this image (192x128), which I've attached as proof.
I've also changed the code a little to crop with the x value being 1 for rock but I still get the issue, same with using the same dimensions for anothe bufferedImage.
Sorry for anything wrong in this post, it's my first time.
Thanks in advance