Add support for cont. vertical margins while splitting double pages

This commit is contained in:
Jays2Kings 2021-10-04 20:18:27 -04:00
parent 453c28bd6b
commit aefed46059
2 changed files with 6 additions and 3 deletions

View file

@ -323,7 +323,7 @@ class WebtoonPageHolder(
return imageBytes.inputStream() return imageBytes.inputStream()
} }
return ImageUtil.splitAndStackBitmap(imageBitmap, viewer.config.invertDoublePages) return ImageUtil.splitAndStackBitmap(imageBitmap, viewer.config.invertDoublePages, viewer.hasMargins)
} }
/** /**

View file

@ -316,12 +316,15 @@ object ImageUtil {
fun splitAndStackBitmap( fun splitAndStackBitmap(
imageBitmap: Bitmap, imageBitmap: Bitmap,
rightSideOnTop: Boolean, rightSideOnTop: Boolean,
hasMargins: Boolean,
progressCallback: ((Int) -> Unit)? = null progressCallback: ((Int) -> Unit)? = null
): ByteArrayInputStream { ): ByteArrayInputStream {
val height = imageBitmap.height val height = imageBitmap.height
val width = imageBitmap.width val width = imageBitmap.width
val result = Bitmap.createBitmap(width / 2, height * 2, Bitmap.Config.ARGB_8888) val gap = if (hasMargins) 15.dpToPx else 0
val result = Bitmap.createBitmap(width / 2, height * 2 + gap, Bitmap.Config.ARGB_8888)
val canvas = Canvas(result) val canvas = Canvas(result)
canvas.drawColor(Color.BLACK)
progressCallback?.invoke(98) progressCallback?.invoke(98)
val upperPart = Rect( val upperPart = Rect(
0, 0,
@ -331,7 +334,7 @@ object ImageUtil {
) )
val lowerPart = Rect( val lowerPart = Rect(
0, 0,
result.height / 2, result.height / 2 + gap,
result.width, result.width,
result.height result.height
) )