SDWebImage / SDWebImage/SDWebImageWebPCoder
Skipping frames for Animated WebP
还没有人认领这个 Issue。
- 主要语言
- Objective-C
- 星标
- 277
- 派生
- 101
- PR 合并指标
- 30 天内没有已合并 PR
描述
It would be good to have an option to skip frames for animated webP.
If I have a thumbnail trying to render an animated wepb image with 120 frames it could be good to render only 30 frames, to preserve speed and memory.
Maybe not the first 30 frames but skipping frames in a loop: the animation will not be very smooth obviously.
A simple, not nice looking solution to skip half of the frames:
SDImageWebPCoder.m
line 264
Adding a skipper in the loop and duplicating the duration
int skipper = 0;
do {
skipper++;
if ((skipper %2) == 0) {
continue;
}
@autoreleasepool {
CGImageRef imageRef = [self sd_drawnWebpImageWithCanvas:canvas iterator:iter colorSpace:colorSpace scaledSize:scaledSize];
if (!imageRef) {
continue;
}
#if SD_UIKIT || SD_WATCH
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp];
#else
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:kCGImagePropertyOrientationUp];
#endif
CGImageRelease(imageRef);
NSTimeInterval duration = [self sd_frameDurationWithIterator:iter];
SDImageFrame *frame = [SDImageFrame frameWithImage:image duration:(duration*2)];
[frames addObject:frame];
}
} while (WebPDemuxNextFrame(&iter));
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 SDImageWebPCoder.m 中大约第 264 行开始,这里会解码动画 WebP 帧并收集其持续时间。确定应如何在受支持的 Apple 平台上公开并保留一个选择性启用的帧跳过选项,然后使用动画 WebP fixture 验证最终的帧数和动画时序。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- objective-c
- 领域
- mobile-dev
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100