Update ImageUtil.kt

This commit is contained in:
Jay 2019-12-02 16:20:51 -08:00
parent 5944191f3e
commit 3e323af296

View File

@ -151,8 +151,8 @@ object ImageUtil {
botRightIsDark -> image.getPixel(right, bot) botRightIsDark -> image.getPixel(right, bot)
else -> blackPixel else -> blackPixel
} }
darkBG = true; darkBG = true
overallWhitePixels = 0; overallWhitePixels = 0
break@outer break@outer
} }
blackStreak -> { blackStreak -> {
@ -164,7 +164,7 @@ object ImageUtil {
else -> blackPixel else -> blackPixel
} }
if (blackPixels > 18) { if (blackPixels > 18) {
overallWhitePixels = 0; overallWhitePixels = 0
break@outer break@outer
} }
} }
@ -180,14 +180,11 @@ object ImageUtil {
darkBG = true darkBG = true
val whiteColor = android.R.attr.colorBackground val whiteColor = android.R.attr.colorBackground
if (darkBG) { if (darkBG) {
if (isWhite(image.getPixel(left, bot)) && isWhite(image.getPixel(right, bot))) return if (isWhite(image.getPixel(left, bot)) && isWhite(image.getPixel(right, bot))) GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
return GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, intArrayOf(blackPixel, blackPixel, whiteColor, whiteColor))
intArrayOf(blackPixel, blackPixel, whiteColor, whiteColor)) else if (isWhite(image.getPixel(left, top)) && isWhite(image.getPixel(right, top))) GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
else if (isWhite(image.getPixel(left, top)) && isWhite(image.getPixel(right, top))) intArrayOf(whiteColor, whiteColor, blackPixel, blackPixel))
return GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, else ColorDrawable(blackPixel)
intArrayOf(whiteColor, whiteColor, blackPixel, blackPixel))
else
return ColorDrawable(blackPixel)
} }
if (topIsBlackStreak || (topLeftIsDark && topRightIsDark if (topIsBlackStreak || (topLeftIsDark && topRightIsDark
&& isDark(image.getPixel(left - offsetX, top)) && isDark(image.getPixel(right + offsetX, top)) && isDark(image.getPixel(left - offsetX, top)) && isDark(image.getPixel(right + offsetX, top))