mozIColorAnalyzer 编辑

toolkit/components/places/mozIColorAnalyzer.idlScriptable Provides methods to analyze colors in an image 1.0 66 Introduced Gecko 17.0 Inherits from: nsISupports Last changed in Gecko 17.0 (Firefox 17.0 / Thunderbird 17.0 / SeaMonkey 2.14)

Method overview

void findRepresentativeColor(in nsIURI imageURI, in mozIRepresentativeColorCallback callback);

Methods

findRepresentativeColor()

Given an image URI, find the most representative color for that image based on the frequency of each color. Preference is given to colors that are more interesting. It avoids the background color if it can be discerned and ignores sufficiently transparent colors.

This is intended to be used on favicon images. Larger images take longer to process, especially those with a larger number of unique colors. If imageURI points to an image that has more than 128^2 pixels, this method will fail for performance reasons before analyzing it.

void findRepresentativeColor(
  in nsIURI imageURI,
  in mozIRepresentativeColorCallback callback
);

Parameters

imageURI
A URI pointing to the image - ideally a data: URI, but any scheme that will load when setting the src attribute of a DOM img element should work.
callback
Function to call when the representative color is found or an error occurs.

Remarks

Below are some images with the result of findRepresentativeColor:

ImageRepresentative color
 0xB28D3A
 0x502E1E
 0x53BA3F
 0x00A400

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:131 次

字数:4128

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文