diff --git a/tess-two/src/com/googlecode/leptonica/android/WriteFile.java b/tess-two/src/com/googlecode/leptonica/android/WriteFile.java index d77a307e1..03c0dee3d 100644 --- a/tess-two/src/com/googlecode/leptonica/android/WriteFile.java +++ b/tess-two/src/com/googlecode/leptonica/android/WriteFile.java @@ -112,18 +112,19 @@ public static Bitmap writeBitmap(Pix pixs) { throw new IllegalArgumentException("Source pix must be non-null"); final int[] dimensions = pixs.getDimensions(); - final int width = dimensions[Pix.INDEX_W]; - final int height = dimensions[Pix.INDEX_H]; + if (dimensions != null) { + final int width = dimensions[Pix.INDEX_W]; + final int height = dimensions[Pix.INDEX_H]; - final Bitmap.Config config = Bitmap.Config.ARGB_8888; - final Bitmap bitmap = Bitmap.createBitmap(width, height, config); + final Bitmap.Config config = Bitmap.Config.ARGB_8888; + final Bitmap bitmap = Bitmap.createBitmap(width, height, config); - if (nativeWriteBitmap(pixs.getNativePix(), bitmap)) { - return bitmap; - } - - bitmap.recycle(); + if (nativeWriteBitmap(pixs.getNativePix(), bitmap)) { + return bitmap; + } + bitmap.recycle(); + } return null; }