From 0e526c36bed52670237165c2e870b154966661b6 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Sun, 28 Aug 2022 19:46:42 +0600 Subject: [PATCH] Long strip split fixes 2.0 (#7882) options was having issues in returning width for some reason Fixes #7880 Fixes #7881 --- .../java/eu/kanade/tachiyomi/util/system/ImageUtil.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt index e9332e3d13..46b735d4c5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt @@ -217,16 +217,13 @@ object ImageUtil { inJustDecodeBounds = false } - // Values are stored as they get modified during split loop - val imageWidth = options.outWidth - val splitDataList = options.splitData return try { splitDataList.forEach { splitData -> val splitPath = splitImagePath(imageFilePath, splitData.index) - val region = Rect(0, splitData.topOffset, imageWidth, splitData.bottomOffset) + val region = Rect(0, splitData.topOffset, splitData.outputImageWidth, splitData.bottomOffset) FileOutputStream(splitPath).use { outputStream -> val splitBitmap = bitmapRegionDecoder.decodeRegion(region, options) @@ -282,7 +279,7 @@ object ImageUtil { val options = extractImageOptions(imageStream).apply { inJustDecodeBounds = false } - val region = Rect(0, splitData.topOffset, options.outWidth, splitData.bottomOffset) + val region = Rect(0, splitData.topOffset, splitData.outputImageWidth, splitData.bottomOffset) try { val splitBitmap = bitmapRegionDecoder.decodeRegion(region, options) @@ -303,6 +300,7 @@ object ImageUtil { private val BitmapFactory.Options.splitData get(): List { val imageHeight = outHeight + val imageWidth = outWidth val splitHeight = (getDisplayMaxHeightInPx * 1.5).toInt() // -1 so it doesn't try to split when imageHeight = splitHeight @@ -328,7 +326,7 @@ object ImageUtil { if (remainingHeight <= (optimalSplitHeight / 10)) { outputImageHeight += remainingHeight } - add(SplitData(index, topOffset, outputImageHeight)) + add(SplitData(index, topOffset, outputImageHeight, imageWidth)) } } } @@ -337,6 +335,7 @@ object ImageUtil { val index: Int, val topOffset: Int, val outputImageHeight: Int, + val outputImageWidth: Int, ) { val bottomOffset = topOffset + outputImageHeight }