[whatwg] on ImageData, putImageData() and drawImage()

On Tue, 1 Jul 2008, Mathieu HENRI wrote:

> > As of today the variants of the putImageData() method copy a region of
> > an ImageData (in device pixels) straight to a Canvas (in intrinsic
> > pixels) and do not allow to scale the region further than the obvious
> > device to intrinsic "scaling".
> >
> > This means that if a developer needs to copy and scale a region of an
> > ImageData, he needs to do so in 2 passes, and use a temporary Canvas.

Ian replies (Apr 30th 2008)
> If you want to scale a part of a canvas, why can't you just use
> drawImage() with that part of the canvas directly?

If all you are looking to do is an affine transformation, then of course
you would only use drawImage.

If you are looking to do an affine transformation, after you've modified
the contents of an ImageData object (say, by running an edge filter), then
you are forced to use a temporary canvas.

The primary reason for running the affine transformation After running
the ImageData filter is for speed -- you can use a down-sampled image,
run it through a filter, then re-size it (losing quality, of course)
and/or rotate it.

There are other uses I'm sure.. but that's one that comes to mind.

drawImage(ImageData) would save us the extra step of using
putImageData(tmp) followed by
drawImage(tmp).


-Charles

Received on Thursday, 30 April 2009 15:49:04 UTC