Fixes to center margin option

(cherry picked from commit d8c2baa135b8cdcac0c00e9b03beeecc132167d6)
This commit is contained in:
Jobobby04 2023-04-16 13:10:43 -04:00
parent 212c1d3287
commit f890a68f35
2 changed files with 5 additions and 3 deletions

View File

@ -358,7 +358,9 @@ class PagerPageHolder(
private fun mergePages(imageStream: InputStream, imageStream2: InputStream?): InputStream {
// Handle adding a center margin to wide images if requested
if (imageStream2 == null) {
return if (imageStream is BufferedInputStream && ImageUtil.isWideImage(imageStream) &&
return if (imageStream is BufferedInputStream &&
!ImageUtil.isAnimatedAndSupported(imageStream) &&
ImageUtil.isWideImage(imageStream) &&
viewer.config.centerMarginType and PagerConfig.CenterMarginType.WIDE_PAGE_CENTER_MARGIN > 0 &&
!viewer.config.imageCropBorders
) {
@ -440,7 +442,7 @@ class PagerPageHolder(
imageStream2.close()
val centerMargin = if (viewer.config.centerMarginType and PagerConfig.CenterMarginType.DOUBLE_PAGE_CENTER_MARGIN > 0 && !viewer.config.imageCropBorders) {
96 / (getHeight().coerceAtLeast(1) / max(height, height2).coerceAtLeast(1)).coerceAtLeast(1)
96 / (this.height.coerceAtLeast(1) / max(height, height2).coerceAtLeast(1)).coerceAtLeast(1)
} else {
0
}

View File

@ -201,7 +201,7 @@ object ImageUtil {
val height = imageBitmap.height
val width = imageBitmap.width
val centerPadding = 96 / (max(1, viewHeight) / height)
val centerPadding = 96 / (max(1, viewHeight) / height).coerceAtLeast(1)
val leftSourcePart = Rect(0, 0, width / 2, height)
val rightSourcePart = Rect(width / 2, 0, width, height)