您可以使用內置的核芯顯卡CGDataProviderCreateWithFilename和CGImageCreateWithPNGDataProvider API來打開圖像,然後通過做一些像創建每個片:
const CGSize tileSize = CGSizeMake(256, 256);
const CGPoint tileOrigin = ...; // Calculate using current column, row, and tile size.
const CGRect tileFrame = CGRectMake(-tileOrigin.x, -tileOrigin.y, imageSize.width, imageSize.height);
UIGraphicsBeginImageContextWithOptions(tileSize, YES, 1);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextDrawImage(context, tileFrame, image.CGImage);
UIImage *tileImage = UIGraphicsGetImageFromCurrentImageContext();
[UIImagePNGRepresentation(tileImage) writeToFile:tilePath atomically:YES];
UIGraphicsEndImageContext();
你可能也想看看相關樣品在UIScrollView類參考下引用的項目(大圖縮小和PhotoScroller)。
這實際上工作!大圖像速度非常慢,但至少可以分割圖像。 – miwic