Skip to content
Snippets Groups Projects
Commit ff072b5c authored by FurWaz's avatar FurWaz
Browse files

Added image cache for smoother experience

parent 69ef97f0
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment