minor: renaming

This commit is contained in:
Thibault Deckers 2020-10-01 10:06:10 +09:00
parent bbc9d69ba5
commit 71d7262b74
6 changed files with 21 additions and 20 deletions

View file

@ -125,7 +125,7 @@ public class ImageDecodeTask extends AsyncTask<ImageDecodeTask.Params, Void, Ima
Bitmap bitmap = resolver.loadThumbnail(entry.uri, new Size(width, height), null);
String mimeType = entry.mimeType;
if (MimeTypes.DNG.equals(mimeType)) {
bitmap = rotateBitmap(bitmap, entry.orientationDegrees);
bitmap = rotateBitmap(bitmap, entry.rotationDegrees);
}
return bitmap;
}
@ -141,7 +141,7 @@ public class ImageDecodeTask extends AsyncTask<ImageDecodeTask.Params, Void, Ima
Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(resolver, contentId, MediaStore.Images.Thumbnails.MINI_KIND, null);
// from Android Q, returned thumbnail is already rotated according to EXIF orientation
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q && bitmap != null) {
bitmap = rotateBitmap(bitmap, entry.orientationDegrees);
bitmap = rotateBitmap(bitmap, entry.rotationDegrees);
}
return bitmap;
}
@ -153,7 +153,7 @@ public class ImageDecodeTask extends AsyncTask<ImageDecodeTask.Params, Void, Ima
int height = params.height;
// add signature to ignore cache for images which got modified but kept the same URI
Key signature = new ObjectKey("" + entry.dateModifiedSecs + entry.width + entry.orientationDegrees);
Key signature = new ObjectKey("" + entry.dateModifiedSecs + entry.width + entry.rotationDegrees);
RequestOptions options = new RequestOptions()
.signature(signature)
.override(width, height);
@ -180,7 +180,7 @@ public class ImageDecodeTask extends AsyncTask<ImageDecodeTask.Params, Void, Ima
Bitmap bitmap = target.get();
String mimeType = entry.mimeType;
if (MimeTypes.DNG.equals(mimeType) || MimeTypes.HEIC.equals(mimeType) || MimeTypes.HEIF.equals(mimeType)) {
bitmap = rotateBitmap(bitmap, entry.orientationDegrees);
bitmap = rotateBitmap(bitmap, entry.rotationDegrees);
}
return bitmap;
} finally {
@ -188,9 +188,10 @@ public class ImageDecodeTask extends AsyncTask<ImageDecodeTask.Params, Void, Ima
}
}
private Bitmap rotateBitmap(Bitmap bitmap, Integer orientationDegrees) {
if (bitmap != null && orientationDegrees != null) {
bitmap = TransformationUtils.rotateImage(bitmap, orientationDegrees);
private Bitmap rotateBitmap(Bitmap bitmap, Integer rotationDegrees) {
if (bitmap != null && rotationDegrees != null) {
// TODO TLAD use exif orientation to rotate & flip?
bitmap = TransformationUtils.rotateImage(bitmap, rotationDegrees);
}
return bitmap;
}

View file

@ -105,6 +105,7 @@ public class ImageByteStreamHandler implements EventChannel.StreamHandler {
try {
Bitmap bitmap = target.get();
if (bitmap != null) {
// TODO TLAD use exif orientation to rotate & flip?
bitmap = TransformationUtils.rotateImage(bitmap, orientationDegrees);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
// we compress the bitmap because Dart Image.memory cannot decode the raw bytes

View file

@ -13,7 +13,7 @@ public class AvesImageEntry {
public String path; // best effort to get local path
public String mimeType;
@Nullable
public Integer width, height, orientationDegrees;
public Integer width, height, rotationDegrees;
@Nullable
public Long dateModifiedSecs;
@ -23,7 +23,7 @@ public class AvesImageEntry {
this.mimeType = (String) map.get("mimeType");
this.width = (Integer) map.get("width");
this.height = (Integer) map.get("height");
this.orientationDegrees = (Integer) map.get("orientationDegrees");
this.rotationDegrees = (Integer) map.get("orientationDegrees");
this.dateModifiedSecs = toLong(map.get("dateModifiedSecs"));
}

View file

@ -32,8 +32,6 @@ import deckers.thibault.aves.utils.MetadataHelper;
import deckers.thibault.aves.utils.MimeTypes;
import deckers.thibault.aves.utils.StorageUtils;
import static deckers.thibault.aves.utils.MetadataHelper.getOrientationDegreesForExifCode;
public class SourceImageEntry {
public Uri uri; // content or file URI
public String path; // best effort to get local path
@ -42,7 +40,7 @@ public class SourceImageEntry {
@Nullable
public String title;
@Nullable
public Integer width, height, orientationDegrees;
public Integer width, height, rotationDegrees;
@Nullable
public Long sizeBytes;
@Nullable
@ -61,7 +59,7 @@ public class SourceImageEntry {
this.sourceMimeType = (String) map.get("sourceMimeType");
this.width = (int) map.get("width");
this.height = (int) map.get("height");
this.orientationDegrees = (int) map.get("orientationDegrees");
this.rotationDegrees = (int) map.get("orientationDegrees");
this.sizeBytes = toLong(map.get("sizeBytes"));
this.title = (String) map.get("title");
this.dateModifiedSecs = toLong(map.get("dateModifiedSecs"));
@ -76,7 +74,7 @@ public class SourceImageEntry {
put("sourceMimeType", sourceMimeType);
put("width", width);
put("height", height);
put("orientationDegrees", orientationDegrees != null ? orientationDegrees : 0);
put("orientationDegrees", rotationDegrees != null ? rotationDegrees : 0);
put("sizeBytes", sizeBytes);
put("title", title);
put("dateModifiedSecs", dateModifiedSecs);
@ -158,7 +156,7 @@ public class SourceImageEntry {
this.height = Integer.parseInt(height);
}
if (rotation != null) {
this.orientationDegrees = Integer.parseInt(rotation);
this.rotationDegrees = Integer.parseInt(rotation);
}
if (durationMillis != null) {
this.durationMillis = Long.parseLong(durationMillis);
@ -251,7 +249,8 @@ public class SourceImageEntry {
height = dir.getInt(ExifIFD0Directory.TAG_IMAGE_HEIGHT);
}
if (dir.containsTag(ExifIFD0Directory.TAG_ORIENTATION)) {
orientationDegrees = getOrientationDegreesForExifCode(dir.getInt(ExifIFD0Directory.TAG_ORIENTATION));
int exifOrientation = dir.getInt(ExifIFD0Directory.TAG_ORIENTATION);
rotationDegrees = MetadataHelper.getRotationDegreesForExifCode(exifOrientation);
}
if (dir.containsTag(ExifIFD0Directory.TAG_DATETIME)) {
sourceDateTakenMillis = dir.getDate(ExifIFD0Directory.TAG_DATETIME, null, TimeZone.getDefault()).getTime();

View file

@ -179,14 +179,14 @@ class ImageEntry {
bool get canRotate => canEdit && (mimeType == MimeTypes.jpeg || mimeType == MimeTypes.png);
bool get rotated => ((isVideo && isCatalogued) ? _catalogMetadata.videoRotation : orientationDegrees) % 180 == 90;
bool get portrait => ((isVideo && isCatalogued) ? _catalogMetadata.videoRotation : orientationDegrees) % 180 == 90;
double get displayAspectRatio {
if (width == 0 || height == 0) return 1;
return rotated ? height / width : width / height;
return portrait ? height / width : width / height;
}
Size get displaySize => rotated ? Size(height.toDouble(), width.toDouble()) : Size(width.toDouble(), height.toDouble());
Size get displaySize => portrait ? Size(height.toDouble(), width.toDouble()) : Size(width.toDouble(), height.toDouble());
int get megaPixels => width != null && height != null ? (width * height / 1000000).round() : null;

View file

@ -103,7 +103,7 @@ class _FullscreenDebugPageState extends State<FullscreenDebugPage> {
'width': '${entry.width}',
'height': '${entry.height}',
'orientationDegrees': '${entry.orientationDegrees}',
'rotated': '${entry.rotated}',
'portrait': '${entry.portrait}',
'displayAspectRatio': '${entry.displayAspectRatio}',
'displaySize': '${entry.displaySize}',
'megaPixels': '${entry.megaPixels}',