[whatwg] Canvas putImageData - Can we scale?

Rob Evans rob at mtn-i.com
Fri Jun 4 10:57:40 PDT 2010

1: My bad.

2: Fair enough.

3: Thanks, I had totally skipped the extra parameters available on the
drawImage function... oops. I think I'll blog it so anyone else who
skim-reads the MDC will find my mistake on google when they search!


From: Oliver Hunt [mailto:oliver at apple.com] 
Sent: 04 June 2010 18:40
To: Rob Evans
Cc: whatwg at lists.whatwg.org
Subject: Re: [whatwg] Canvas putImageData - Can we scale?


On Jun 4, 2010, at 10:05 AM, Rob Evans wrote:



                I wonder if this is the correct place to post this but I
cannot find any resources online as canvas is so new.

Canvas isn't new -- it's at least 4 or 5 years old, and has been in the
html5 spec for at least 2 or 3 of those years -- I believe the MDC has some
of the best API documentation (at least in terms of providing examples of
how the APIs are used.)


                After grabbing some image data from a canvas with the
getImageData call, I cannot find a way to put the image data onto a canvas
scaled down.


                If I use the canvas scale function and then put the image
data, no scaling occurs. Is there any way to scale with putImageData?


No. The ImageData API documentation is very clear on this, and has not
changed substantively in a few years now.  get/putImageData are not effected
by the current CTM.


                If not I think it would be a useful addition to the
specification. I can imagine many situations where copying a section of the
canvas and applying scaling before pasting it back to the canvas would be


You shouldn't be using ImageData to do this --
CanvasRenderingContext2D.drawImage supports canvas elements, and has well
defined semantics for drawing the contents of a canvas element into its own
context -- in addition to supporting non-identity CTMs this is also likely
quite a bit faster in the identity case than an imagedata based approach.
Is there some specific reason you want to use the ImageData API?






Rob Evans


mtn-i LTD


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100604/904492c7/attachment-0002.htm>

More information about the whatwg mailing list