android 位图大小依赖性基于分辨率或文件大小
android bitmap size dependency is based on resolution or file size
我有两张 jpg images.one 图片大小约为 1 MB,另一张小于 100KB.but 两张图片的分辨率相同。现在这些图像应该加载到图像视图中。加载这些图像时的内存分配将取决于文件大小或分辨率?
这取决于分辨率,而不是文件大小。图片在加载时会解压到内存中,所以两张相同分辨率的图片占用的内存量是一样的。
您可以使用 getByteCount() or getAllocationByteCount()(KitKat 及更高版本)验证加载到 ImageView 中的位图的内存使用情况。
例如:
ImageView image = (ImageView)findViewById(R.id.image1);
int bytesUsed = ((BitmapDrawable)image.getDrawable()).getBitmap().getAllocationByteCount();
我有两张 jpg images.one 图片大小约为 1 MB,另一张小于 100KB.but 两张图片的分辨率相同。现在这些图像应该加载到图像视图中。加载这些图像时的内存分配将取决于文件大小或分辨率?
这取决于分辨率,而不是文件大小。图片在加载时会解压到内存中,所以两张相同分辨率的图片占用的内存量是一样的。
您可以使用 getByteCount() or getAllocationByteCount()(KitKat 及更高版本)验证加载到 ImageView 中的位图的内存使用情况。
例如:
ImageView image = (ImageView)findViewById(R.id.image1);
int bytesUsed = ((BitmapDrawable)image.getDrawable()).getBitmap().getAllocationByteCount();