HTML5 Tracker

Diff (omit for latest revision)
Filter

Short URL: http://html5.org/r/7177

SVNBugCommentTime (UTC)
7177[Gecko] [Internet Explorer] [Opera] [Webkit] Admit defeat: putImageData() assumes 96dpi. We'll add HD versions of these methods shortly.2012-07-16 19:16
Index: source
===================================================================
--- source	(revision 7176)
+++ source	(revision 7177)
@@ -41730,11 +41730,11 @@
   void <span title="dom-context-2d-addHitRegion">addHitRegion</span>(<span>HitRegionOptions</span> options);
 
   // pixel manipulation
-  <span>ImageData</span> <span title="dom-context-2d-createImageData">createImageData</span>(unrestricted double sw, unrestricted double sh);
+  <span>ImageData</span> <span title="dom-context-2d-createImageData">createImageData</span>(double sw, double sh);
   <span>ImageData</span> <span title="dom-context-2d-createImageData">createImageData</span>(<span>ImageData</span> imagedata);
-  <span>ImageData</span> <span title="dom-context-2d-getImageData">getImageData</span>(unrestricted double sx, unrestricted double sy, unrestricted double sw, unrestricted double sh);
-  void <span title="dom-context-2d-putImageData">putImageData</span>(<span>ImageData</span> imagedata, unrestricted double dx, unrestricted double dy);
-  void <span title="dom-context-2d-putImageData">putImageData</span>(<span>ImageData</span> imagedata, unrestricted double dx, unrestricted double dy, unrestricted double dirtyX, unrestricted double dirtyY, unrestricted double dirtyWidth, unrestricted double dirtyHeight);
+  <span>ImageData</span> <span title="dom-context-2d-getImageData">getImageData</span>(double sx, double sy, double sw, double sh);
+  void <span title="dom-context-2d-putImageData">putImageData</span>(<span>ImageData</span> imagedata, double dx, double dy);
+  void <span title="dom-context-2d-putImageData">putImageData</span>(<span>ImageData</span> imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
 };
 <span>CanvasRenderingContext2D</span> implements <span>CanvasDrawingStyles</span>;
 <span>CanvasRenderingContext2D</span> implements <span>CanvasPathMethods</span>;
@@ -46671,9 +46671,8 @@
    <dd>
 
     <p>Returns an <code>ImageData</code> object with the given
-    dimensions in CSS pixels (which might map to a different number of
-    actual device pixels exposed by the object itself). All the pixels
-    in the returned object are transparent black.</p>
+    dimensions. All the pixels in the returned object are transparent
+    black.</p>
 
    </dd>
 
@@ -46699,6 +46698,9 @@
     exception if the either of the width or height arguments are
     zero.</p>
 
+    <p>The data will be returned with one pixel of image data for each
+    coordinate space unit on the canvas (ignoring transforms).</p>
+
    </dd>
 
    <dt><var title="">imagedata</var> . <code title="dom-imagedata-width">width</code></dt>
@@ -46737,6 +46739,9 @@
     <p>Throws a <code>NotSupportedError</code> exception if any of the
     arguments are not finite.</p>
 
+    <p>Each pixel in the image data is mapped to one coordinate space
+    unit on the canvas.</p>
+
    </dd>
 
   </dl>
@@ -46749,14 +46754,13 @@
   objects. When the method is invoked with two arguments <var
   title="">sw</var> and <var title="">sh</var>, it must return an
   <code>ImageData</code> object representing a rectangle with a width
-  in CSS pixels equal to the absolute magnitude of <var
-  title="">sw</var> and a height in CSS pixels equal to the absolute
-  magnitude of <var title="">sh</var>. When invoked with a single <var
-  title="">imagedata</var> argument, it must return an
-  <code>ImageData</code> object representing a rectangle with the same
-  dimensions as the <code>ImageData</code> object passed as the
-  argument. The <code>ImageData</code> object returned must be filled
-  with transparent black.</p>
+  in equal to the absolute magnitude of <var title="">sw</var> and a
+  height equal to the absolute magnitude of <var title="">sh</var>.
+  When invoked with a single <var title="">imagedata</var> argument,
+  it must return an <code>ImageData</code> object representing a
+  rectangle with the same dimensions as the <code>ImageData</code>
+  object passed as the argument. The <code>ImageData</code> object
+  returned must be filled with transparent black.</p>
 
   <p>The <dfn
   title="dom-context-2d-getImageData"><code>getImageData(<var
@@ -46766,7 +46770,8 @@
   if the <code>canvas</code> element's <i>origin-clean</i> flag is set
   to false, throw a <code>SecurityError</code> exception; otherwise, it
 <!--REMOVE-TOPIC:Security-->
-  must return an <code>ImageData</code> object representing the
+  must return an <code>ImageData</code> object with width <var
+  title="">sw</var> and height <var title="">sh</var> representing the
   underlying pixel data for the area of the canvas denoted by the
   rectangle whose corners are the four points (<var title="">sx</var>,
   <var title="">sy</var>), (<span title=""><var title="">sx</var>+<var
@@ -46778,39 +46783,34 @@
   outside the canvas must be returned as transparent black. Pixels
   must be returned as non-premultiplied alpha values.</p>
 
-  <p>If any of the arguments to <code
-  title="dom-context-2d-createImageData">createImageData()</code> or
-  <code title="dom-context-2d-getImageData">getImageData()</code>
-  are infinite or NaN, the method must instead throw a
-  <code>NotSupportedError</code> exception. If either the <var
-  title="">sw</var> or <var title="">sh</var> arguments are zero,
-  the method must instead throw an <code>IndexSizeError</code>
-  exception.</p>
+  <p>If either the <var title="">sw</var> or <var title="">sh</var>
+  arguments are zero, the method must instead throw an
+  <code>IndexSizeError</code> exception.</p>
 
   <p><code>ImageData</code> objects must be initialized so that their
   <dfn title="dom-imagedata-width"><code>width</code></dfn> attribute
-  is set to <var title="">w</var>, the number of physical device
-  pixels per row in the image data, their <dfn
+  is set to the number of pixels per row in the image data, their <dfn
   title="dom-imagedata-height"><code>height</code></dfn> attribute is
-  set to <var title="">h</var>, the number of rows in the image data,
-  and their <dfn title="dom-imagedata-data"><code>data</code></dfn>
-  attribute is initialized to a <code>Uint8ClampedArray</code> object.
-  The <code>Uint8ClampedArray</code> object must use a <span>Canvas
-  Pixel <code>ArrayBuffer</code></span> for its storage, and must have
-  a zero start offset and a length equal to the length of its storage,
+  set to the number of rows in the image data, and their <dfn
+  title="dom-imagedata-data"><code>data</code></dfn> attribute is
+  initialized to a <code>Uint8ClampedArray</code> object. The
+  <code>Uint8ClampedArray</code> object must use a <span>Canvas Pixel
+  <code>ArrayBuffer</code></span> for its storage, and must have a
+  zero start offset and a length equal to the length of its storage,
   in bytes. The <span>Canvas Pixel <code>ArrayBuffer</code></span>
   must contain the image data. At least one pixel's worth of image
-  data must be returned. <a href="#refsTYPEDARRAY">[TYPEDARRAY]</a></p>
+  data must be returned. <a
+  href="#refsTYPEDARRAY">[TYPEDARRAY]</a></p>
 
   <p>A <dfn>Canvas Pixel <code>ArrayBuffer</code></dfn> is an
   <code>ArrayBuffer</code> that whose data is represented in
   left-to-right order, row by row top to bottom, starting with the top
   left, with each pixel's red, green, blue, and alpha components being
-  given in that order for each pixel. 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. The components must
-  be assigned consecutive indices starting with 0 for the top left
-  pixel's red component. <a href="#refsTYPEDARRAY">[TYPEDARRAY]</a></p>
+  given in that order for each pixel. Each component of each pixel
+  represented in this array must be in the range 0..255, representing
+  the 8 bit value for that component. The components must be assigned
+  consecutive indices starting with 0 for the top left pixel's red
+  component. <a href="#refsTYPEDARRAY">[TYPEDARRAY]</a></p>
 
   <p>The <dfn
   title="dom-context-2d-putImageData"><code>putImageData(<var
@@ -46820,9 +46820,6 @@
   title="">dirtyHeight</var>)</code></dfn> method writes data from
   <code>ImageData</code> structures back to the canvas.</p>
 
-  <p>If any of the arguments to the method are infinite or NaN, the
-  method must throw a <code>NotSupportedError</code> exception.</p>
-
   <p>When the last four arguments are omitted, they must be assumed to
   have the values 0, 0, the <code
   title="dom-imagedata-width">width</code> member of the <var
@@ -46839,20 +46836,6 @@
 
    <li>
 
-    <p>Let <var title="">dx<sub>device</sub></var> be the x-coordinate
-    of the device pixel in the underlying pixel data of the canvas
-    corresponding to the <var title="">dx</var> coordinate in the
-    canvas coordinate space.</p>
-
-    <p>Let <var title="">dy<sub>device</sub></var> be the y-coordinate
-    of the device pixel in the underlying pixel data of the canvas
-    corresponding to the <var title="">dy</var> coordinate in the
-    canvas coordinate space.</p>
-
-   </li>
-
-   <li>
-
     <p>If <var title="">dirtyWidth</var> is negative, let <var
     title="">dirtyX</var> be <span title=""><var title="">dirtyX</var>+<var
     title="">dirtyWidth</var></span>, and let <var
@@ -46909,6 +46892,52 @@
 
    </li>
 
+   <li>
+
+    <p>Draw the region of the image data in the horizontal rectangle
+    whose top left corner is at (<var title="">dirtyX</var>,<var
+    title="">dirtyY</var>) and whose bottom right corner is at (<span
+    title=""><var title="">dirtyX</var>+<var
+    title="">dirtyWidth</var></span>,<span title=""><var
+    title="">dirtyY</var>+<var title="">dirtyHeight</var></span>) onto
+    the canvas, aligned such that the top left of the rectangle is at
+    coordinate (<var title="">dx</var>,<var title="">dy</var>).</p>
+
+    <p>If the <code
+    title="dom-context-2d-imageSmoothingEnabled">imageSmoothingEnabled</code>
+    attribute is set to true, then the user agent should attempt to
+    apply a smoothing algorithm to the image data if the canvas does
+    not have exactly one device pixel per coordinate space unit in its
+    underlying pixel data.</p>
+
+   </li>
+
+  </ol>
+
+<!-- XXXXX
+
+   <li>
+
+    <p>Let <var title="">scale</var> be the number of device pixels in
+    the underlying pixel data of the canvas per coordinate space
+    unit.</p>
+
+   </li>
+
+   <li>
+
+    <p>Let <var title="">dx<sub>device</sub></var> be the x-coordinate
+    of the device pixel in the underlying pixel data of the canvas
+    corresponding to the <var title="">dx</var> coordinate in the
+    canvas coordinate space.</p>
+
+    <p>Let <var title="">dy<sub>device</sub></var> be the y-coordinate
+    of the device pixel in the underlying pixel data of the canvas
+    corresponding to the <var title="">dy</var> coordinate in the
+    canvas coordinate space.</p>
+
+   </li>
+
    <li><p>Otherwise, for all integer values of <var title="">x</var>
    and <var title="">y</var> where <span title=""><var
    title="">dirtyX</var>&nbsp;&le;&nbsp;<var
@@ -46926,8 +46955,6 @@
    title="">y</var></span>) in the underlying pixel data of the
    canvas.</p></li>
 
-  </ol>
-
   <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
@@ -46970,6 +46997,7 @@
   returned to an equivalent <code
   title="dom-context-2d-getImageData">getImageData()</code> as
   different values.</p>
+-->
 
   <p>The current path, <span
   title="dom-context-2d-transformation">transformation matrix</span>,

|