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

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -