mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Add support for cont. vertical margins while splitting double pages
This commit is contained in:
parent
453c28bd6b
commit
aefed46059
2 changed files with 6 additions and 3 deletions
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue