Guardar una imagen con su pulgar y mostrarla en imageView android

Estoy intentando ahorrar una imagen tomada de la cámara y después almacenarla en sdCard junto con su pulgar que también muestra este pulgar en un imageView. Sin embargo, da error en el puntero nulo

imageBitmap = Bitmap.createScaledBitmap(imageBitmap, 40, 40, false); 

¿Qué está mal?

  { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); try { if (title.getText().toString().equals("")) { displayAlert("Please Input Title First","Error!"); } else { Integer val = myMisc.miscId ; String fileName = "image" + "_" + title.getText().toString()+"_" + val.toString(); photo = this.createFile(fileName, ".jpg"); myMisc.filename = photo.getAbsolutePath(); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); startActivityForResult(intent, RESULT_CAMERA_SELECT); } } catch(Exception e) { Log.v("Error", "Can't create file to take picture!"); displayAlert("Can't create file to take picture!","SDCard Error!"); } } public synchronized void onActivityResult(final int requestCode, int resultCode, final Intent data) { if (resultCode == Activity.RESULT_OK) { if (requestCode == RESULT_CAMERA_SELECT) { try { saveImage(); } catch (IOException e) { e.printStackTrace(); } } public static int calculateInSampleSize( BitmapFactory.Options options, int reqWidth, int reqHeight) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > reqHeight || width > reqWidth) { if (width > height) { inSampleSize = Math.round((float)height / (float)reqHeight); } else { inSampleSize = Math.round((float)width / (float)reqWidth); } } return inSampleSize; } public void saveImage() throws IOException { try { FileInputStream is2 = new FileInputStream(photo); final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; Bitmap imageBitmap = BitmapFactory.decodeStream(is2, null, options); options.inSampleSize = calculateInSampleSize(options, 40, 40); options.inJustDecodeBounds = false; imageBitmap = BitmapFactory.decodeStream(is2 ,null, options); imageBitmap = Bitmap.createScaledBitmap(imageBitmap, 40, 40, false); Integer val = myMisc.miscId; String fileName = ".thumbImage" + "_" + title.getText().toString()+ "_" + val.toString(); photo = this.createFile(fileName, ".jpg"); myMisc.thumbFileName = photo.getAbsolutePath(); try { FileOutputStream out = new FileOutputStream(photo); imageBitmap.compress(Bitmap.CompressFormat.PNG, 90, out); } catch (Exception e) { e.printStackTrace(); } is2.close(); Uri uri = Uri.fromFile(photo); photo = null; imageBitmap = null; imageView.setImageURI(uri); }catch(Exception e) { displayAlert("Can't create file to take picture!","SD Card Error"); } } 

Es probablemente debido al método decodeStream.

Bitmap imageBitmap = BitmapFactory.decodeStream(is2, null, options);

Se analizó null en el momento en que se solicita un rectángulo y cuando se intentó crear un mapa de bits a escala no era válido.

Encontré mi error Bitmap imageBitmap = BitmapFactory.decodeStream(is2, null, options); decodificando dos veces

  • ¿Cómo determinar un tacto largo en androide?
  • Login Facebook registerCallback no llamado
  • Android Studio no puede resolver ninguna dependencia
  • Android dos AsyncTasks ejecución en serie o en paralelo? - El segundo es helada pero el resultado es bueno
  • Spannable en android para textView
  • Cómo poner una vista en el paquete
  • Función de devolución de llamada de Bluetooth onCharacteristicRead no está realizando llamada de intención a otra actividad Trabajar con <API21. Restaurantes en Marshmallow
  • ¿Cómo puedo especificar una imagen de marcador de posición?
  • ¿Cómo administrar el estado de Android MediaPlayer, errores y excepciones?
  • Obtener objeto JSON anidado con GSON utilizando retrofit
  • No se puede resolver el método checkSelfPermission
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.