获取Android的位图大小 [英] Get size of Bitmap Android

查看:255
本文介绍了获取Android的位图大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  解码后位图字节大小?

反正是有这样我就可以得到这个位图的大小?我试图用getByteCount(),但我不能用它?

Is there anyway so I can get the size of this Bitmap?I've tried to use getByteCount() but I can't use it?

Bitmap bitmap = BitmapFactory.decodeByteArray(decryptedData , 0, decryptedData .length);    //decoding bytearrayoutputstream to bitmap

有什么建议?

推荐答案

你可以从的 API ,您可以用

getWidth()
getHeight()

有以像素为单位的位图的大小。

for the size of the Bitmap in pixels.

而如果它是一个字节数组(8位= 1字节),那么只取 decryptedData.length - 偏移,你知道多少字节的位图

And if it is an array of bytes (8bit = 1byte) then just take decryptedData.length - offset and you know how many bytes are in the Bitmap.

还是我失去了一些东西?

Or am I missing something here?

这篇关于获取Android的位图大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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