【问题标题】:Very slow to resize animated UIImage frame by frame逐帧调整动画 UIImage 的大小非常慢
【发布时间】: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


    【解决方案1】:

    快速更新 - 我最终为 UIImageView 使用了 Aspect Fit 视图选项,这正是我需要的,然后在服务器端进行了实际的调整大小。

    【讨论】:

      猜你喜欢
      • 2014-04-02
      • 1970-01-01
      • 2013-06-22
      • 2018-01-18
      • 1970-01-01
      • 1970-01-01
      • 2017-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多