mcbjam
mcbjam

Reputation: 7474

Canvas to Image in javascript?

I'm trying to transform a canvas on html image.

The canvas is display without any problem, in $('#image1') there are some data, but it's not display ? What i have forget ?

Here is a jsfidle with the code : http://jsfiddle.net/mcbjam/tZGcq/

Here is the call i need to perform.

$('#image1').attr('src', image.src);  

Upvotes: 0

Views: 163

Answers (1)

icktoofay
icktoofay

Reputation: 129139

You're drawing an image from another domain. When you do this, the canvas becomes tainted, and you can't get at the data any more because that might reveal data from that other domain that you normally wouldn't be able to access.

You can fix this by copying the image file to your own domain and then using a relative URL to access it.


Additionally, you'll probably want to call convertCanvasToImage from inside the img.onload callback, but that's not your primary problem.

Upvotes: 1

Related Questions