diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt index b72f9ea66f..9178d03a7f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt @@ -4,8 +4,10 @@ import android.annotation.SuppressLint import android.content.Intent import android.graphics.BitmapFactory import android.graphics.PointF +import android.graphics.drawable.ColorDrawable import android.graphics.drawable.Drawable import android.net.Uri +import android.support.v4.graphics.ColorUtils import android.view.GestureDetector import android.view.Gravity import android.view.MotionEvent @@ -255,9 +257,23 @@ class PagerPageHolder( launchUI { val image = async { BitmapFactory.decodeByteArray(bytesArray, 0, bytesArray.size) } - imageView.background = ImageUtil.autoSetBackground(image.await()) - if (!viewer.config.imageCropBorders) - imageView.setImage(ImageSource.bitmap(image.await())) + val bg = ImageUtil.autoSetBackground(image.await()) + imageView.background = bg + if (!viewer.config.imageCropBorders) { + if (bg is ColorDrawable) { + val array = FloatArray(3) + ColorUtils.colorToHSL(bg.color, array) + if (array[1] < 0.2) { + val bytesStream = bytesArray.inputStream() + imageView.setImage(ImageSource.inputStream(bytesStream)) + bytesStream.close() + } + else + imageView.setImage(ImageSource.bitmap(image.await())) + } + else + imageView.setImage(ImageSource.bitmap(image.await())) + } } } else {