Skip to content

Commit 3dc49bf

Browse files
author
Dan Oprea
committed
HDR: allow to skip alignment
1 parent f1787d4 commit 3dc49bf

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

app/src/main/java/com/dan/mergephotos/MainActivity.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class MainActivity : AppCompatActivity() {
104104
binding.spinnerMerge -> {
105105
binding.panoramaOptions.isVisible = Settings.MERGE_PANORAMA == position
106106
binding.longexposureOptions.isVisible = Settings.MERGE_LONG_EXPOSURE == position
107+
binding.hdrOptions.isVisible = Settings.MERGE_HDR == position
107108
}
108109
}
109110

@@ -565,16 +566,17 @@ class MainActivity : AppCompatActivity() {
565566
private fun mergeHdr(prefix: String): Pair<List<Mat>, String> {
566567
log("HDR: Start")
567568

568-
val alignedImages = alignImages(prefix).first
569+
val alignImages = !binding.hdrAlreadyAligned.isChecked
570+
val inputImages = if (alignImages) alignImages(prefix).first else ( cache[prefix] ?: listOf() )
569571
val output = Mat()
570572

571-
if (alignedImages.size >= 2) {
573+
if (inputImages.size >= 2) {
572574
val hdrMat = Mat()
573575
val mergeMertens = createMergeMertens()
574-
mergeMertens.process(alignedImages, hdrMat)
576+
mergeMertens.process(inputImages, hdrMat)
575577

576578
if (!hdrMat.empty()) {
577-
hdrMat.convertTo(output, alignedImages[0].type(), 255.0)
579+
hdrMat.convertTo(output, inputImages[0].type(), 255.0)
578580
}
579581
}
580582

@@ -731,6 +733,7 @@ class MainActivity : AppCompatActivity() {
731733

732734
binding.panoramaInpaint.setOnCheckedChangeListener { _, _ -> mergePhotosSmall() }
733735
binding.longexposureAlreadyAligned.setOnCheckedChangeListener { _, _ -> mergePhotosSmall() }
736+
binding.hdrAlreadyAligned.setOnCheckedChangeListener { _, _ -> mergePhotosSmall() }
734737

735738
if (intent?.action == Intent.ACTION_SEND_MULTIPLE && intent.type?.startsWith("image/") == true) {
736739
intent.getParcelableArrayListExtra<Parcelable>(Intent.EXTRA_STREAM)?.let { list ->

app/src/main/res/layout/activity_main.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,22 @@
109109

110110
</LinearLayout>
111111

112+
<LinearLayout
113+
android:id="@+id/hdrOptions"
114+
android:layout_width="match_parent"
115+
android:layout_height="wrap_content"
116+
android:layout_marginBottom="16dp"
117+
android:orientation="vertical">
118+
119+
<Switch
120+
android:id="@+id/hdrAlreadyAligned"
121+
android:layout_width="match_parent"
122+
android:layout_height="wrap_content"
123+
android:layout_weight="1"
124+
android:text="Already aligned (don't align)" />
125+
126+
</LinearLayout>
127+
112128
<com.ortiz.touchview.TouchImageView
113129
android:id="@+id/imageView"
114130
android:layout_width="match_parent"

0 commit comments

Comments
 (0)