W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2009

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

From: Charles Pritchard <chuck@jumis.com>
Date: Thu, 30 Apr 2009 15:49:04 -0700 (PDT)
Message-ID: <54024.67.171.33.219.1241131744.squirrel@mx.visc.us>
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

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