Joe
Joe

Reputation: 1535

canvas toDataURL with background image

I have a canvas element that I want to allow the user to download as an image. I have managed to get SVG to download however I was wondering if there was any way to include the canvas css background image to download with it?

EDIT:

I have realised that what I am actually looking for is a workaround for the following from http://www.html5canvastutorials.com/advanced/html5-canvas-save-drawing-as-an-image/;

The toDataURL() method requires that any images drawn onto the canvas are hosted on a web server with the same domain as the code executing it. If this condition is not met, a SECURITY_ERR exception is thrown.

Upvotes: 0

Views: 1215

Answers (1)

devnull69
devnull69

Reputation: 16544

You should get the full URL of the canvas background image and draw it on a new canvas, then use the first canvas as a parameter of drawImage to draw its content onto the second canvas

Upvotes: 1

Related Questions