W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2008

[whatwg] More random comments on the putImageData definition

From: Philip Taylor <excors+whatwg@gmail.com>
Date: Wed, 23 Jan 2008 13:44:26 +0000
Message-ID: <ea09c0d10801230544y51433583qce5364451b782c44@mail.gmail.com>
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
Received on Wednesday, 23 January 2008 05:44:26 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:00 UTC