查找图像的主色在Android @drawable [英] Finding the dominant color of an image in an Android @drawable

查看:272
本文介绍了查找图像的主色在Android @drawable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以明白为什么我试图找到图像中的主色,如果你使用的是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浏览器是如何挑选的主色调也可能会有所帮助。 <一href="http://www.quora.com/Google-Chrome/How-does-Chrome-pick-the-color-for-the-stripes-on-the-Most-visited-page-thumbnails" rel="nofollow">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

这篇关于查找图像的主色在Android @drawable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆