Hacker News new | ask | show | jobs
by icode 5556 days ago
Well done! Im looking for a png parser in javascript. I would like to load pngs with xmlhttprequest and them draw them on a canvas. Ever heard of one?
3 comments

Why not just do something like the below when you need to do that?

  var img = new Image();
  img.onload = function(){
       //draw to canvas
  };
  img.src = "image.png";
Could be a stupid answer, or possibly it'd be better to do it your way?( Maybe I can learn something :) )
All major browsers will now do this for you, with data: urls. Take a look at the examples here: http://en.wikipedia.org/wiki/Data_URI_scheme