Skip to content

Commit

Permalink
[go] (2) Clarify error handling for getImageData/putImageData
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@807 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed May 11, 2007
1 parent 7bdbe8a commit 4469c15
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 2 deletions.
47 changes: 46 additions & 1 deletion index
Original file line number Diff line number Diff line change
Expand Up @@ -16534,7 +16534,21 @@ interface <dfn id=imagedata>ImageData</dfn> {
order, row by row, starting at the top left, with each pixel's red, green,
blue, and alpha components being given in that order. Each component of
each device pixel represented in this array must be in the range 0..255,
representing the 8 bit value for that component.
representing the 8 bit value for that component. At least one pixel must
be returned.

<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
backed by a high-resolution bitmap.

<p>If the <code title=dom-context-2d-getImageData><a
href="#getimagedata">getImageData(<var title="">sx</var>, <var
title="">sy</var>, <var title="">sw</var>, <var
title="">sh</var>)</a></code> method is called with either the <var
title="">sw</var> or <var title="">sh</var> arguments set to zero or
negative values, the method must raise an <code>INDEX_SIZE_ERR</code>
exception.

<p>The <dfn id=putimagedata
title=dom-context-2d-putImageData><code>putImageData(<var
Expand All @@ -16545,6 +16559,37 @@ interface <dfn id=imagedata>ImageData</dfn> {
canvas coordinate space, mapping each pixel represented by the <code><a
href="#imagedata">ImageData</a></code> structure into one device pixel.

<p>If any of the following conditions are true, the method must raise a
<code>TYPE_MISMATCH_ERR</code> exception:

<ul>
<li>The method's first argument is not an object with <code
title=dom-imagedata-width><a href="#width5">width</a></code> and <code
title=dom-imagedata-height><a href="#height5">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.

<li>The <code><a href="#imagedata">ImageData</a></code> object's <code
title=dom-imagedata-width><a href="#width5">width</a></code> is not
greater than zero.

<li>The <code><a href="#imagedata">ImageData</a></code> object's <code
title=dom-imagedata-height><a href="#height5">height</a></code> is not
greater than zero.

<li>The <code><a href="#imagedata">ImageData</a></code> object's <code
title=dom-imagedata-width><a href="#width5">width</a></code> multiplied
by its <code title=dom-imagedata-height><a
href="#height5">height</a></code> multiplied by 4 is not equal to the
number of entries in the 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 contains
entries that are not in the range 0 to 255 inclusive.
</ul>

<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
46 changes: 45 additions & 1 deletion source
Original file line number Diff line number Diff line change
Expand Up @@ -14147,7 +14147,20 @@ interface <dfn>ImageData</dfn> {
left, with each pixel's red, green, blue, and alpha components being
given in that order. Each component of each device pixel represented
in this array must be in the range 0..255, representing the 8 bit
value for that component.</p>
value for that component. At least one pixel must be returned.</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
canvas is backed by a high-resolution bitmap.</p>

<p>If the <code
title="dom-context-2d-getImageData">getImageData(<var
title="">sx</var>, <var title="">sy</var>, <var title="">sw</var>,
<var title="">sh</var>)</code> method is called with either the <var
title="">sw</var> or <var title="">sh</var> arguments set to zero or
negative values, the method must raise an
<code>INDEX_SIZE_ERR</code> exception.</p>

<p>The <dfn
title="dom-context-2d-putImageData"><code>putImageData(<var
Expand All @@ -14158,6 +14171,37 @@ interface <dfn>ImageData</dfn> {
coordinate space, mapping each pixel represented by the
<code>ImageData</code> structure into one device pixel.</p>

<p>If any of the following conditions are true, the method must
raise a <code>TYPE_MISMATCH_ERR</code> exception:</p>

<ul>

<li>The method's first argument is not an object with <code
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>

<li>The <code>ImageData</code> object's <code
title="dom-imagedata-width">width</code> is not greater than
zero.</li>

<li>The <code>ImageData</code> object's <code
title="dom-imagedata-height">height</code> is not greater than
zero.</li>

<li>The <code>ImageData</code> object's <code
title="dom-imagedata-width">width</code> multiplied by its <code
title="dom-imagedata-height">height</code> multiplied by 4 is not
equal to the number of entries in the 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 contains entries that
are not in the range 0 to 255 inclusive.</li>

</ul>

<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

0 comments on commit 4469c15

Please sign in to comment.