Cutting up an image.
Author |
Message |
Gooie
|
Posted: Sun Jan 13, 2008 4:29 pm Post subject: Cutting up an image. |
|
|
If I had a set of sprites in one image. Is there a way to pull certain pieces of the image out. Say I had an image like this.
I want to divide it into a 4 by 4 gird. Then pull each image from each point in the gird. It could do it with single images, btu this would be 100x easier for what I want it for. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
zylum
![](http://compsci.ca/v3/uploads/user_avatars/1689129126468091c334ee0.gif)
|
Posted: Sun Jan 13, 2008 4:39 pm Post subject: RE:Cutting up an image. |
|
|
Use a nested for loop to go over the x and y coordinates. You would go over 4 iterations in each loop incrementing by a quarter of the desired dimension (width/height). Then you would use Pic.New to "cut out" each of the sub images and maybe store them in an array.
Pseudo Code:
code: | for x : 0 to 3
for y : 0 to 4
savePic(x, y, x + picWidth/4, y + picHeight/4)
end loop
end loop |
|
|
|
|
|
![](images/spacer.gif) |
Saad
![](http://compsci.ca/v3/uploads/user_avatars/182387547249e7ebb91fb8a.png)
|
Posted: Sun Jan 13, 2008 4:40 pm Post subject: RE:Cutting up an image. |
|
|
Think about it for a second, your given the Width and Height, You know how many rows and columns. You can calculate the x size of each smaller picture and the y size. The x size would be Width/columns and y size would be Heigh/rows.
Then its just a matter of coding a simple program to split each picture into smaller ones. |
|
|
|
|
![](images/spacer.gif) |
Gooie
|
Posted: Sun Jan 13, 2008 4:58 pm Post subject: Re: Cutting up an image. |
|
|
Alright, I suppose that would work, thanks. Bits for all! |
|
|
|
|
![](images/spacer.gif) |
|
|