This site requires JavaScript, please enable it in your browser!
Greenfoot back
actinium
actinium wrote ...

2012/12/14

Chopping up an image

actinium actinium

2012/12/14

#
Is there any way to cut an image up into a sequence of squares.
Zamoht Zamoht

2012/12/14

#
http://www.greenfoot.org/scenarios/5815 check out my scenario it might help you.
actinium actinium

2012/12/14

#
I was thinking along the lines of using a bufferedImage. Nice scenario Zamoht.
danpost danpost

2012/12/14

#
You can create an array of GreenfootImage objects from a larger image using something like the following:
GreenfootImage bigImage = new GreenfootImage("bigImageName");
int w=bigImage.getWidth(), h=bigImage.getHeight();
int numImagesAcross=a=2, numImagesDown=d=2;
GreenfootImage[][] smallImages = new GreenfootImage[a][d];
for(int x=0; x<a; x++)
for(int y=0; y<d; y++)
{
    smallImages[x][y]=new GreenfootImage(w/a, h/d);
    smallImages[x][y].drawImage(bigImage, -x*w/a, -y*h/d);
}
actinium actinium

2012/12/14

#
Thanks all, that looks like what i need danpost. Thanks also zamoht.
You need to login to post a reply.