Skip to content

Commit

Permalink
Add ImageBitmapOptions to ImageBitmap's spec
Browse files Browse the repository at this point in the history
  • Loading branch information
xidachen committed Feb 29, 2016
1 parent 392c10a commit c665107
Showing 1 changed file with 76 additions and 14 deletions.
90 changes: 76 additions & 14 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -89418,10 +89418,20 @@ typedef (<span>HTMLImageElement</span> or
<span>CanvasRenderingContext2D</span> or
<span>ImageBitmap</span>) <dfn>ImageBitmapSource</dfn>;

enum <dfn>ImageOrientation</dfn> { "<span data-x="dom-ImageOrientation-none">none</span>", "<span data-x="dom-ImageOrientation-flipY">flipY</span>" };
enum <dfn>PremultiplyAlpha</dfn> { "<span data-x="dom-PremultiplyAlpha-none">none</span>", "<span data-x="dom-PremultiplyAlpha-premultiply">premultiply</span>", "<span data-x="dom-PremultiplyAlpha-default">default</span>" };
enum <dfn>ColorspaceConversion</dfn> { "<span data-x="dom-ColorspaceConversion-none">none</span>", "<span data-x="dom-ColorspaceConversion-default">default</span>" };

dictionary <dfn>ImageBitmapOptions</dfn> {
<span>ImageOrientation</span> <span data-x="dom-ImageBitmapOptions-imageOrientation">imageOrientation</span> = "<span data-x="dom-ImageOrientation-none">none</span>";
<span>PremultiplyAlpha</span> <span data-x="dom-ImageBitmapOptions-premultiplyAlpha">premultiplyAlpha</span> = "<span data-x="dom-PremultiplyAlpha-default">default</span>";
<span>ColorspaceConversion</span> <span data-x="dom-ImageBitmapOptions-colorspaceConversion">colorspaceConversion</span> = "<span data-x="dom-ColorspaceConversion-default">default</span>";
};

[NoInterfaceObject, Exposed=(Window,Worker)]
interface <dfn>ImageBitmapFactories</dfn> {
Promise&lt;ImageBitmap&gt; <span data-x="dom-createImageBitmap">createImageBitmap</span>(<span>ImageBitmapSource</span> image);
Promise&lt;ImageBitmap&gt; <span data-x="dom-createImageBitmap">createImageBitmap</span>(<span>ImageBitmapSource</span> image, long sx, long sy, long sw, long sh);
Promise&lt;ImageBitmap&gt; <span data-x="dom-createImageBitmap">createImageBitmap</span>(<span>ImageBitmapSource</span> image, optional <span>ImageBitmapOptions</span> options);
Promise&lt;ImageBitmap&gt; <span data-x="dom-createImageBitmap">createImageBitmap</span>(<span>ImageBitmapSource</span> image, long sx, long sy, long sw, long sh, optional <span>ImageBitmapOptions</span> options);
};
<span>Window</span> implements <span>ImageBitmapFactories</span>;
<span>WorkerGlobalScope</span> implements <span>ImageBitmapFactories</span>;</pre>
Expand All @@ -89436,7 +89446,8 @@ interface <dfn>ImageBitmapFactories</dfn> {

<dl class="domintro">

<dt><var>promise</var> = <var>Window</var> . <code subdfn data-x="dom-createImageBitmap">createImageBitmap</code>(<var>image</var> [, <var>sx</var>, <var>sy</var>, <var>sw</var>, <var>sh</var> ] )</dt>
<dt><var>promise</var> = <var>Window</var> . <code subdfn data-x="dom-createImageBitmap">createImageBitmap</code>(<var>image</var> [, <var>options</var> ])</dt>
<dt><var>promise</var> = <var>Window</var> . <code data-x="dom-createImageBitmap">createImageBitmap</code>(<var>image</var>, <var>sx</var>, <var>sy</var>, <var>sw</var>, <var>sh</var> [, <var>options</var> ])</dt>

<dd>

Expand All @@ -89453,6 +89464,13 @@ interface <dfn>ImageBitmapFactories</dfn> {
any pixels missing in the original replaced by transparent black. These coordinates are in the
source image's pixel coordinate space, <em>not</em> in CSS pixels.</p>

<p>If <var>options</var> is provided, the <code>ImageBitmap</code> object's bitmap
data is modified according to <var>options</var>. For example,
if the <code data-x="dom-ImageBitmapOptions-premultiplyAlpha">premultiplyAlpha</code>
option is set to "<code data-x="dom-PremultiplyAlpha-premultiply">premultiply</code>",
the <span data-x="concept-ImageBitmap-bitmap-data">bitmap data</span>'s color channels are
premultiplied by its alpha channel.

<p>Rejects the promise with an <code>InvalidStateError</code> exception if the source image is
not in a valid state (e.g. an <code>img</code> element that hasn't finished loading, or a
<code>CanvasRenderingContext2D</code> object whose bitmap data has zero length along one or
Expand Down Expand Up @@ -89549,8 +89567,8 @@ interface <dfn>ImageBitmapFactories</dfn> {

<li><p>Let the <code>ImageBitmap</code> object's <span
data-x="concept-ImageBitmap-bitmap-data">bitmap data</span> be a copy of the <code>img</code>
element's media data, <span>cropped to the source rectangle</span>. If this is an animated
image, the <code>ImageBitmap</code> object's <span
element's media data, <span>cropped to the source rectangle with formatting</span>. If this is
an animated image, the <code>ImageBitmap</code> object's <span
data-x="concept-ImageBitmap-bitmap-data">bitmap data</span> must only be taken from the
default image of the animation (the one that the format defines is to be used when animation
is not supported or is disabled), or, if there is no such image, the first frame of the
Expand Down Expand Up @@ -89597,7 +89615,7 @@ interface <dfn>ImageBitmapFactories</dfn> {
<span>current playback position</span>, at the <span>media resource</span>'s <span
data-x="concept-video-intrinsic-width">intrinsic width</span> and <span
data-x="concept-video-intrinsic-height">intrinsic height</span> (i.e. after any aspect-ratio
correction has been applied), <span>cropped to the source rectangle</span>.</p>
correction has been applied), <span>cropped to the source rectangle with formatting</span>.</p>

<li><p>If the <span>origin</span> of the <code>video</code> element is not the <span>same
origin</span> as the <span>origin</span> specified by the <span>entry settings object</span>,
Expand Down Expand Up @@ -89632,7 +89650,7 @@ interface <dfn>ImageBitmapFactories</dfn> {
data-x="concept-ImageBitmap-bitmap-data">bitmap data</span> be a copy of the
<code>canvas</code> element's <span
data-x="concept-ImageBitmap-bitmap-data">bitmap data</span>, <span>cropped to the source
rectangle</span>.</p></li>
rectangle with formatting</span>.</p></li>

<li><p>Set the <span data-x="concept-canvas-origin-clean">origin-clean</span> flag of the
<code>ImageBitmap</code> object's bitmap to the same value as the <span
Expand Down Expand Up @@ -89681,8 +89699,8 @@ interface <dfn>ImageBitmapFactories</dfn> {

<li><p>Let the <code>ImageBitmap</code> object's <span
data-x="concept-ImageBitmap-bitmap-data">bitmap data</span> be the image data read from the
<code>Blob</code> object, <span>cropped to the source rectangle</span>. If this is an animated
image, the <code>ImageBitmap</code> object's <span
<code>Blob</code> object, <span>cropped to the source rectangle with formatting</span>.
If this is an animated image, the <code>ImageBitmap</code> object's <span
data-x="concept-ImageBitmap-bitmap-data">bitmap data</span> must only be taken from the
default image of the animation (the one that the format defines is to be used when animation
is not supported or is disabled), or, if there is no such image, the first frame of the
Expand Down Expand Up @@ -89712,7 +89730,7 @@ interface <dfn>ImageBitmapFactories</dfn> {

<li><p>Let the <code>ImageBitmap</code> object's <span
data-x="concept-ImageBitmap-bitmap-data">bitmap data</span> be the image data given by the
<code>ImageData</code> object, <span>cropped to the source rectangle</span>.</p></li>
<code>ImageData</code> object, <span>cropped to the source rectangle with formatting</span>.</p></li>

<li><p>Return a new promise, but continue running these steps
<span>in parallel</span>.</p></li>
Expand Down Expand Up @@ -89741,7 +89759,7 @@ interface <dfn>ImageBitmapFactories</dfn> {
<li><p>Let the <code>ImageBitmap</code> object's <span
data-x="concept-ImageBitmap-bitmap-data">bitmap data</span> be a copy of the
<code>CanvasRenderingContext2D</code> object's <span>scratch bitmap</span>, <span>cropped to
the source rectangle</span>.</p></li>
the source rectangle with formatting</span>.</p></li>

<li><p>Set the <span data-x="concept-canvas-origin-clean">origin-clean</span> flag of the
<code>ImageBitmap</code> object's bitmap to the same value as the <span
Expand Down Expand Up @@ -89777,7 +89795,7 @@ interface <dfn>ImageBitmapFactories</dfn> {
<li><p>Let the <code>ImageBitmap</code> object's <span
data-x="concept-ImageBitmap-bitmap-data">bitmap data</span> be a copy of the <var>image</var>
argument's <span data-x="concept-ImageBitmap-bitmap-data">bitmap data</span>, <span>cropped
to the source rectangle</span>.</p></li>
to the source rectangle with formatting</span>.</p></li>

<li><p>Set the <span data-x="concept-canvas-origin-clean">origin-clean</span> flag of the
<code>ImageBitmap</code> object's bitmap to the same value as the <span
Expand All @@ -89797,8 +89815,8 @@ interface <dfn>ImageBitmapFactories</dfn> {
</dl>

<p>When the steps above require that the user agent <dfn data-x="cropped to the source
rectangle">crop bitmap data to the source rectangle</dfn>, the user agent must run the following
steps:</p>
rectangle with formatting">crop bitmap data to the source rectangle with formatting</dfn>,
the user agent must run the following steps:</p>

<ol>

Expand Down Expand Up @@ -89826,6 +89844,46 @@ interface <dfn>ImageBitmapFactories</dfn> {

</li>

<li><p>If the value of the <dfn><code
data-x="dom-ImageBitmapOptions-imageOrientation">imageOrientation</code></dfn> member of
<var>options</var> is "<dfn><code data-x="dom-ImageOrientation-none">none</code></dfn>",
no extra step is required. If it is "<dfn><code
data-x="dom-ImageOrientation-flipY">flipY</code></dfn>", <var>output</var> must be flipped
vertically, disregarding any image orientation metadata of the source (such as EXIF metadata),
if any. <ref spec=EXIF></p></li>

<li>

<p>If the value of the <dfn><code
data-x="dom-ImageBitmapOptions-colorspaceConversion">colorspaceConversion</code></dfn> member of
<var>options</var> is "<dfn><code data-x="dom-ColorspaceConversion-default">default</code></dfn>",
the colorspace conversion behavior is implementation-specific, and should be chosen according
to the colorspace that the implementation uses for drawing images onto the canvas. If it is
"<dfn><code data-x="dom-ColorspaceConversion-none">none</code></dfn>", <var>output</var> must
be decoded without performing any colorspace conversions. This means that the image decoding
algorithm must ignore color profile metadata embedded in the source data as well as the display
device color profile.
<code data-x="dom-ImageBitmapOptions-colorspaceConversion">colorspaceConversion</code>
only applies when creating an <code>ImageBitmap</code> object from bitmap media
data such as a <code>Blob</code> object or an <code>img</code> element with non-vector images.</p>

<p class="note">The native colorspace of canvas is currently unspecified, but this is expected
to change in the future.</p>

</li>

<li><p>If the value of the <dfn><code
data-x="dom-ImageBitmapOptions-premultiplyAlpha">premultiplyAlpha</code></dfn> member of
<var>options</var> is "<dfn><code data-x="dom-PremultiplyAlpha-default">default</code></dfn>",
the alpha premultiplication behavior is implementation-specific, and should be chosen according
to implementation deems optimal for drawing images onto the canvas. If it is
"<dfn><code data-x="dom-PremultiplyAlpha-premultiply">premultiply</code></dfn>", the
<var>output</var> that is not premultiplied by alpha must have its color components multiplied
by alpha and that is premultiplied by alpha must be left untouched. If it is
"<dfn><code data-x="dom-PremultiplyAlpha-none">none</code></dfn>", the <var>output</var> that is
not premultiplied by alpha must be left untouched and that is premultiplied by alpha
must have its color components divided by alpha.</p></li>

<li><p>Return <var>output</var>.</p></li>

</ol>
Expand Down Expand Up @@ -115846,6 +115904,9 @@ INSERT INTERFACES HERE
<dt id="refsENCODING">[ENCODING]</dt>
<dd><cite><a href="https://encoding.spec.whatwg.org/">Encoding</a></cite>, A. van Kesteren, J. Bell. WHATWG.</dd>

<dt id="refsEXIF">[EXIF]</dt>
<dd>(Non-normative) <cite><a href="http://www.jeita.or.jp/cgi-bin/standard_e/list.cgi?cateid=1&subcateid=4">Exchangeable image file format</a></cite>. JEITA.</dd>

<dt id="refsFETCH">[FETCH]</dt>
<dd><cite><a href="https://fetch.spec.whatwg.org/">Fetch</a></cite>, A. van Kesteren. WHATWG.</dd>

Expand Down Expand Up @@ -116926,6 +116987,7 @@ INSERT INTERFACES HERE
Wolfram Kriesing,
Xan Gregg,
xenotheme,
Xida Chen,
Yang Chen,
Ye-Kui Wang,
Yehuda Katz,
Expand Down

0 comments on commit c665107

Please sign in to comment.