Saving CanvasSnapshot in Node-Webkit

Get help using Construct 2

Post » Wed Nov 20, 2013 10:38 pm

Greetings.

After combing through the forums, I've exhausted all the suggestions on how to save a CanvasSnapshot to disk in node-webkit. When in a browser, the image will download just as any normal file without a hitch--same if it's opened in a new window.

In node-webkit, whether windowed or full-screen, the download does not initiate. Also, showing the CanvasSnapshot in a new window doesn't enable any right-click 'Save As...' functionality. Saving the file to disk doesn't work, either, as node-webkit writes text to files.

In the game, there is a simple camera button that takes a canvas snapshot and should allow the player to save that file somehow. No issues in a browser but node-webkit is defying every attempt to save it.

If anyone knows of a way, or can find something to try, I'd greatly appreciate the help!
B
16
S
6
G
2
Posts: 152
Reputation: 3,764

Post » Thu Nov 21, 2013 12:18 am

Also tried using Ajax, just for fun, with no luck. It's very odd that a new window displaying the image appears in NodeWebkit, but right-clicking does nothing.

@Ashley - sorry to bug ya, man, but this one is driving me loco. Either I missed something very simple or it's not possible. When you have a second, any advice would be appreciated.
B
16
S
6
G
2
Posts: 152
Reputation: 3,764

Post » Fri Nov 22, 2013 2:38 am

Really? Whoa. There's seriously no possible way to save CanvasSnapshot to disk as an image using NodeWebkit? Any suggestions or ideas at all?

I tried using Ajax to request the image URI and then download the Ajax.lastdata, but that ain't working either.

@Ashley - If it's impossible, could ya tell me so and crush my dreams, please. :) Maybe shed some light on why right-click context doesn't work in NodeWebkit when an image is opened in a new tab.

Thanks!
B
16
S
6
G
2
Posts: 152
Reputation: 3,764

Post » Tue May 13, 2014 5:14 pm

I'm looking for a solution to this now too...I cant believe you never got an answer since 2013.
B
49
S
9
G
4
Posts: 426
Reputation: 7,071

Post » Tue May 13, 2014 5:41 pm

From R0J0hound's method:


->System: Start of layout:
NodeWebkit: show save dialog (accept ".png")

->NodeWebkit: On save dialog OK
Browser: Execute javascript "var fs = require('fs');fs['writeFileSync']('" &replace(NodeWebkit.ChosenPath,"\","\\")& "','" &Canvas.imageUrl& "'.split(',')[1], {'encoding': 'base64'});"


I decided to modify it without requiring a plugin
Image

A snippet:

Code: Select all
"var fs = require('fs');fs['writeFileSync']('" &replace(NodeWebkit.ChosenPath,"\","\\")& "','" &CanvasSnapshot& "'.split(',')[1], {'encoding': 'base64'});"
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests