Sophie Alpert
Sophie Alpert

Reputation: 143114

Draw image from pixel data arrays

If I have an array of pixel data in JavaScript, is there a good way to display it on an HTML page?

I doubt any exist, but does anyone know of image libraries for JavaScript that can generate image in a standard format? Is there a way to replicate the functionality of a data: URI in IE 7?

Upvotes: 4

Views: 4376

Answers (4)

user524160
user524160

Reputation: 31

Canvas is a good solution, for-cross browser support see Mark Pilgrim's excellent tutorial. Specifically, the "What about IE?" section and using ExplorerCanvas. You can use and create data: URIs in the PNG and JPEG formats with canvas.

Upvotes: 3

Drew LeSueur
Drew LeSueur

Reputation: 20145

Maybe check out fxCanvas http://burzak.com/pro/fxcanvas/

I think they implement even ‘putImageData‘ in IE using Flash.

Upvotes: -1

Trochoid
Trochoid

Reputation: 576

Does PNG format work for your targets? If so PNGlib looks pretty good.

Also, JS JPEG Encoder looks good but it takes as input the returned value of Canvas.getImageData().

Don't know what you can do to support IE 7 though.

Upvotes: 2

Jamie Wong
Jamie Wong

Reputation: 18350

Check you Raphaël - http://raphaeljs.com/

While this may be slow, and it is not the intended use of the library, it will work with support for browsers you're interested in.

Upvotes: 0

Related Questions