开发者

get image size in bytes

I want to get image size in bytes what should i do..

// this code switch me in gallery where we can select any existing images

Intent i = new Intent(Intent.ACTION_PICK,
                                       android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
                开发者_如何学Go       i.setType("image/*");
                       startActivityForResult(i, 2);

// this code of snippet return the uri of selected images from gallery but i want to image //size in bytes also from here

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
               super.onActivityResult(requestCode, resultCode, data);

               if (requestCode == 2) {// 2 for selectimage
                       // Get the data of the image selected? and upload to server

                       if (resultCode == Activity.RESULT_OK) {
                               ImageURI = data.getData();
                               Log.d("IMAGE PATH",""+ImageURI);}}}

thanks..


ContentResolver resolver = context.getContentResolver();
InputStream is = resolver.openInputStream(ImageURI);
BitmapFactory.Options bounds = new BitmapFactory.Options();
BitmapFactory.decodeStream(is,null,bounds);
int width = bounds.outWidth;
int height = bounds.outHeight;
int size = width * height * bytes_per_pixel
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜