【发布时间】:2013-04-24 21:06:04
【问题描述】:
我正在尝试在 iOS 中缩小 GIF 图像的大小,因此我正在循环遍历每一帧,如下面的代码所示。
NSMutableArray *animationImages = [NSArray arrayWithArray:sourceImage.images];
NSMutableArray *newAnimationImages = [[NSMutableArray alloc] init];
//@autoreleasepool {
UIGraphicsBeginImageContext(CGSizeMake(newWidth, newHeight));
for(UIImage *frame in animationImages) {
[frame drawInRect:CGRectMake(0, 0, newWidth, newHeight)];
UIImage *newFrame = UIGraphicsGetImageFromCurrentImageContext();
[newAnimationImages addObject:newFrame];
}
UIGraphicsEndImageContext();
//}
newImage = [UIImage animatedImageWithImages:newAnimationImages duration:sourceImage.duration];
不幸的是,由于某种原因,调整大小需要很长时间(2-4 秒的 gif 大约需要 3-4 秒)
任何想法我做错了什么?
【问题讨论】:
标签: ios objective-c uiimage nsmutablearray gif