-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I like Drawing Images, too. #2
Comments
Also having the same problem not being able to draw images. Any ideas on this ? |
Partial answer -> get the base64 string of image and this add the image to the XMLSerializer. |
I found a way to make this work . Convert the src atributes of all images to base64 strings. var imgArray = $('img');
for (var i = 0; i < imgArray.length; i++) {
var dataUrl = getBase64Image(imgArray[i]);
$(imgArray[i]).attr('src',dataUrl);
};
function getBase64Image(img) {
// Create an empty canvas element
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
// Copy the image contents to the canvas
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
return canvas.toDataURL("image/png");
} |
Hello, I love this script and I think it would be great to draw images. I am searching how to achieve this with a loader like this one: http://www.html5canvastutorials.com/tutorials/html5-canvas-image-loader/ I made more test and the tools already works with css background images, so in my case it can do the trick. |
Hello guys, I had the same problem, the solution is to get your image url as a |
var dom = $('<img src="source/asset/img/tile.png"/>').appendTo('body')
var dom2 = $('<div id="foo" style="background: url(source/asset/img/tile.png)">Howdy!</div>').appendTo('body')
domvas.toImage(dom[0], function() {
ctx.drawImage(this, 0,0);
});
Adding an img tag does not seem to render.
Trying a div with a background tag seems to prevent even the div from rendering, let alone rendering just some of the DIV's contents.
(Just making your life harder :D)
The text was updated successfully, but these errors were encountered: