toolkit/components/places/mozIColorAnalyzer.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/mozIColorAnalyzer.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "nsISupports.idl"
     1.9 +
    1.10 +interface nsIURI;
    1.11 +
    1.12 +[function, scriptable, uuid(e4089e21-71b6-40af-b546-33c21b90e874)]
    1.13 +interface mozIRepresentativeColorCallback : nsISupports
    1.14 +{
    1.15 +  /**
    1.16 +   * Will be called when color analysis finishes.
    1.17 +   *
    1.18 +   * @param success
    1.19 +   *        True if analysis was successful, false otherwise.
    1.20 +   *        Analysis can fail if the image is transparent, imageURI doesn't
    1.21 +   *        resolve to a valid image, or the image is too big.
    1.22 +   *
    1.23 +   * @param color
    1.24 +   *        The representative color as an integer in RGB form.
    1.25 +   *        e.g. 0xFF0102 == rgb(255,1,2)
    1.26 +   *        If success is false, color is not provided.
    1.27 +   */
    1.28 +  void onComplete(in boolean success, [optional] in unsigned long color);
    1.29 +};
    1.30 +
    1.31 +[scriptable, uuid(d056186c-28a0-494e-aacc-9e433772b143)]
    1.32 +interface mozIColorAnalyzer : nsISupports
    1.33 +{
    1.34 +  /**
    1.35 +   * Given an image URI, find the most representative color for that image
    1.36 +   * based on the frequency of each color.  Preference is given to colors that
    1.37 +   * are more interesting.  Avoids the background color if it can be
    1.38 +   * discerned.  Ignores sufficiently transparent colors.
    1.39 +   *
    1.40 +   * This is intended to be used on favicon images.  Larger images take longer
    1.41 +   * to process, especially those with a larger number of unique colors.  If
    1.42 +   * imageURI points to an image that has more than 128^2 pixels, this method
    1.43 +   * will fail before analyzing it for performance reasons.
    1.44 +   *
    1.45 +   * @param imageURI
    1.46 +   *        A URI pointing to the image - ideally a data: URI, but any scheme
    1.47 +   *        that will load when setting the src attribute of a DOM img element
    1.48 +   *        should work.
    1.49 +   * @param callback
    1.50 +   *        Function to call when the representative color is found or an
    1.51 +   *        error occurs.
    1.52 +   */
    1.53 +  void findRepresentativeColor(in nsIURI imageURI,
    1.54 +                               in mozIRepresentativeColorCallback callback);
    1.55 +};

mercurial