2008-01-12 20:15:20 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 04:12:37 -07: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-12 20:15:20 -08:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
interface nsIInputStream;
|
|
|
|
interface imgIContainer;
|
2012-06-25 21:20:12 -07:00
|
|
|
interface imgILoader;
|
|
|
|
interface imgICache;
|
|
|
|
interface nsIDOMDocument;
|
2008-01-12 20:15:20 -08:00
|
|
|
|
2012-06-25 21:20:12 -07:00
|
|
|
[scriptable, uuid(53dd1cbe-cb9f-4d9e-8104-1ab72851c88e)]
|
2008-01-12 20:15:20 -08:00
|
|
|
interface imgITools : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* decodeImageData
|
|
|
|
* 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. (If the caller already has a container,
|
|
|
|
* it can be provided as input to be reused).
|
|
|
|
*
|
|
|
|
* @param aStream
|
|
|
|
* An input stream for an encoded image file.
|
|
|
|
* @param aMimeType
|
|
|
|
* Type of image in the stream.
|
|
|
|
* @param aContainer
|
|
|
|
* An imgIContainer holding the decoded image. Specify |null| when
|
|
|
|
* calling to have one created, otherwise specify a container to
|
2009-09-12 15:44:18 -07:00
|
|
|
* be used. It is an error to pass an already-initialized container
|
|
|
|
* as aContainer.
|
2008-01-12 20:15:20 -08:00
|
|
|
*/
|
|
|
|
void decodeImageData(in nsIInputStream aStream,
|
|
|
|
in ACString aMimeType,
|
|
|
|
inout imgIContainer aContainer);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-16 16:43:10 -08:00
|
|
|
* @param outputOptions
|
|
|
|
* Encoder-specific output options.
|
2008-01-12 20:15:20 -08:00
|
|
|
*/
|
|
|
|
nsIInputStream encodeImage(in imgIContainer aContainer,
|
2011-12-16 16:43:10 -08:00
|
|
|
in ACString aMimeType,
|
|
|
|
[optional] in AString outputOptions);
|
2008-01-12 20:15:20 -08: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-02 23:22:10 -07: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-16 16:43:10 -08:00
|
|
|
* @param outputOptions
|
|
|
|
* Encoder-specific output options.
|
2008-01-12 20:15:20 -08:00
|
|
|
*/
|
|
|
|
nsIInputStream encodeScaledImage(in imgIContainer aContainer,
|
|
|
|
in ACString aMimeType,
|
|
|
|
in long aWidth,
|
2011-12-16 16:43:10 -08:00
|
|
|
in long aHeight,
|
|
|
|
[optional] in AString outputOptions);
|
2012-07-02 23:22:10 -07:00
|
|
|
|
2012-06-25 21:20:12 -07: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
|
|
|
|
* A document. Must not be null.
|
|
|
|
*/
|
|
|
|
imgICache getImgCacheForDocument(in nsIDOMDocument doc);
|
|
|
|
|
2012-07-02 23:22:10 -07: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);
|
2008-01-12 20:15:20 -08:00
|
|
|
};
|