mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-02-20 21:30:45 +01:00
use the functions from Commons for saving rotated images
This commit is contained in:
parent
1bade23297
commit
15e24a7f83
@ -45,7 +45,7 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:3.17.21'
|
implementation 'com.simplemobiletools:commons:3.17.22'
|
||||||
|
|
||||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
|
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
|
||||||
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
|
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
|
||||||
|
@ -78,7 +78,7 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
|
|||||||
val imageRot = orient.degreesFromOrientation()
|
val imageRot = orient.degreesFromOrientation()
|
||||||
|
|
||||||
val totalRotation = (imageRot + deviceRot + previewRot) % 360
|
val totalRotation = (imageRot + deviceRot + previewRot) % 360
|
||||||
if (!path.startsWith(activity.internalStoragePath) && !isNougatPlus()) {
|
if (!activity.isPathOnSD(path) && !isNougatPlus()) {
|
||||||
image = rotate(image, totalRotation)
|
image = rotate(image, totalRotation)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,16 +100,7 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
|
|||||||
val fileExif = ExifInterface(path)
|
val fileExif = ExifInterface(path)
|
||||||
|
|
||||||
image.compress(Bitmap.CompressFormat.JPEG, activity.config.photoQuality, fos)
|
image.compress(Bitmap.CompressFormat.JPEG, activity.config.photoQuality, fos)
|
||||||
if (path.startsWith(activity.internalStoragePath)) {
|
activity.saveImageRotation(path, totalRotation)
|
||||||
saveExifRotation(ExifInterface(path), totalRotation)
|
|
||||||
} else if (isNougatPlus()) {
|
|
||||||
val documentFile = activity.getSomeDocumentFile(path)
|
|
||||||
if (documentFile != null) {
|
|
||||||
val parcelFileDescriptor = activity.contentResolver.openFileDescriptor(documentFile.uri, "rw")
|
|
||||||
val fileDescriptor = parcelFileDescriptor.fileDescriptor
|
|
||||||
saveExifRotation(ExifInterface(fileDescriptor), totalRotation)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (activity.config.savePhotoMetadata) {
|
if (activity.config.savePhotoMetadata) {
|
||||||
tempExif.copyTo(fileExif)
|
tempExif.copyTo(fileExif)
|
||||||
@ -124,13 +115,6 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveExifRotation(exif: ExifInterface, degrees: Int) {
|
|
||||||
val orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
|
|
||||||
val orientationDegrees = (orientation.degreesFromOrientation() + degrees) % 360
|
|
||||||
exif.setAttribute(ExifInterface.TAG_ORIENTATION, orientationDegrees.orientationFromDegrees())
|
|
||||||
exif.saveAttributes()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun rotate(bitmap: Bitmap, degree: Int): Bitmap? {
|
private fun rotate(bitmap: Bitmap, degree: Int): Bitmap? {
|
||||||
if (degree == 0) {
|
if (degree == 0) {
|
||||||
return bitmap
|
return bitmap
|
||||||
|
Loading…
x
Reference in New Issue
Block a user