Splitting up an Image
I have an image which always has the height of 32 (pixels). The length is 32*?. I want to divide the image into ? pieces each with the height of 32 and the length of 32. Im this far:
// Variables
public Image pic;
// The Method
pic = load(path);// my custom method (it works)
// Following is Pseudocode
for(Image/32)
{
vector.add(image.cutoff(0,0,32,32);
}
thats how it is supposed to work. The problem is i don't know how i can transalate the pseudo-code into real code :(. Also i dont have much experience whith vectors :(.
> How do i use that method?
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/image/BufferedImage.html#getSubimage(int,%20int,%20int,%20int)
> How do i draw a buffered image onto a canvas?
BufferedImage is a subclass of Image, so you can pass it to the drawImage() method just like you could with the image object.
> Thanks! on that website i also found methods like
> gettilex and gettiley.
It's amazing all the information that you can find in the API. ;-)
Here's a reference link: http://java.sun.com/j2se/1.5.0/docs/api/
> What do they do? Whats meant by tile?
Click on the method and it will tell you:
- What the method does.
- What the parameters are.
- What the method returns.
- What exceptions (if any) the method throws.