How can I split an Image object (java.awt.Image
) into smaller images?
For example, splitting a 64*64px image into a sprite sheet of sixteen 16*16px images.
See: http://rameshjavablog.blogspot.com/2012/04/sub-image-from-image-using-java.html
Using a function like:
image = createImage(new FilteredImageSource(image.getSource(),new CropImageFilter(13, 13, 143, 163)));
You are creating an image using the 'crop image filter').
Then it should just be a matter of iterating through the original image grabbing the different squares you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With