Save screenshot in cocos creator 2.0

@slackmoehrle @jare

I have got the reference of taking screenshot from below link.
camera Screenshot

I want to save a screenshot in local storage. I am not getting any reference for it. Please help. Thanks in advance.

@slackmoehrle
anything we can do for it? Please suggest

I’m actually not sure. I thought that by design JavaScript could not access the local file system. But I could be wrong and that doesn’t mean that Creator can’t. I’m just not sure about it.

@jare can the local file system be accessed?

Refer to the render_to_sprite test case in example-cases, you will see

if (CC_JSB) {
     let data = this.renderTexture.readPixels();
     let width = this.renderTexture.width;
     let height = this.renderTexture.height;
     let filePath = jsb.fileUtils.getWritablePath() + 'render_to_sprite_image.png';
     let success = jsb.saveImageData(data, width, height, filePath);
     if (success) {
         cc.log("save image data success, file: " + filePath);
     }
     else {
         cc.error("save image data failed!");
     }
 }
 else {
     cc.log("saveImage, only supported on native platform.");
 }
3 Likes

Very cool. I had no idea. Thanks for replying!

Thanks for the reply @jare @drelaptop @slackmoehrle