图片边加载边显示,类似浏览器有什么解决方案

2015-10-19 00:00:22 +08:00
 Ixizi
图片一点一点加载。从不清晰的像素点加载到完整图片,或者从上往下加载…

然后我想要用在 cell 中…
我网络断了,我显示半个未加载完的图片在那。
3498 次点击
所在节点    iDev
6 条回复
qq286735628
2015-10-19 00:04:22 +08:00
这是 JPEG 格式的特性,用 PS 导出的时候,勾上‘连续’即可

http://image.zhangxinxu.com/image/blog/201301/2013-01-07_181001.png

详情搜一下渐进式 JPEG
lightforce
2015-10-19 00:34:42 +08:00
progressive feature
loveuqian
2015-10-19 00:49:11 +08:00
@qq286735628 学习了
ibremn
2015-10-19 01:03:30 +08:00
progressive/interlaced 是只由模糊变清晰,这个需要图片本身处理过,网上这种图片比较少。
一般图片默认是 baseline 的,即逐行加载。
下面这段代码可以支持 baseline/progressive/interlaced JPEG/PNG/GIF :

CGImageSourceRef source = CGImageSourceCreateIncremental(NULL);
while (dataArrived) {
CGImageSourceUpdateData(source, (__bridge CFDataRef)data, false);
if (CGImageSourceGetCount(source) > 0) {
CGImageRef imageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL);
UIImage *image = [UIImage imageWithCGImage:imageRef scale:screenScale];
/// display
}
}
sneezry
2015-10-19 03:10:39 +08:00
png 也是支持的, ps 里勾选“交错”
xuzhongzhou
2015-10-19 12:57:54 +08:00
[Concorde]( https://github.com/contentful-labs/Concorde.git) Download and decode progressive JPEGs on iOS.

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/229060

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX