How to check the filesize of ImageView in android> -
in android app. trying upload image server. need filesize smaller 1mb. if have imageview object, how can programtically check size smaller 1mb?
thanks
bitmapdrawable bmpdrawable = imgview.getdrawable(); bitmap bmp = bmpdrawable.getbitmap(); bytearrayoutputstream out = new bytearrayoutputstream(); bmp.compress(bitmap.compressformatjpeg, 100, out); int size = out.count; if( out.count > 1024 *1024 * 1024 ) { // greater 1 mb }
// use bitmap size using bitmapfacotry.options class // size depend on how compress image , send, can idea getting image width , size , caluclate pixels used. jpeg size varies according image, use io stream write file jpeg , see number of bytes in it.
Comments
Post a Comment