简体   繁体   English

强制 function 从 Light One 的图像中选择深色阴影

[英]Force function to pick a dark shade from image instaed of Light One

I have created this function to pick color from image.我创建了这个 function 来从图像中挑选颜色。


fun getMainColor(img: Bitmap): Int {
    val newImg = Bitmap.createScaledBitmap(img, 1, 1, true)
    val color = newImg.getPixel(0, 0)
    newImg.recycle()
    return color
}

But it usually chooses a Light Shade color that makes the UI so Ugly, I want it to Choose a dark shade from the image.但它通常会选择一种使 UI 如此丑陋的 Light Shade 颜色,我希望它从图像中选择深色。 How Could I do that!我怎么能那样!

Palette API is good solution for find the colors from the Image with multiple choices . 调色板 API是从具有多项选择的图像中找到 colors 的好解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM