我需要将一个大图像(大约 10000px 高度)拆分为多个较小的图像,以将它们用作 OpenGL 的纹理,下面是我现在正在做的方式,任何人都有任何想法可以更快地做到这一点,因为它需要很长时间。
NSArray *images = [NSArray alloc] initWith 
for (int i = 0; i<numberOfImages; i++){
    int t = i*origHeight;
    CGRect fromRect = CGRectMake(0, t, origWidth, origHeight); // or whatever rectangle
    CGImageRef drawImage = CGImageCreateWithImageInRect(sourceImage.CGImage, fromRect);
    UIImage *newImage = [UIImage imageWithData:UIImageJPEGRepresentation([UIImage imageWithCGImage:drawImage],1.0)];
    [images addObject:newImage];
    CGImageRelease(drawImage);
}