Лучше всего, вероятно, использовать Core Graphics и ImageI / O
CGImageRef image = ...; // the big image to slice, don't draw with this image or it will decompress and might chew up all your memory
NSURL *url = ...; // the url for this slice
NSString *uti = @"public.jpeg"; // just an example, you should get the correct one for your images
CGSize sliceSize = 256.0; // for example
size_t column = 0;
size_t row = 0; // row and column should vary across your image
CGFloat colWidth = 256.0; // should account for the final column not being 256
CGFloat rowWidth = 256.0; // should account for the final row not being 256
CGRect sliceRect = CGRectMake(floor(column * sliceSize), floor(row * sliceSize),
floor(colWidth), floor(rowHeight));
CGImageRef slicedImage = CGImageCreateWithImageInRect(image, sliceRect);
if(NULL == slicedImage) {
NSLog(@"hosed image");
}
CGImageDestinationRef destination = CGImageDestinationCreateWithURL((CFURLRef)url, (CFStringRef)uti, 1, NULL);
CGImageDestinationAddImage(destination, slicedImage, NULL);
if(!CGImageDestinationFinalize(destination)) {
NSLog(@"hosed write of %@", [url path]);
}
CFRelease(destination);
CGImageRelease(slicedImage);
В качестве предостережения, это складывается из памяти и, вероятно, неправильно.Пожалуйста, прочитайте документы, чтобы увидеть, где я напортачил.
Вот документы по этой технике.
http://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGImage/Reference/reference.html#//apple_ref/c/func/CGImageCreateWithImageInRect
http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Conceptual/ImageIOGuide/imageio_basics/ikpg_basics.html