为什么位图尺寸更大的内存比在磁盘上的Andr​​oid? [英] Why Bitmap size is bigger in memory than on disk in Android?

查看:197
本文介绍了为什么位图尺寸更大的内存比在磁盘上的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个2448x3264的图像在我消耗1667072字节的SD卡,但是当我打开它作为一个位图,并使用 getRowBytes()*的getHeight()我计算出它的大小结束了15980544个字节。

I have a 2448x3264 image on my SD card that consumes 1,667,072 bytes but when I load it as a Bitmap and calculate its size using getRowBytes()*getHeight() I end up with 15,980,544 bytes.

为什么会出现这种情况,我该如何计算文件的实际尺寸是多少?

Why does this happen and how can I calculate the actual size of the file?

推荐答案

这是因为图像是COM pressed当它在磁盘上(存储在一个JPG,PNG,或类似的格式)。一旦你加载图像到内存中,它不再是COM pressed,并采取了尽可能多的内存是必要的所有像素(通常是宽*高* 4 RGBA_8888,或宽*高* 2 RGB_565)。

That is because the image is compressed when it is on disk (stored in a JPG, PNG, or similar format). Once you load the image into memory, it is no longer compressed and takes up as much memory as is necessary for all the pixels (typically width * height * 4 for RGBA_8888, or width * height * 2 for RGB_565).

这篇关于为什么位图尺寸更大的内存比在磁盘上的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆