我正在尝试在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秒)
任何想法我做错了什么?
答案 0 :(得分:0)
快速更新 - 我最终使用了适合UIImageView的Aspect Fit视图选项,它完全符合我的需要,然后进行了实际调整大小的服务器端。