Change logic in BitmapFactory.Options.splitData (#7989)

(cherry picked from commit 935c8e7d827ebf1db624c7d26ab7310d312b590c)
This commit is contained in:
AntsyLich 2022-09-12 03:59:57 +06:00 committed by Jobobby04
parent 81a4f16a34
commit e5bf6664f7

View File

@ -346,19 +346,19 @@ object ImageUtil {
}
return mutableListOf<SplitData>().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)
if (index == range.last) {
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)) {
splitHeight += remainingHeight
}
add(SplitData(index, topOffset, splitHeight, imageWidth))
}
}