查找图像的主色在Android @drawable图像、Android、drawable

2023-09-12 11:19:18 作者:安然。但不淡然ヾ

您可以明白为什么我试图找到图像中的主色,如果你使用的是Windows 7,当你的鼠标放在任务栏上的程序,该特定程序更改背景的基础上,在最有统治力的颜色图标。我已经注意到这种技术在其他程序中使用的为好,但不记得他们把我的头顶部。

You can understand why I'm trying to find the dominant color in an image if you use Windows 7. When your mouse over a program in the taskbar, the background of that particular program changes based on the most dominant color in the icon. I have noticed this technique used in other programs as well, but can't remember them off the top of my head.

我可以看到这是在一些我使用开发应用程序的用户界面技术帮助,我不知道如何找到最常见的颜色会从Android的绘制资源来实现。

I can see this being helpful in a number of UI techniques that I'm using to develop an application, and I was wondering how finding the most common color would be achieved from an Android drawable resource.

推荐答案

遍历所有像素的颜色数据和平均颜色值,忽略任何为灰色或透明阴影。我相信这也是微软确实在Windows 7的基础上最近的一篇博客。

Loop through all the pixel's color data and average the color values, ignore anything that is a shade of grey or transparent. I believe that is what Microsoft does in Windows 7 based on a recent blog post.

修改 该博客文章: http://blogs.msdn.com /b/oldnewthing/archive/2011/12/06/10244432.aspx

edit The blog post: http://blogs.msdn.com/b/oldnewthing/archive/2011/12/06/10244432.aspx

此链接显示Chrome浏览器是如何挑选的主色调也可能会有所帮助。 http://www.quora.com/Google-Chrome/How-does-Chrome-pick-the-color-for-the-stripes-on-the-Most-visited-page-thumbnails

This link showing how Chrome picks the dominant color may also be helpful. http://www.quora.com/Google-Chrome/How-does-Chrome-pick-the-color-for-the-stripes-on-the-Most-visited-page-thumbnails