Canvas.toDataUrl("image/png") no funciona correctamente

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!

preguntado el 28 de agosto de 12 a las 13:08

What is not working? What is the code expected to do? -

Got the answer from nneonneo! Thanks for your concern! -

1 Respuestas

No se puede utilizar toDataUrl after loading an image from another domain into the canvas, as it would open up a security hole (information disclosure from other domains).

Ver ¿Por qué esta línea toDataURL es un error de seguridad?.

contestado el 23 de mayo de 17 a las 12:05

No problem. Please accept the answer if it was useful to you. - neonneo

@MJQ You also can't draw the image to canvas before it has loaded/been cached. - Paul s.

Well, no, the image draw actually does work. It's the toDataUrl that doesn't, exactly as @MJQ said. - neonneo

No, in that case you are using toDataUrl before the image is drawn. So toDataUrl works but produces a blank canvas image. - neonneo

No! I first draw image then do toDataUrl and then again draw image from src of toDataUrl!!!!! - MJQ

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.