Files
knowledge-kit/Chapter1 - iOS/1.90.md
杭城小刘 e89fe0ca1c docs: 内容
2020-11-08 15:51:47 +08:00

32 lines
897 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# YYImage 框架原理,探索图片高效加载原理
## 图片显示流程
![image-20200813130942777](/Users/lbp/Desktop/Github/knowledge-kit/assets/2020-08-13-ImageRenderProcess.png)
```objective-c
UIImage *image = [UIImage imageNamed:@"test"];
_imageView.image = image;
```
上述的代码叫做“隐形解码”。 代码测试一张图片从磁盘读取到内存中,通过 Instrucments 中的 Time Profiler 分析得到,从磁盘调用 ImageIO 中方法加载到内存中,这个过程比较耗时。
图片大,则需要更大的空间去将 Data Buffer 计算得到 Image Buffer
所以将图片解码过程,放到异步线程中去。
## YYImage 源码
![image-20200813131944130](/Users/lbp/Desktop/Github/knowledge-kit/assets/2020-08-13-YYImageClassLevel.png)
很多框架使用锁都是 pthread_mutex_lock分析原因
pthread_mutex_lock
pthread_mutex_unlock