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:
parent
a83d29f058
commit
0e526c36be
1 changed files with 5 additions and 6 deletions
|
@ -217,16 +217,13 @@ object ImageUtil {
|
||||||
inJustDecodeBounds = false
|
inJustDecodeBounds = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Values are stored as they get modified during split loop
|
|
||||||
val imageWidth = options.outWidth
|
|
||||||
|
|
||||||
val splitDataList = options.splitData
|
val splitDataList = options.splitData
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
splitDataList.forEach { splitData ->
|
splitDataList.forEach { splitData ->
|
||||||
val splitPath = splitImagePath(imageFilePath, splitData.index)
|
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 ->
|
FileOutputStream(splitPath).use { outputStream ->
|
||||||
val splitBitmap = bitmapRegionDecoder.decodeRegion(region, options)
|
val splitBitmap = bitmapRegionDecoder.decodeRegion(region, options)
|
||||||
|
@ -282,7 +279,7 @@ object ImageUtil {
|
||||||
|
|
||||||
val options = extractImageOptions(imageStream).apply { inJustDecodeBounds = false }
|
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 {
|
try {
|
||||||
val splitBitmap = bitmapRegionDecoder.decodeRegion(region, options)
|
val splitBitmap = bitmapRegionDecoder.decodeRegion(region, options)
|
||||||
|
@ -303,6 +300,7 @@ object ImageUtil {
|
||||||
private val BitmapFactory.Options.splitData
|
private val BitmapFactory.Options.splitData
|
||||||
get(): List<SplitData> {
|
get(): List<SplitData> {
|
||||||
val imageHeight = outHeight
|
val imageHeight = outHeight
|
||||||
|
val imageWidth = outWidth
|
||||||
|
|
||||||
val splitHeight = (getDisplayMaxHeightInPx * 1.5).toInt()
|
val splitHeight = (getDisplayMaxHeightInPx * 1.5).toInt()
|
||||||
// -1 so it doesn't try to split when imageHeight = splitHeight
|
// -1 so it doesn't try to split when imageHeight = splitHeight
|
||||||
|
@ -328,7 +326,7 @@ object ImageUtil {
|
||||||
if (remainingHeight <= (optimalSplitHeight / 10)) {
|
if (remainingHeight <= (optimalSplitHeight / 10)) {
|
||||||
outputImageHeight += remainingHeight
|
outputImageHeight += remainingHeight
|
||||||
}
|
}
|
||||||
add(SplitData(index, topOffset, outputImageHeight))
|
add(SplitData(index, topOffset, outputImageHeight, imageWidth))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,6 +335,7 @@ object ImageUtil {
|
||||||
val index: Int,
|
val index: Int,
|
||||||
val topOffset: Int,
|
val topOffset: Int,
|
||||||
val outputImageHeight: Int,
|
val outputImageHeight: Int,
|
||||||
|
val outputImageWidth: Int,
|
||||||
) {
|
) {
|
||||||
val bottomOffset = topOffset + outputImageHeight
|
val bottomOffset = topOffset + outputImageHeight
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue