From 935c8e7d827ebf1db624c7d26ab7310d312b590c Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Mon, 12 Sep 2022 03:59:57 +0600 Subject: [PATCH] Change logic in `BitmapFactory.Options.splitData` (#7989) --- .../java/eu/kanade/tachiyomi/util/system/ImageUtil.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 0c7b7fd620..b27523a997 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 @@ -310,19 +310,19 @@ object ImageUtil { } return mutableListOf().apply { - for (index in (0 until partCount)) { + val range = 0 until partCount + for (index in range) { // Only continue if the list is empty or there is image remaining if (isNotEmpty() && imageHeight <= last().bottomOffset) break val topOffset = index * optimalSplitHeight var splitHeight = min(optimalSplitHeight, imageHeight - topOffset) - val remainingHeight = imageHeight - (topOffset + splitHeight) - // If remaining height is smaller or equal to 1/10th of - // optimal split height then include it in current page - if (remainingHeight <= (optimalSplitHeight / 10)) { + if (index == range.last) { + val remainingHeight = imageHeight - (topOffset + splitHeight) splitHeight += remainingHeight } + add(SplitData(index, topOffset, splitHeight, imageWidth)) } }