当前位置:网站首页>Bitmap load memory analysis
Bitmap load memory analysis
2022-06-23 23:32:00 【MirkoWug】
One 、Bitmap Memory
1.Bitmap How memory is calculated
1.decodeResource from drawable、mipmap The corresponding file directory is loaded with pictures Bitamp Occupied memory size = Width pixels x (inTargetDensity / inDensity) x Height pixel x (inTargetDensity / inDensity)x Memory occupied by one pixel inTargetDensity : The equipment dpiinDensity : Current file location drawable Folder Directory Corresponding dpi
Memory occupied by one pixel , There are several pixel formats :
ALPHA_8 1byte
ARGB_4444 2byte
ARGB_8888 4byte
RGB_565 2byte
2. From local disk 、asset、 And so on Bitamp Occupied memory size = Width pixels x Height pixel x Memory occupied by one pixel
Be careful : When using third-party libraries , These formulas cannot be used to calculate , Because the internal memory of the third-party library will be re optimized .
eg:
fresco: No matter where the picture comes from , Even if it's res, The memory size occupied by the image is still calculated according to the resolution of the original image .
Glide: If there is a control to set the picture display , Then it will be automatically according to the size of the control , Reduce the resolution of the picture . The source of the picture is res The resolution conversion rule of is also invalid for it .
Be careful :Bitmap The memory size of And the pixel size is different .
Memory size = Pixel size ( I.e. picture width x high )x Memory occupied by one pixel
Two 、 Two factors that affect memory
1、 Image resolution , That is, the size of the picture
2、 The amount of memory occupied by pixels , Corresponding 4 Two pixel formats
So when I do memory optimization , We can start from these two aspects :
1. Reduce the size of the picture
2. Adjust to pixel format that takes up less memory .
In development , We prefer the first , Because changing the pixel format , It will cause the picture quality to decline , Cause distortion .
And for the first , You can refer to Luban
3、 ... and 、 Conclusion
- The source of the picture is res When different resource directories within , The system will be based on the current status of the equipment dpi Value and the corresponding resource directory dpi value , Do a resolution conversion , The following rules : New resolution = The horizontal resolution of the original image * ( The equipment dpi / The directory corresponds to dpi ) * The vertical resolution of the original image * ( The equipment dpi / The directory corresponds to dpi ).
- Source of other pictures , Disk , file , Flow, etc. , The memory size of the image is calculated according to the resolution of the original image .
- jpg、png Just a container for pictures , The storage size of the image file itself has nothing to do with the memory size it occupies .
Reference resources
1.Bitmap analysis
2.https://www.cnblogs.com/dasusu/p/9789389.html
3.Bitmap analysis
边栏推荐
- 远程办公之:如何成为时间管理大师?| 社区征文
- How to index websites in Google
- 【HackTheBox】Fawn
- 在OpenCloudOS使用snap安装.NET 6
- Summary of cloud native pipeline tools
- Stm32 - - - - interruption externe
- 小程序容器到底是什么
- Kotlin 集合List 、Set、Map操作汇总
- The 12 SQL optimization schemes summarized by professional "brick moving" old drivers are very practical!
- 生鲜前置仓的面子和里子
猜你喜欢

Sorry, your USB cable may be wrong!

The Sandbox 归属周来啦!

Detailed quaternion
云原生流水线工具汇总

Analysis on the advantages and disadvantages of the best 12 project management systems at home and abroad
MySQL导致索引失效的几种情况

Flutter中的GetX状态管理用起来真的那么香吗?

Generate post order traversal according to pre order traversal and mid order traversal

laravel之任务队列

Develop synergy and efficiently manage | community essay solicitation
随机推荐
HDLBits-> Circuits-> Arithmetic Circuitd-> 3-bit binary adder
Isolement des transactions MySQL
【观察】戴尔科技+英特尔傲腾技术:以“纳秒之速”领跑存储创新
STM32-------外部中断
Kotlin 协程 异步 异步流
堡垒机安装pytorch,mmcv,mmclassification,并训练自己的数据集
【HackTheBox】 meow
Sorry, your USB cable may be wrong!
迪赛智慧数——柱状图(基本柱状图):2022年父亲节过节的方式
【设计】1359- Umi3 如何实现插件化架构
Some explanations of Tim timer of embedded interface and STM32 template library function of NVIC
What is the development prospect of face recognition technology?
How to connect the fortress machine to the new server? What can I do if there is a problem with the fortress machine?
Kotlin coroutine asynchronous flow
Construction of cache stack FIFO in different application scenarios for PLC data operation series (detailed algorithm explanation)
C# 读取内存条占用大小,硬盘占用大小
Can the characteristics of different network structures be compared? Ant & meituan & NTU & Ali proposed a cross architecture self supervised video representation learning method CaCl, performance SOTA
谈谈数字化转型晓知识
STM32------ADC(电压检测)
对不起,你的USB走线可能搞错了!