public Point measureImage ( Resources resources ) { BitmapFactory . Options justBoundsOptions = new BitmapFactory . Options ( ) ; justBoundsOptions . inJustDecodeBounds = true ; if ( bitmap != null ) { return new Point ( bitmap . getWidth ( ) , bitmap . getHeight ( ) ) ; } else if ( resId != null ) { BitmapFactory . decodeResource ( resources , resId , justBoundsOptions ) ; float scale = ( float ) justBoundsOptions . inTargetDensity / justBoundsOptions . inDensity ; return new Point ( ( int ) ( justBoundsOptions . outWidth * scale + 0.5f ) , ( int ) ( justBoundsOptions . outHeight * scale + 0.5f ) ) ; } else if ( fileToBitmap != null ) { BitmapFactory . decodeFile ( fileToBitmap . getAbsolutePath ( ) , justBoundsOptions ) ; } else if ( inputStream != null ) { BitmapFactory . decodeStream ( inputStream , null , justBoundsOptions ) ; try { inputStream . reset ( ) ; } catch ( IOException ignored ) { } } else if ( view != null ) { return new Point ( view . getWidth ( ) , view . getHeight ( ) ) ; } return new Point ( justBoundsOptions . outWidth , justBoundsOptions . outHeight ) ; }
If the not a bitmap itself this will read the file s meta data .