[whatwg] More random comments on the putImageData definition

Philip Taylor excors+whatwg at gmail.com
Wed Jan 23 05:44:26 PST 2008


On 23/01/2008, Oliver Hunt <oliver at apple.com> wrote:
> It would be great if putImageData
> could take a source region, in addition to the destination.  One of
> the primary reasons for using get/putImageData is to allow JS to
> rapidly blit data to the screen, however without an ability to blit
> only a subregion of the image data the only available options are to
> either re-blit the entire imagedata region (which can be expensive due
> to the need for [un]premultiplying in some (all?) implementations),

((Opera does non-premultiplied colour internally.))

> or create and populate a new ImageData object which still requires more
> work than would ideally be necessary.

You can also create a temporary canvas and putImageData once onto
that, and then drawImage sections onto the screen as they are needed.
That lets you draw lots of sections lots of times quickly (since
you're mostly drawing from the optimised canvas surface format, not
from a JS array), which perhaps helps in some (most?) of the cases.
(You still have to do a single putImageData of the whole data to get
it onto the temporary canvas, but if there are parts of the data you
aren't ever using then you just should make the ImageData smaller and
cut out the unused bits.)

-- 
Philip Taylor
excors at gmail.com



More information about the whatwg mailing list