Question Split an image into seperate 32x32 peices


May 26, 2009
Programming Experience
Hi all, I'm new in these forums (and to vb or .net) so go easy on me!

My question is, what is the simpleist way to split an image (384 x 256) into smaller peices (32 x 32). I will be using the images seperated only for animation and I dont need to save them or anything like that. I'm new to the whole programming concept and I hope is as easy as I'm hoping, I'v only made a couple of programs so explain well! thanks in advance, ell.

Ps. Im using visual basic 2008 express edtion.


Well-known member
Aug 30, 2005
Cambridge, UK
Programming Experience
GDI+ can handle this for you, though i'm not sure how well it will perform. There is a function in the Graphics class called DrawImage. It has about 25+ overloads and one of them accepts arguments for a source bitmap for which you can provide co-ordinates of the part of the image you want, you could run this in a loop and then save the part of the image to a bitmap array.


Simply set up the co-ordinates of the part of the images you need in the order you need them maybe in a two dimensional array of integers. Then during the animation you can just supply a routine with the current frame coordinates and draw that part of the image to where ever you need.

Personally I think this may be better accomplished by breaking down the image into frames in a photo editor and then loading them into an image list or bitmap array. Multiple calls to GDI+ will start to become expensive due to the number of interop calls, so it's best to eliminate unnecessary P/Invoking where possible.

Latest posts

Top Bottom