0

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

任何想法我做错了什么?

4

1 回答 1

0

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

于 2013-07-27T15:06:45.280 回答