Long strip split fixes 2.0 (#7882)

options was having issues in returning width for some reason

Fixes #7880
Fixes #7881
This commit is contained in:
AntsyLich 2022-08-28 19:46:42 +06:00 committed by GitHub
parent a83d29f058
commit 0e526c36be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<SplitData> {
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
}