Screenshot game canvas and upload/save image

Screenshot game canvas and upload/save image
0.0 0


hello developing a game that requires screenshots of the canvas , anyone have any idea how to do this on cocos2d-HTML5 , afterwards it would be required to be uploaded on facebook

[iOS] Share screenshot: cc.Sprite to UIImage conversion

It’s easier than I thought:

var canvasElement = cc.$("canvas");
var image = new Image();
image.src = canvasElement.toDataURL("image/png");

Note that the conversion proccess (the toDataURL) takes a little while, so you should implement some sort of waiting dialog and a callback for when it’s finished. You can test that this works easily by “opening” the generated image in the browser like this: window.location.replace(canvasElement.toDataURL("image/png"));.

Does anyone know if there’s a better way for getting the canvas element?



I tried with above code. This works fine for me in chrome browser and safari browser.
But when i check in IPAD device safari browser am getting white image.

Is the above code works fine for you in Ipad devices?

Thanks in advance.