Re: [whatwg] toDataURL() for image/video?

On Tue, May 29, 2012 at 1:41 PM, Ashley Gullen <ashley@scirra.com> wrote:

> Has toDataURL() (from canvas) been considered for ordinary image and video
> elements?  Seems like it would be useful for pure javascript applications.
>  Currently it can be done by creating a new canvas, getting a 2D context,
> drawImage(), then canvas.toDataURL().  However adding it to images directly
> would be a useful convenience method, avoid the performance overhead of a
> new canvas, and probably be straightforward to define/implement.
>

It doesn't need any overhead, actually.  You can create a single canvas for
all of your readback operations.  As long as you keep the canvas out of the
document, it doesn't even need to actually blit the image; a smart
implementation can delay that, so when you read the data back it can get
the pixel data directly from the original image.  This is more important
with toBlob, where implementations might be able to skip the compression
step and just return the original compressed data.


> Use cases for myimage.toDataURL():
>

(These are use cases for reading back images--they're not really use cases
for adding another way to do it.)

-- 
Glenn Maynard

Received on Tuesday, 29 May 2012 18:55:46 UTC