W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2013

Re: [whatwg] Proposal: ImageData constructor or factory method with preexisting data

From: Kenneth Russell <kbr@google.com>
Date: Tue, 12 Mar 2013 10:55:07 -0700
Message-ID: <CAMYvS2eD9C6hodY3_nYJtTDeR+PB7m0huV1TqRm21KcscDT38g@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: WHAT Working Group <whatwg@lists.whatwg.org>
I much prefer your suggestion to just add a constructor to ImageData.
I was not sure whether that style was preferred nowadays. ImageData is
already exposed in the global namespace, so making it a callable
constructor function seems like an easy change.

As mentioned in another reply, the intent here is to reference the
Uint8ClampedArray, not make a copy.

-Ken


On Mon, Mar 11, 2013 at 7:03 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 3/11/13 7:28 PM, Kenneth Russell wrote:
>>
>> Proposed IDL:
>>
>> [NoInterfaceObject]
>> interface ImageDataFactories {
>>    ImageData createImageData(Uint8ClampedArray data, double sw, double
>> sh);
>> };
>> Window implements ImageDataFactories;
>> WorkerGlobalScope implements ImageDataFactories;
>
>
> How about just:
>
>   [Constructor(Uint8ClampedArray data, double sw, double sh)]
>   interface ImageData {
>     /* Whatever is currently there */
>   };
>
> and then you create one with:
>
>   new ImageData(someData, someWidth, someHeight);
>
> Other than needing to specify whether the array is copied or held on to by
> reference, and specifying that this interface should be exposed in workers,
> this seems fine to me.
>
> -Boris
Received on Tuesday, 12 March 2013 17:55:32 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 12 March 2013 17:55:32 GMT