Re: [whatwg] ImageData constructor questions

On Sat, Mar 22, 2014 at 11:31 PM, Dirk Schulze <dschulze@adobe.com> wrote:

> Hi,
>
> I was reading the spec part about ImageData [1].
>
> 1)
> I noticed that createImageData() is explicit that it represent a
> transparent black rectangle. The constructor for ImageData is not that
> explicit.
>

Yes, that seems like an oversight.


> 2)
> The last step of the 2nd constructor that takes an Uint8ClampedArray says:
> "       * Return a new ImageData object whose width is sw, whose height is
> height, and whose data is source."
>
> Is data a reference to the original source or a copy of source?


It is the original source. The spec does not say anything about creating a
new array and copying the bits over.


> For the former, there might be two ImageData objects referencing the same
> ByteArray. How would that be useful?
>

You *could* use the API that way but I don't see why there has to be a way
to prevent that from happening. Is there an implementation issue if 2
different imageData object point to the same dataarray/



> [1]
> http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dfnReturnLink-7(4.12.4.2.16 Pixel manipulation)


Correct link is:
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#pixel-manipulation

Received on Sunday, 23 March 2014 19:34:20 UTC