diff --git a/Sources/app/src/main/java/Structures/PhotoInfo.java b/Sources/app/src/main/java/Structures/PhotoInfo.java index 7dc3d0d32042bb05df6765786c1b297a67d903de..5cdd81592578c152e87ab303e5593d9b3654409f 100644 --- a/Sources/app/src/main/java/Structures/PhotoInfo.java +++ b/Sources/app/src/main/java/Structures/PhotoInfo.java @@ -13,6 +13,14 @@ public class PhotoInfo implements Serializable { byte[] image = null; ZoneInfo zone = null; List<PathView> pathViews = new ArrayList<>(); + transient Bitmap bitmap = null; + + protected void createBitmap() { + Bitmap source = BitmapFactory.decodeByteArray(this.image, 0, this.image.length); + Matrix mat = new Matrix(); + mat.postRotate(90); + this.bitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), mat, true); + } public PhotoInfo() { @@ -24,11 +32,14 @@ public class PhotoInfo implements Serializable { public PhotoInfo(byte[] im) { this.image = im; + createBitmap(); + this.askForSave(); } public PhotoInfo(byte[] im, Orientation orientation) { this.image = im; this.orientation = orientation; + createBitmap(); this.askForSave(); } @@ -48,14 +59,15 @@ public class PhotoInfo implements Serializable { public Bitmap getBitmap() { if (this.image == null || this.image.length == 0) return null; - Bitmap source = BitmapFactory.decodeByteArray(this.image, 0, this.image.length); - Matrix mat = new Matrix(); - mat.postRotate(90); - return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), mat, true); + if (this.bitmap != null) return this.bitmap; + + createBitmap(); + return this.bitmap; } public void setImage(byte[] data) { this.image = data; + createBitmap(); this.askForSave(); }