Saving CanvasSnapshot in Node-Webkit

0 favourites
  • 5 posts
From the Asset Store
Match the similar cards with each other and free all animals!
  • 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!

  • 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.

  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm looking for a solution to this now too...I cant believe you never got an answer since 2013.

  • 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

    A snippet:

    "var fs = require('fs');fs['writeFileSync']('" &replace(NodeWebkit.ChosenPath,"\","\\")& "','" &CanvasSnapshot& "'.split(',')[1], {'encoding': 'base64'});"[/code:323zshco]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)