mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-16 14:07:28 +01:00
Add option to automatically split tall downloaded images (#7029)
* Auto split long images to improve performance of reader * Auto split long images to improve performance of reader - fixed the sorting * Improved performance of splitting by getting rid of 1 extra loop * Cleaned up code and moved the functionality to work during the downloading process (unsure how this affects download speed) * Replaced the import .* with the actual used imports * Fixes for Bugs discovered during my testing * Fixed last split missing bug. * Reordered the download progress to be updated before splitting instead of after to reflect more meaningful progress of download * Reverted last commit since it had no effect * Improved progress tracking when a download is paused then resumed. * Implemented the recommended changes to enhance the feature. * Apply suggestions from code review Co-authored-by: arkon <arkon@users.noreply.github.com> * Update app/src/main/res/values/strings.xml Co-authored-by: arkon <arkon@users.noreply.github.com> Co-authored-by: arkon <arkon@users.noreply.github.com>
This commit is contained in:
@@ -115,6 +115,24 @@ object ImageUtil {
|
||||
return options.outWidth > options.outHeight
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the image is considered a tall image
|
||||
* @return true if the height:width ratio is greater than the 3:!
|
||||
*/
|
||||
fun isTallImage(imageStream: InputStream): Boolean {
|
||||
imageStream.mark(imageStream.available() + 1)
|
||||
|
||||
val imageBytes = imageStream.readBytes()
|
||||
// Checking the image dimensions without loading it in the memory.
|
||||
val options = BitmapFactory.Options().apply { inJustDecodeBounds = true }
|
||||
BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size, options)
|
||||
val width = options.outWidth
|
||||
val height = options.outHeight
|
||||
val ratio = height / width
|
||||
|
||||
return ratio > 3
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the 'side' part from imageStream and return it as InputStream.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user