W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2010

[whatwg] Canvas putImageData - Can we scale?

From: Oliver Hunt <oliver@apple.com>
Date: Fri, 4 Jun 2010 10:40:16 -0700
Message-ID: <8EDC98C1-2C8B-4FBB-A9CA-77E070D48D03@apple.com>
On Jun 4, 2010, at 10:05 AM, Rob Evans wrote:

> Hi,
>  
>                 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 useful!

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?

--Oliver
>  
> Thanks,
>  
> Rob Evans
> CTO
> mtn-i LTD

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100604/632cfa5a/attachment.htm>
Received on Friday, 4 June 2010 10:40:16 UTC

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