I am drawing an image onto canvas. after that I do canvas.toDataUrl("image/png"); But it doesn't go fine. Here is the link to jsfiddle!
Asked
Active
Viewed 1,564 times
0
-
What is not working? What is the code expected to do? – jbalsas Aug 28 '12 at 12:57
-
Got the answer from nneonneo! Thanks for your concern! – MJQ Aug 28 '12 at 13:02
1 Answers
1
You cannot use toDataUrl
after loading an image from another domain into the canvas, as it would open up a security hole (information disclosure from other domains).
-
@MJQ You also can't draw the image to canvas before it has loaded/been cached. – Paul S. Aug 28 '12 at 13:03
-
Well, no, the image draw actually does work. It's the `toDataUrl` that doesn't, exactly as @MJQ said. – nneonneo Aug 28 '12 at 13:05
-
No, in that case you are using `toDataUrl` before the image is drawn. So `toDataUrl` works but produces a blank canvas image. – nneonneo Aug 28 '12 at 13:16
-
No! I first draw image then do toDataUrl and then again draw image from src of toDataUrl!!!!! – MJQ Aug 28 '12 at 13:20
-
Now that I have added image to the document, but it is still not getting it in toDataUrl!!!!!! – MJQ Aug 28 '12 at 13:26
-
As I pointed out in my answer, you **cannot** use `toDataUrl` after loading a foreign image into a canvas. You just can't. If you have more questions, open a new question. – nneonneo Aug 28 '12 at 14:00