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

2013-01-27 Thread Florian Bösch
If we have a context we can use in a worker on which we can set the framebuffer to which we would bind the texture and which we can readPixel back into bytes, which we would stick into a surfaceless 2D canvas so we can kick off the encoding to png (or just implement it in JS after implementing

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

2013-01-26 Thread Gregg Tavares
Could this be solved in workers? x) Create canvas, set to desired size x) Create 2D context x) Create imageData object x) Create a WebGL framebuffer object x) Attach texture as color target to framebuffer x) read back pixels into canvas2d's imageData.data member x) ctx.putImageData into the

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

2013-01-16 Thread Kyle Huey
On Mon, Jan 14, 2013 at 7:04 AM, Florian Bösch pya...@gmail.com wrote: On Mon, Jan 14, 2013 at 4:00 PM, Glenn Maynard gl...@zewt.org wrote: You want toBlob, not toDataURL. So how would I stick a blob into an arraybuffer? I don't think there's any reason we can't have toArrayBuffer as well.

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

2013-01-16 Thread Glenn Maynard
On Wed, Jan 16, 2013 at 6:29 AM, Kyle Huey m...@kylehuey.com wrote: I don't think there's any reason we can't have toArrayBuffer as well. The hard part from an implementation perspective is asynchronously encoding the image, not what we stick it in. No technical reason, but I'd avoid adding

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

2013-01-16 Thread Florian Bösch
Perhaps we should think of a better scheme to export data than toFoo(). Maybe toData('url'), toData('arraybuffer') toData('blob') or perhaps toData(URL), toData(ArrayBuffer) or toData(Blob). I tend to think that if you're starting to write toA, toB, toC, toX methods on an object, you've not

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

2013-01-16 Thread Glenn Maynard
On Wed, Jan 16, 2013 at 9:40 AM, Florian Bösch pya...@gmail.com wrote: Perhaps we should think of a better scheme to export data than toFoo(). Maybe toData('url'), toData('arraybuffer') toData('blob') or perhaps toData(URL), toData(ArrayBuffer) or toData(Blob). I tend to think that if you're

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

2013-01-16 Thread Kyle Huey
On Wed, Jan 16, 2013 at 7:50 AM, Glenn Maynard gl...@zewt.org wrote: On Wed, Jan 16, 2013 at 9:40 AM, Florian Bösch pya...@gmail.com wrote: Perhaps we should think of a better scheme to export data than toFoo(). Maybe toData('url'), toData('arraybuffer') toData('blob') or perhaps

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

2013-01-16 Thread Florian Bösch
Whatever the eventual solution to this problem, it should be the user of the API driving the decision how to get the data. On Wed, Jan 16, 2013 at 4:56 PM, Kyle Huey m...@kylehuey.com wrote: On Wed, Jan 16, 2013 at 7:50 AM, Glenn Maynard gl...@zewt.org wrote: On Wed, Jan 16, 2013 at 9:40

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

2013-01-14 Thread Anne van Kesteren
On Mon, Jan 14, 2013 at 1:20 PM, Florian Bösch pya...@gmail.com wrote: Having a texture in WebGL and wanting to encode it into a typed array as PNG, I have found that the only way to do it is the following convoluted method. Could you list the use cases?

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

2013-01-14 Thread Florian Bösch
The usecase is that I write a productivity application using WebGL which has a need to bundle images residing in computed textures into one archive (tar, zip etc.). - The images belong together (such as normal, height, tangent, specular color, specular power, albedo etc.) - The archive has to

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

2013-01-14 Thread Glenn Maynard
On Mon, Jan 14, 2013 at 6:20 AM, Florian Bösch pya...@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

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

2013-01-14 Thread Florian Bösch
On Mon, Jan 14, 2013 at 4:00 PM, Glenn Maynard gl...@zewt.org wrote: You want toBlob, not toDataURL. So how would I stick a blob into an arraybuffer?

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

2013-01-14 Thread Glenn Maynard
On Mon, Jan 14, 2013 at 9:04 AM, Florian Bösch pya...@gmail.com wrote: On Mon, Jan 14, 2013 at 4:00 PM, Glenn Maynard gl...@zewt.org wrote: You want toBlob, not toDataURL. So how would I stick a blob into an arraybuffer? http://dev.w3.org/2006/webapi/FileAPI/#dfn-filereader -- Glenn