Skip to content

Commit

Permalink
[gow] (2) ImageData: make the object handle having new values set. Cl…
Browse files Browse the repository at this point in the history
…arify what it means to call putImageData() (not drawing). Clarify how to handle non-ImageData data. Make the color spaces compatible with CSS; make toDataURL() not include color space information.

git-svn-id: http://svn.whatwg.org/webapps@1165 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jan 18, 2008
1 parent bfc3dd0 commit 6d8e020
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 36 deletions.
59 changes: 41 additions & 18 deletions index
Original file line number Diff line number Diff line change
Expand Up @@ -17296,6 +17296,20 @@ notes on what would need to be defined for dashed lines:
representing the 8 bit value for that component. At least one pixel must
be returned.

<p>The values of the <code title=dom-imagedata-data><a
href="#data1">data</a></code> array may be changed (the length of the
array, and the other attributes in <code><a
href="#imagedata">ImageData</a></code> objects, are all read-only). On
setting, JS <code>undefined</code> values must be converted to zero. Other
values must first be converted to numbers using JavaScript's ToNumber
algorithm, and if the result is not a number, a
<code>TYPE_MISMATCH_ERR</code> exception must be raised. If the result is
less than 0, it must be clamped to zero. If the result is more than 255,
it must be clamed to 255. If the number is not an integer, it must be
rounded to the nearest integer using the IEEE 754r <i>roundTiesToEven</i>
rounding mode. <a href="#refsECMA262">[ECMA262]</a> <a
href="#refsIEEE754r">[IEEE754R]</a>

<p class=note>The width and height (<var title="">w</var> and <var
title="">h</var>) might be different than the <var title="">sw</var> and
<var title="">sh</var> arguments to the function, e.g. if the canvas is
Expand All @@ -17313,7 +17327,7 @@ notes on what would need to be defined for dashed lines:
title=dom-context-2d-putImageData><code>putImageData(<var
title="">image</var>, <var title="">dx</var>, <var
title="">dy</var>)</code></dfn> method must take the given <code><a
href="#imagedata">ImageData</a></code> structure, and draw it at the
href="#imagedata">ImageData</a></code> structure, and place it at the
specified location <var title="">dx</var>,<var title="">dy</var> in the
canvas coordinate space, mapping each pixel represented by the <code><a
href="#imagedata">ImageData</a></code> structure into one device pixel.
Expand All @@ -17329,7 +17343,9 @@ notes on what would need to be defined for dashed lines:
title=dom-imagedata-width><a href="#width2">width</a></code> and <code
title=dom-imagedata-height><a href="#height2">height</a></code>
attributes with integer values and a <code title=dom-imagedata-data><a
href="#data1">data</a></code> attribute whose value is an integer array.
href="#data1">data</a></code> attribute whose value is an enumerable list
of values that are either JS Numbers or the JS value
<code>undefined</code>.

<li>The <code><a href="#imagedata">ImageData</a></code> object's <code
title=dom-imagedata-width><a href="#width2">width</a></code> is greater
Expand All @@ -17345,13 +17361,16 @@ notes on what would need to be defined for dashed lines:
href="#height2">height</a></code> multiplied by 4 is equal to the number
of entries in the <code><a href="#imagedata">ImageData</a></code>
object's <code title=dom-imagedata-data><a href="#data1">data</a></code>
array.

<li>The <code><a href="#imagedata">ImageData</a></code> object's <code
title=dom-imagedata-data><a href="#data1">data</a></code> array only
contains entries that are in the range 0 to 255 inclusive.
property.
</ul>

<p>In the <code title=dom-imagedata-data><a href="#data1">data</a></code>
property, undefined values must be treated as zero, any numbers below zero
must be clamped to zero, any numbers above 255 must be clamped to 255, and
any numbers that are not integers must be rounded to the nearest integer
using the IEEE 754r <i>roundTiesToEven</i> rounding mode. <a
href="#refsIEEE754r">[IEEE754R]</a>

<p>The handling of pixel rounding when the specified coordinates do not
exactly map to the device coordinate space is not defined by this
specification, except that the following must result in no visible changes
Expand Down Expand Up @@ -17472,21 +17491,25 @@ notes on what would need to be defined for dashed lines:

<p>The <code><a href="#canvas">canvas</a></code> APIs must perform colour
correction at only two points: when rendering images with their own gamma
correction information onto the canvas (e.g. using the <code
correction information onto the canvas, to convert the image to the color
space used by the canvas (e.g. using the <code
title=dom-context-2d-drawImage><a href="#drawimage">drawImage()</a></code>
method with an <code><a
href="#htmlimageelement">HTMLImageElement</a></code> object, to convert
the image to the color space used by the canvas), and when rendering the
actual canvas bitmap to the output device or to an external resource (e.g.
using the <code title=dom-canvas-toDataURL><a
href="#todataurl">toDataURL()</a></code> method).

<p>Thus, colors used to draw shapes onto the canvas will exactly match
colors obtained through the <code title=dom-context-2d-getImageData><a
href="#htmlimageelement">HTMLImageElement</a></code> object), and when
rendering the actual canvas bitmap to the output device.

<p>Thus, in the 2D context, colors used to draw shapes onto the canvas will
exactly match colors obtained through the <code
title=dom-context-2d-getImageData><a
href="#getimagedata">getImageData()</a></code> method.

<p class=big-issue>(is this right?) <!-- XXX --> The canvas must use the
sRGB color space. <a href="#refsSRGB">[SRGB]</a>
<p>The <code title=dom-canvas-toDataURL><a
href="#todataurl">toDataURL()</a></code> method must not include color
space information in the resource returned.

<p>In user agents that support CSS, the color space used by a <code><a
href="#canvas">canvas</a></code> element must match the color space used
for processing any colors for that element in CSS.

<h4 id=the-map><span class=secno>3.14.12. </span>The <dfn
id=map><code>map</code></dfn> element</h4>
Expand Down
56 changes: 38 additions & 18 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -14879,6 +14879,20 @@ notes on what would need to be defined for dashed lines:
in this array must be in the range 0..255, representing the 8 bit
value for that component. At least one pixel must be returned.</p>

<p>The values of the <code title="dom-imagedata-data">data</code>
array may be changed (the length of the array, and the other
attributes in <code>ImageData</code> objects, are all read-only). On
setting, JS <code>undefined</code> values must be converted to zero.
Other values must first be converted to numbers using JavaScript's
ToNumber algorithm, and if the result is not a number, a
<code>TYPE_MISMATCH_ERR</code> exception must be raised. If the
result is less than 0, it must be clamped to zero. If the result is
more than 255, it must be clamed to 255. If the number is not an
integer, it must be rounded to the nearest integer using the IEEE
754r <i>roundTiesToEven</i> rounding mode. <a
href="#refsECMA262">[ECMA262]</a> <a
href="#refsIEEE754r">[IEEE754R]</a></p>

<p class="note">The width and height (<var title="">w</var> and <var
title="">h</var>) might be different than the <var title="">sw</var>
and <var title="">sh</var> arguments to the function, e.g. if the
Expand All @@ -14896,7 +14910,7 @@ notes on what would need to be defined for dashed lines:
title="dom-context-2d-putImageData"><code>putImageData(<var
title="">image</var>, <var title="">dx</var>, <var
title="">dy</var>)</code></dfn> method must take the given
<code>ImageData</code> structure, and draw it at the specified
<code>ImageData</code> structure, and place it at the specified
location <var title="">dx</var>,<var title="">dy</var> in the canvas
coordinate space, mapping each pixel represented by the
<code>ImageData</code> structure into one device pixel.</p>
Expand All @@ -14913,7 +14927,8 @@ notes on what would need to be defined for dashed lines:
title="dom-imagedata-width">width</code> and <code
title="dom-imagedata-height">height</code> attributes with integer
values and a <code title="dom-imagedata-data">data</code> attribute
whose value is an integer array.</li>
whose value is an enumerable list of values that are either JS
Numbers or the JS value <code>undefined</code>.</li>

<li>The <code>ImageData</code> object's <code
title="dom-imagedata-width">width</code> is greater than
Expand All @@ -14927,14 +14942,17 @@ notes on what would need to be defined for dashed lines:
title="dom-imagedata-width">width</code> multiplied by its <code
title="dom-imagedata-height">height</code> multiplied by 4 is equal
to the number of entries in the <code>ImageData</code> object's
<code title="dom-imagedata-data">data</code> array.</li>

<li>The <code>ImageData</code> object's <code
title="dom-imagedata-data">data</code> array only contains entries
that are in the range 0 to 255 inclusive.</li>
<code title="dom-imagedata-data">data</code> property.</li>

</ul>

<p>In the <code title="dom-imagedata-data">data</code> property,
undefined values must be treated as zero, any numbers below zero
must be clamped to zero, any numbers above 255 must be clamped to
255, and any numbers that are not integers must be rounded to the
nearest integer using the IEEE 754r <i>roundTiesToEven</i> rounding
mode. <a href="#refsIEEE754r">[IEEE754R]</a></p>

<p>The handling of pixel rounding when the specified coordinates do
not exactly map to the device coordinate space is not defined by
this specification, except that the following must result in no
Expand Down Expand Up @@ -15065,22 +15083,24 @@ notes on what would need to be defined for dashed lines:

<p>The <code>canvas</code> APIs must perform colour correction at
only two points: when rendering images with their own gamma
correction information onto the canvas (e.g. using the <code
correction information onto the canvas, to convert the image to the
color space used by the canvas (e.g. using the <code
title="dom-context-2d-drawImage">drawImage()</code> method with an
<code>HTMLImageElement</code> object, to convert the image to the
color space used by the canvas), and when rendering the actual
canvas bitmap to the output device or to an external resource
(e.g. using the <code
title="dom-canvas-toDataURL">toDataURL()</code> method).</p>

<p>Thus, colors used to draw shapes onto the canvas will exactly
match colors obtained through the <code
<code>HTMLImageElement</code> object), and when rendering the actual
canvas bitmap to the output device.</p>

<p>Thus, in the 2D context, colors used to draw shapes onto the
canvas will exactly match colors obtained through the <code
title="dom-context-2d-getImageData">getImageData()</code>
method.</p>

<p class="big-issue">(is this right?) <!-- XXX --> The canvas must
use the sRGB color space. <a href="#refsSRGB">[SRGB]</a></p>
<p>The <code title="dom-canvas-toDataURL">toDataURL()</code> method
must not include color space information in the resource
returned.</p>

<p>In user agents that support CSS, the color space used by a
<code>canvas</code> element must match the color space used for
processing any colors for that element in CSS.</p>



Expand Down

0 comments on commit 6d8e020

Please sign in to comment.