Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Cutting up an image.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Gooie




PostPosted: 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.

Posted Image, might have been reduced in size. Click Image to view fullscreen.

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.
Sponsor
Sponsor
Sponsor
sponsor
zylum




PostPosted: 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
Saad




PostPosted: 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.
Gooie




PostPosted: Sun Jan 13, 2008 4:58 pm   Post subject: Re: Cutting up an image.

Alright, I suppose that would work, thanks. Bits for all!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: