W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2013

Re: Reading image bytes to a PNG in a typed array

From: Glenn Maynard <glenn@zewt.org>
Date: Mon, 14 Jan 2013 09:00:14 -0600
Message-ID: <CABirCh8yLNPvwE+U_M5XmvEqSz_HCG19=p_L6fyC4Jf9tR5B-g@mail.gmail.com>
To: Florian Bösch <pyalot@gmail.com>
Cc: Webapps WG <public-webapps@w3.org>
On Mon, Jan 14, 2013 at 6:20 AM, Florian Bösch <pyalot@gmail.com> wrote:
>
> 1) Create canvas, set to desired size
> 2) Create 2D context
> 3) Create imageData object
> 4) Create a WebGL framebuffer object
> 5) Attach texture as color target to framebuffer
> 6) read back pixels into canvas2d's imageData.data member
> 7) ctx.putImageData into the canvas
>

You want to be rendering to a WebGL canvas, not a 2D canvas.  There's the
limitation of not being able to draw to anything except the displayed
canvas, but I think that's being worked on within WebGL.

8) call canvases toDataURL('image/png')
> 9) snip off the mime/encoding header
> 10) implement base64 decode in JS and decode to Uint8Array
>

You want toBlob, not toDataURL.

-- 
Glenn Maynard
Received on Monday, 14 January 2013 15:00:45 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:57 GMT