How do I load png

  • I just don't get how to load a png. I have spent over an hour and got no where.

    What I am really trying to do is click a button that loads a png into a spite (is there a better way?), then type into a text box that sits on the imported picture and then save the picture including the text as a png.

    Is this possible?

  • I think R0J0 answered pretty clearly in the Paster thread, it definitely is possible even without plugins.

    Which part exactly are you having trouble with? Do you have a .capx you can upload so we can see what you've gotten so far and help troubleshoot?

  • https://app.box.com/s/2dfh9ub4waycnbrna5pq4z1b8g7yw6zf

    The image does not load when I click the button. Can you also show me how to save the image with the text showing in the picture, maybe by clicking a different button?

    Thanks

  • The problem is in your load target.

    You did nwjs.AppFolder&"data/mydog.png" , Windows uses \ for directories, so it should be nwjs.AppFolder&"data\mydog.png".

    To debug, I recommend adding

    On Layout Start - Set Textbox Text to nwjs.AppFolder&"data\mydog.png"[/code:257wngew] to make sure you have the exact file path correct.
    
    The saving image is as R0J0 described (with small modification)
    
    On click
    --- set viewport size to sprite.width, sprite.height
    --- scroll to sprite
    --- snapshot canvas as jpeg
    
    On snapshot
    --- wait 0
    --- browser: invoke download snapshoturl
    
    Make sure your textbox overlaps the sprite or it will get cut off.
  • Just changing the slash

    nwjs.AppFolder&"data\mydog.png

    Still will not load the picture when I hit the button. I even moved to picture form data to the program folder. Did the program run for you? What am I missing?

    I do have the latest NWjs 2/16

    Maybe can you do a cap that works and I can see if it runs on my machine? maybe i am missing something small.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Did you test by exporting or previewing? Make sure the file name/path matches exactly, if you used the debug method I recommended.

    This won't work from preview from browser (chrome or other), you have to set the preview to nw.js in project setting.

    If you do that you'll see that for preview the file needs to be where you have nwjs installed. Can you confirm your file is there and not the construct folder? (When you export, you'll need to copy it to the export directory)

    I'll put together a package capx/exported project for you, but I ran into another issue where textboxes are not captured by the snapshot feature so I'll post it once I put together a workaround for that.

  • https://www.dropbox.com/s/z7fc5hey0yzu5 ... c.zip?dl=0

    .capx located in the same folder as nw.exe. Use nw.exe to run exported project.

    Again, if you preview from capx using nw.js, you need to copy your file to the nw.js folder.

    The issue I found was textbox is not captured by snapshot, so I used a spritefont instead.

    There is no confirmation that the download happens in nw.js - check your default chrome save directory.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)