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

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

From: Kenneth Russell <kbr@google.com>
Date: Mon, 11 Mar 2013 16:28:36 -0700
Message-ID: <CAMYvS2eURVrte9rH-=cD1ydgFqWAtBpNk8KgryTQUbuJsF07QA@mail.gmail.com>
To: WHAT Working Group <whatwg@whatwg.org>
It would be useful to be able to create an ImageData [1] object with
preexisting data. The main use case is to display arbitrary data in
the 2D canvas context with no data copies.

Proposed IDL:

[NoInterfaceObject]
interface ImageDataFactories {
  ImageData createImageData(Uint8ClampedArray data, double sw, double sh);
};
Window implements ImageDataFactories;
WorkerGlobalScope implements ImageDataFactories;

createImageData would throw an exception if the length of the
Uint8ClampedArray was not equal to 4 * floor(sw) * floor(sh), or at
least, if the length of the array was less than this value. (Similar
wording would be used to that of CanvasRenderingContext2D's
createImageData.)

I don't think it is necessary to provide a createImageDataHD in this
interface. The caller will know the devicePixelRatio and determine
whether to generate high-DPI data.

[1] http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#imagedata

Comments?

Thanks,

-Ken
Received on Monday, 11 March 2013 23:29:03 GMT

This archive was generated by hypermail 2.3.1 : Monday, 11 March 2013 23:29:04 GMT