2008-01-13 07:15:20 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-01-13 07:15:20 +03:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
2017-11-27 19:05:57 +03:00
|
|
|
interface nsIEventTarget;
|
2008-01-13 07:15:20 +03:00
|
|
|
interface nsIInputStream;
|
|
|
|
interface imgIContainer;
|
2012-06-26 08:20:12 +04:00
|
|
|
interface imgILoader;
|
|
|
|
interface imgICache;
|
|
|
|
interface nsIDOMDocument;
|
2012-10-12 20:11:22 +04:00
|
|
|
interface imgIScriptedNotificationObserver;
|
|
|
|
interface imgINotificationObserver;
|
2017-11-27 19:05:57 +03:00
|
|
|
interface imgIContainerCallback;
|
2008-01-13 07:15:20 +03:00
|
|
|
|
2012-12-18 05:35:07 +04:00
|
|
|
[scriptable, builtinclass, uuid(4c2383a4-931c-484d-8c4a-973590f66e3f)]
|
2008-01-13 07:15:20 +03:00
|
|
|
interface imgITools : nsISupports
|
|
|
|
{
|
2012-12-18 05:35:07 +04:00
|
|
|
/**
|
|
|
|
* decodeImage
|
|
|
|
* Caller provides an input stream and mimetype. We read from the stream
|
|
|
|
* and decompress it (according to the specified mime type) and return
|
|
|
|
* the resulting imgIContainer.
|
|
|
|
*
|
|
|
|
* @param aStream
|
|
|
|
* An input stream for an encoded image file.
|
|
|
|
* @param aMimeType
|
|
|
|
* Type of image in the stream.
|
|
|
|
*/
|
|
|
|
imgIContainer decodeImage(in nsIInputStream aStream,
|
|
|
|
in ACString aMimeType);
|
|
|
|
|
2017-11-27 19:05:57 +03:00
|
|
|
/**
|
|
|
|
* decodeImageAsync
|
|
|
|
* See decodeImage. The main difference between this method and decodeImage
|
|
|
|
* is that here the operation is done async on a thread from the decode
|
|
|
|
* pool. When the operation is completed, the callback is executed with the
|
|
|
|
* result.
|
|
|
|
*
|
|
|
|
* @param aStream
|
|
|
|
* An input stream for an encoded image file.
|
|
|
|
* @param aMimeType
|
|
|
|
* Type of image in the stream.
|
|
|
|
* @param aCallback
|
|
|
|
* The callback is executed when the imgContainer is fully created.
|
|
|
|
* @param aEventTarget
|
|
|
|
* This eventTarget is used to execute aCallback
|
|
|
|
*/
|
|
|
|
void decodeImageAsync(in nsIInputStream aStream,
|
|
|
|
in ACString aMimeType,
|
|
|
|
in imgIContainerCallback aCallback,
|
|
|
|
in nsIEventTarget aEventTarget);
|
|
|
|
|
2008-01-13 07:15:20 +03:00
|
|
|
/**
|
|
|
|
* encodeImage
|
|
|
|
* Caller provides an image container, and the mime type it should be
|
|
|
|
* encoded to. We return an input stream for the encoded image data.
|
|
|
|
*
|
|
|
|
* @param aContainer
|
|
|
|
* An image container.
|
|
|
|
* @param aMimeType
|
|
|
|
* Type of encoded image desired (eg "image/png").
|
2011-12-17 04:43:10 +04:00
|
|
|
* @param outputOptions
|
|
|
|
* Encoder-specific output options.
|
2008-01-13 07:15:20 +03:00
|
|
|
*/
|
|
|
|
nsIInputStream encodeImage(in imgIContainer aContainer,
|
2011-12-17 04:43:10 +04:00
|
|
|
in ACString aMimeType,
|
|
|
|
[optional] in AString outputOptions);
|
2008-01-13 07:15:20 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* encodeScaledImage
|
|
|
|
* Caller provides an image container, and the mime type it should be
|
|
|
|
* encoded to. We return an input stream for the encoded image data.
|
|
|
|
* The encoded image is scaled to the specified dimensions.
|
|
|
|
*
|
|
|
|
* @param aContainer
|
|
|
|
* An image container.
|
|
|
|
* @param aMimeType
|
|
|
|
* Type of encoded image desired (eg "image/png").
|
|
|
|
* @param aWidth, aHeight
|
2012-07-03 10:22:10 +04:00
|
|
|
* The size (in pixels) desired for the resulting image. Specify 0 to
|
|
|
|
* use the given image's width or height. Values must be >= 0.
|
2011-12-17 04:43:10 +04:00
|
|
|
* @param outputOptions
|
|
|
|
* Encoder-specific output options.
|
2008-01-13 07:15:20 +03:00
|
|
|
*/
|
|
|
|
nsIInputStream encodeScaledImage(in imgIContainer aContainer,
|
|
|
|
in ACString aMimeType,
|
|
|
|
in long aWidth,
|
2011-12-17 04:43:10 +04:00
|
|
|
in long aHeight,
|
|
|
|
[optional] in AString outputOptions);
|
2012-07-03 10:22:10 +04:00
|
|
|
|
2012-06-26 08:20:12 +04:00
|
|
|
/**
|
|
|
|
* getImgLoaderForDocument
|
|
|
|
* Retrieve an image loader that reflects the privacy status of the given
|
|
|
|
* document.
|
|
|
|
*
|
|
|
|
* @param doc
|
|
|
|
* A document. Must not be null.
|
|
|
|
*/
|
|
|
|
imgILoader getImgLoaderForDocument(in nsIDOMDocument doc);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getImgLoaderForDocument
|
|
|
|
* Retrieve an image cache that reflects the privacy status of the given
|
|
|
|
* document.
|
|
|
|
*
|
|
|
|
* @param doc
|
2012-09-26 07:51:18 +04:00
|
|
|
* A document. Null is allowed, but must _only_ be passed
|
|
|
|
* when there is no way to obtain a relevant document for
|
|
|
|
* the current context in which a cache is desired.
|
2012-06-26 08:20:12 +04:00
|
|
|
*/
|
|
|
|
imgICache getImgCacheForDocument(in nsIDOMDocument doc);
|
|
|
|
|
2012-07-03 10:22:10 +04:00
|
|
|
/**
|
|
|
|
* encodeCroppedImage
|
|
|
|
* Caller provides an image container, and the mime type it should be
|
|
|
|
* encoded to. We return an input stream for the encoded image data.
|
|
|
|
* The encoded image is cropped to the specified dimensions.
|
|
|
|
*
|
|
|
|
* The given offset and size must not exceed the image bounds.
|
|
|
|
*
|
|
|
|
* @param aContainer
|
|
|
|
* An image container.
|
|
|
|
* @param aMimeType
|
|
|
|
* Type of encoded image desired (eg "image/png").
|
|
|
|
* @param aOffsetX, aOffsetY
|
|
|
|
* The crop offset (in pixels). Values must be >= 0.
|
|
|
|
* @param aWidth, aHeight
|
|
|
|
* The size (in pixels) desired for the resulting image. Specify 0 to
|
|
|
|
* use the given image's width or height. Values must be >= 0.
|
|
|
|
* @param outputOptions
|
|
|
|
* Encoder-specific output options.
|
|
|
|
*/
|
|
|
|
nsIInputStream encodeCroppedImage(in imgIContainer aContainer,
|
|
|
|
in ACString aMimeType,
|
|
|
|
in long aOffsetX,
|
|
|
|
in long aOffsetY,
|
|
|
|
in long aWidth,
|
|
|
|
in long aHeight,
|
|
|
|
[optional] in AString outputOptions);
|
2012-10-12 20:11:22 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a wrapper around a scripted notification observer (ordinarily
|
|
|
|
* imgINotificationObserver cannot be implemented from scripts).
|
|
|
|
*
|
2014-12-06 02:12:08 +03:00
|
|
|
* @param aObserver The scripted observer to wrap
|
2012-10-12 20:11:22 +04:00
|
|
|
*/
|
2014-12-06 02:12:08 +03:00
|
|
|
imgINotificationObserver
|
|
|
|
createScriptedObserver(in imgIScriptedNotificationObserver aObserver);
|
2008-01-13 07:15:20 +03:00
|
|
|
};
|
2017-11-27 19:05:57 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a companion interface for nsIAsyncInputStream::asyncWait.
|
|
|
|
*/
|
|
|
|
[function, scriptable, uuid(f195772c-a4c0-47ae-80ca-211e001c67be)]
|
|
|
|
interface imgIContainerCallback : nsISupports
|
|
|
|
{
|
|
|
|
/* If the operation fails, aStatus will contain the error value */
|
|
|
|
void onImageReady(in imgIContainer aImage, in nsresult aStatus);
|
|
|
|
};
|