mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-16 14:07:28 +01:00
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:
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user