diff --git a/app/src/main/java/eu/faircode/email/AdapterMedia.java b/app/src/main/java/eu/faircode/email/AdapterMedia.java index b817d78631..72ccfb0189 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMedia.java +++ b/app/src/main/java/eu/faircode/email/AdapterMedia.java @@ -224,16 +224,18 @@ public class AdapterMedia extends RecyclerView.Adapter Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) try (InputStream is = new FileInputStream(file)) { Bitmap bitmap = ImageHelper.getScaledBitmap(is, file.getAbsolutePath(), type, max); - int width = bitmap.getWidth(), height = bitmap.getHeight(); - int[] pixels = new int[width * height]; - bitmap.getPixels(pixels, 0, width, 0, 0, width, height); - - RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels); - BinaryBitmap bBitmap = new BinaryBitmap(new HybridBinarizer(source)); - MultiFormatReader reader = new MultiFormatReader(); - Result result = reader.decode(bBitmap); - args.putString("barcode_text", Helper.getPrintableString(result.getText(), false)); - args.putString("barcode_format", result.getBarcodeFormat().name()); + if (bitmap != null) { + int width = bitmap.getWidth(), height = bitmap.getHeight(); + int[] pixels = new int[width * height]; + bitmap.getPixels(pixels, 0, width, 0, 0, width, height); + + RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels); + BinaryBitmap bBitmap = new BinaryBitmap(new HybridBinarizer(source)); + MultiFormatReader reader = new MultiFormatReader(); + Result result = reader.decode(bBitmap); + args.putString("barcode_text", Helper.getPrintableString(result.getText(), false)); + args.putString("barcode_format", result.getBarcodeFormat().name()); + } } catch (NotFoundException ex) { Log.i(ex); } catch (Throwable ex) {