繁体   English   中英

逐帧调整动画UIImage的大小非常慢

[英]Very slow to resize animated UIImage frame by frame

我正在尝试在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为2-4秒)

有什么想法我做错了吗?

快速更新-我最终对UIImageView使用了Aspect Fit视图选项,该选项完全满足了我的需要,然后对服务器端进行了实际的调整大小。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM