Bug 1608150 [wpt PR 21112] - Add missing space in `./wpt lint` command line docs...
[gecko.git] / image / imgIEncoder.idl
blob8d6eae76ef04c95928b40bed833359ebb3451e5d
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsISupports.idl"
7 #include "nsIAsyncInputStream.idl"
8 #include "nsIEventTarget.idl"
10 /**
11 * imgIEncoder interface
13 [scriptable, uuid(4baa2d6e-fee7-42df-ae3f-5fbebc0c267c)]
14 interface imgIEncoder : nsIAsyncInputStream
16 // Possible values for outputOptions. Multiple values are semicolon-separated.
18 // PNG:
19 // ----
20 // transparency=[yes|no|none] -- default: "yes"
21 // Overrides default from input format. "no" and "none" are equivalent.
24 // APNG:
25 // -----
26 // The following options can be used with startImageEncode():
28 // transparency=[yes|no|none] -- default: "yes"
29 // Overrides default from input format. "no" and "none" are equivalent.
30 // skipfirstframe=[yes|no] -- default: "no"
31 // Controls display of the first frame in animations. PNG-only clients
32 // always display the first frame (and only that frame).
33 // frames=# -- default: "1"
34 // Total number of frames in the image. The first frame, even if skipped,
35 // is always included in the count.
36 // plays=# -- default: "0"
37 // Number of times to play the animation sequence. "0" will repeat
38 // forever.
40 // The following options can be used for each frame, with addImageFrame():
42 // transparency=[yes|no|none] -- default: "yes"
43 // Overrides default from input format. "no" and "none" are equivalent.
44 // delay=# -- default: "500"
45 // Number of milliseconds to display the frame, before moving to the next
46 // frame.
47 // dispose=[none|background|previous] -- default: "none"
48 // What to do with the image's canvas before rendering the next frame.
49 // See APNG spec.
50 // blend=[source|over] -- default: "source"
51 // How to render the new frame on the canvas. See APNG spec.
52 // xoffset=# -- default: "0"
53 // yoffset=# -- default: "0"
54 // Where to draw the frame, relative to the canvas.
57 // JPEG:
58 // -----
60 // quality=# -- default: "92"
61 // Quality of compression, 0-100 (worst-best).
62 // Quality >= 90 prevents down-sampling of the color channels.
65 // Possible values for input format (note that not all image formats
66 // support saving alpha channels):
68 // Input is RGB each pixel is represented by three bytes:
69 // R, G, and B (in that order, regardless of host endianness)
70 const uint32_t INPUT_FORMAT_RGB = 0;
72 // Input is RGB each pixel is represented by four bytes:
73 // R, G, and B (in that order, regardless of host endianness).
74 // POST-MULTIPLIED alpha us used (50% transparent red is 0xff000080)
75 const uint32_t INPUT_FORMAT_RGBA = 1;
77 // Input is host-endian ARGB: On big-endian machines each pixel is therefore
78 // ARGB, and for little-endian machiens (Intel) each pixel is BGRA
79 // (This is used by canvas to match it's internal representation)
81 // PRE-MULTIPLIED alpha is used (That is, 50% transparent red is 0x80800000,
82 // not 0x80ff0000
83 const uint32_t INPUT_FORMAT_HOSTARGB = 2;
85 /* data - list of bytes in the format specified by inputFormat
86 * width - width in pixels
87 * height - height in pixels
88 * stride - number of bytes per row in the image
89 * Normally (width*3) or (width*4), depending on your input format,
90 * but some data uses padding at the end of each row, which would
91 * be extra.
92 * inputFormat - one of INPUT_FORMAT_* specifying the format of data
93 * outputOptions - semicolon-delimited list of name=value pairs that can
94 * give options to the output encoder. Options are encoder-
95 * specific. Just give empty string for default behavior.
97 void initFromData([array, size_is(length), const] in uint8_t data,
98 in unsigned long length,
99 in uint32_t width,
100 in uint32_t height,
101 in uint32_t stride,
102 in uint32_t inputFormat,
103 in AString outputOptions);
106 * For encoding images which may contain multiple frames, the 1-shot
107 * initFromData() interface is too simplistic. The alternative is to
108 * use startImageEncode(), call addImageFrame() one or more times, and
109 * then finish initialization with endImageEncode().
111 * The arguments are basically the same as in initFromData().
113 void startImageEncode(in uint32_t width,
114 in uint32_t height,
115 in uint32_t inputFormat,
116 in AString outputOptions);
118 void addImageFrame( [array, size_is(length), const] in uint8_t data,
119 in unsigned long length,
120 in uint32_t width,
121 in uint32_t height,
122 in uint32_t stride,
123 in uint32_t frameFormat,
124 in AString frameOptions);
126 void endImageEncode();
129 * Sometimes an encoder can contain another encoder and direct access
130 * to its buffer is necessary. It is only safe to assume that the buffer
131 * returned from getImageBuffer() is of size equal to getImageBufferUsed().
133 [noscript] unsigned long getImageBufferUsed();
134 [noscript] charPtr getImageBuffer();