我试图在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秒)
你知道我做错了什么吗?
发布于 2013-07-27 23:06:45
快速更新-我最终使用了UIImageView的Aspect Fit视图选项,这正是我所需要的,然后实际调整服务器端的大小。
https://stackoverflow.com/questions/16308462
复制相似问题