answered Feb 18 '13
http://stackoverflow.com/questions/4875372/how-to-slice-cut-an-image-into-pieces
I think this is fairly close to what you need.