BitmapFactory.Options da 0 ancho y altura

final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(path, options); final int height = options.outHeight; final int width = options.outWidth; 

Path es la ruta del archivo de imagen que es correcta.

El problema es options.outHeight y options.outWidth son 0 cuando la imagen se captura en modo horizontal con AutoRotate activado . Si apago AutoRotate , funciona bien. Dado que su ancho y altura son 0, estaba recibiendo un bitmap nulo al final.

Código Completo:

 Bitmap photo = decodeSampledBitmapFromFile(filePath, DESIRED_WIDTH, DESIRED_HEIGHT); public static Bitmap decodeSampledBitmapFromFile(String path, int reqWidth, int reqHeight) { // First decode with inJustDecodeBounds=true to check dimensions final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(path, options); // Calculate inSampleSize, Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; options.inPreferredConfig = Bitmap.Config.ARGB_8888; int inSampleSize = 1; if (height > reqHeight) { inSampleSize = Math.round((float) height / (float) reqHeight); } int expectedWidth = width / inSampleSize; if (expectedWidth > reqWidth) { inSampleSize = Math.round((float) width / (float) reqWidth); } options.inSampleSize = inSampleSize; // Decode bitmap with inSampleSize set options.inJustDecodeBounds = false; return BitmapFactory.decodeFile(path, options); } 

FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.