Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split an image into multiple smaller images

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.

like image 502
Kacper Lubisz Avatar asked May 20 '13 17:05

Kacper Lubisz


1 Answers

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.

like image 185
obaqueiro Avatar answered Oct 06 '22 21:10

obaqueiro