如何获得在Android的图像的大小? [英] How to get the size of an image in Android?

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

问题描述

我能够获得的图像的高度和宽度。但有一个检索的大小(以字节为单位或KB或MB),用于存储在手机图像的方法?

I'm able to get the height and width of an image. But is there a method to retrieve the size (in bytes or kb or mb) for an image stored in the phone?

推荐答案

感谢您的答案。这就是我终于解决了它:

Thank you for your answers. This is how I finally resolved it:

 Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), 
            R.drawable.ic_launcher);


     Bitmap bitmap = bitmapOrg;
     ByteArrayOutputStream stream = new ByteArrayOutputStream();   
     bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);   
     byte[] imageInByte = stream.toByteArray(); 
     long lengthbmp = imageInByte.length; 

鸭preciate您的时间和答案:)

Appreciate your time and answers :)

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

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