Cleanup dual page split (#4956)

* Cleanup Dual Page Split

* Move where images is processed

* Change parameter name to imageStream

* Use available instead of Int.MAX_VALUE

* Update JavaDoc
This commit is contained in:
Andreas
2021-04-25 17:08:51 +02:00
committed by GitHub
parent f608cb55eb
commit 662b71436e
4 changed files with 48 additions and 32 deletions

View File

@@ -77,15 +77,20 @@ object ImageUtil {
}
/**
* Check whether the image is a double image (width > height), return the result and original stream
* Check whether the image is a double-page spread
* @return true if the width is greater than the height
*/
fun isDoublePage(imageStream: InputStream): Pair<Boolean, InputStream> {
fun isDoublePage(imageStream: InputStream): Boolean {
imageStream.mark(imageStream.available() + 1)
val imageBytes = imageStream.readBytes()
val options = BitmapFactory.Options().apply { inJustDecodeBounds = true }
BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size, options)
return Pair(options.outWidth > options.outHeight, ByteArrayInputStream(imageBytes))
imageStream.reset()
return options.outWidth > options.outHeight
}
/**