Skip to main content
gamedev.net
🔒 Locked

[java] tile images

Started by deonbotha 3 replies 650+ views
Original Post
deonbotha
deonbotha
I have an image consisting of a few tiles: what I want to do it extract each tile and put it in an Image array, how do I go about copying a part of that image specified by coords into a new image?
-----------------[ serafin studios ]
Vyper_uk
Vyper_uk
It might be easier to have each of the tiles as individual images rather than having them all as one big image. Theres a discussion about tiles vs tilesets floating around the isometric forum if I remember
deonbotha
deonbotha
granted yea it is easier just to use the individual image, it's what I'm doing at the moment. I'm just trying to implement it as a tileset to learn something new, but I'm having trouble finding a way to copy part of an existing image into a new image... any help?
-----------------[ serafin studios ]
stormrunner
stormrunner
Quote:
Original post by deonbotha
what I want to do it extract each tile and put it in an Image array,

You've got a couple of options. The first - and probably easiest, as you're already using Images - is to simply crop the image using a CropImageFilter.

The second way is to use an array of BufferedImages instead. The main image (tileset) would be loaded using a BufferedImage, and then you'd use the BufferedImage.getSubimage method to obtain the smaller images and copy them.

Both examples (basic usage) are demonstrated here. There are also other Image resources there that might be of interest.
stormrunner
deonbotha
deonbotha
thanks stormrunner, thats awesome, exactly what I wanted!
-----------------[ serafin studios ]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.