I am trying to get image from gallery and setting up it on ImageView
, Hear is okay well i get and set image on ImageView
, but now i want to check
to know the size is less then 100kb. you should know the image size to compare. there is some method to know the size of bitmap
method 1
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;
method 2
File file = new File("/sdcard/Your_file");
long length = file.length() / 1024; // Size in KB
For more Study
go for http://developer.android.com/reference/android/graphics/Bitmap.html#getByteCount%28%29