gecko/modules/libpr0n/public/imgIEncoder.idl

159 lines
6.5 KiB
Plaintext
Raw Normal View History

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Oracle Corporation code.
*
* The Initial Developer of the Original Code is Oracle Corporation.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@pavlov.net>
* Brett Wilson <brettw@gmail.com>
* Justin Dolske <dolske@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIInputStream.idl"
/**
* imgIEncoder interface
*/
[scriptable, uuid(ba3a854b-fb8d-4881-8af9-5849df10e5e5)]
interface imgIEncoder : nsIInputStream
{
// Possible values for outputOptions. Multiple values are semicolon-separated.
//
// PNG:
// ----
// transparency=[yes|no|none] -- default: "yes"
// Overrides default from input format. "no" and "none" are equivalent.
//
//
// APNG:
// -----
// The following options can be used with startImageEncode():
//
// transparency=[yes|no|none] -- default: "yes"
// Overrides default from input format. "no" and "none" are equivalent.
// skipfirstframe=[yes|no] -- default: "no"
// Controls display of the first frame in animations. PNG-only clients always
// display the first frame (and only that frame).
// frames=# -- default: "1"
// Total number of frames in the image. The first frame, even if skipped, is
// always included in the count.
// plays=# -- default: "0"
// Number of times to play the animation sequence. "0" will repeat forever.
//
//
// The following options can be used for each frame, with addImageFrame():
//
// transparency=[yes|no|none] -- default: "yes"
// Overrides default from input format. "no" and "none" are equivalent.
// delay=# -- default: "500"
// Number of milliseconds to display the frame, before moving to the next frame.
// dispose=[none|background|previous] -- default: "none"
// What to do with the image's canvas before rendering the next frame. See APNG spec.
// blend=[source|over] -- default: "source"
// How to render the new frame on the canvas. See APNG spec.
// xoffset=# -- default: "0"
// yoffset=# -- default: "0"
// Where to draw the frame, relative to the canvas.
//
//
// JPEG:
// -----
//
// quality=# -- default: "92"
// Quality of compression, 0-100 (worst-best).
// Quality >= 90 prevents down-sampling of the color channels.
// Possible values for input format (note that not all image formats
// support saving alpha channels):
// Input is RGB each pixel is represented by three bytes:
// R, G, and B (in that order, regardless of host endianness)
const PRUint32 INPUT_FORMAT_RGB = 0;
// Input is RGB each pixel is represented by four bytes:
// R, G, and B (in that order, regardless of host endianness).
// POST-MULTIPLIED alpha us used (50% transparent red is 0xff000080)
const PRUint32 INPUT_FORMAT_RGBA = 1;
// Input is host-endian ARGB: On big-endian machines each pixel is therefore
// ARGB, and for little-endian machiens (Intel) each pixel is BGRA
// (This is used by canvas to match it's internal representation)
//
// PRE-MULTIPLIED alpha is used (That is, 50% transparent red is 0x80800000,
// not 0x80ff0000
const PRUint32 INPUT_FORMAT_HOSTARGB = 2;
/* data - list of bytes in the format specified by inputFormat
* width - width in pixels
* height - height in pixels
* stride - number of bytes per row in the image
* Normally (width*3) or (width*4), depending on your input format,
* but some data uses padding at the end of each row, which would
* be extra.
* inputFormat - one of INPUT_FORMAT_* specifying the format of data
* outputOptions - semicolon-delimited list of name=value pairs that can
* give options to the output encoder. Options are encoder-
* specific. Just give empty string for default behavior.
*/
void initFromData([array, size_is(length), const] in PRUint8 data,
in unsigned long length,
in PRUint32 width,
in PRUint32 height,
in PRUint32 stride,
in PRUint32 inputFormat,
in AString outputOptions);
/*
* For encoding images which may contain multiple frames, the 1-shot
* initFromData() interface is too simplistic. The alternative is to
* use startImageEncode(), call addImageFrame() one or more times, and
* then finish initialization with endImageEncode().
*
* The arguments are basically the same as in initFromData().
*/
void startImageEncode(in PRUint32 width,
in PRUint32 height,
in PRUint32 inputFormat,
in AString outputOptions);
void addImageFrame( [array, size_is(length), const] in PRUint8 data,
in unsigned long length,
in PRUint32 width,
in PRUint32 height,
in PRUint32 stride,
in PRUint32 frameFormat,
in AString frameOptions);
void endImageEncode();
};