How do I screen shot to email vs new draw canvas - advantages / disadvantages?

0 favourites
From the Asset Store
Kids Game
$49 USD
New Sounds Added Update: 115 new sound effects added for no additional cost!
  • I have been having problems with sending the canvas screenshot to PHP an then emailing myself. Discovered that its working fine but its delivering a BlOb - Binary Object which I can decode manually but I also saw that their is a new draw canvas function. Has anyone figured out how to have this new function just POST to an email? or should I write a PHP script to decode the binary and from which? canvas shot Vs the new Draw Canvas would be better future thinking?

    Thanks

  • I assume your question is about Construct 3? This is Construct 2 forum.

  • I assume your question is about Construct 3? This is Construct 2 forum.

    Yes the reference is to my tutorial https://www.construct.net/en/tutorials/screenshot-capture-to-email-1320

    This does not work in C3 because the data is blob instead of base64.

    Is there anyway to convert the Canvas Snapshot back to base64 in c3?

  • Moved to C3 forums.

    You should avoid converting to base64 if you can - it's slower and uses more bandwidth than the binary (blob) equivalent. Any good server should be able to handle binary data directly.

    So the approach I'd recommend is:

    1. Take a canvas snapshot (either runtime or Drawing Canvas)
    2. Use AJAX to load the snapshot URL in to Binary Data
    3. Post the Binary Data to the server

    If you really can't figure out how to load binary on the server and are willing to use a less efficient approach, the Binary Data object can also convert to base64.

  • Thanks Ashely and fellow Constructors!

    If anyone knows how long do Blob's exist? Seems like their is a window to write them into a file. Sorry new to this sort of transfer via PHP

    blob:https://preview.construct.net/3913b9dc-d856-4a3f-a67e-7fc7e80e83ff

    Can see the links now but cant get the image to decode in the PHP email.

    See screen shot bellow .... Ha

    Think some wrapper may need to be activated for the PHP settings on our server and then maybe I'll be able to save the binary to a php but so far no luck.

  • Moved to C3 forums.

    You should avoid converting to base64 if you can - it's slower and uses more bandwidth than the binary (blob) equivalent. Any good server should be able to handle binary data directly.

    So the approach I'd recommend is:

    1. Take a canvas snapshot (either runtime or Drawing Canvas)
    2. Use AJAX to load the snapshot URL in to Binary Data
    3. Post the Binary Data to the server

    If you really can't figure out how to load binary on the server and are willing to use a less efficient approach, the Binary Data object can also convert to base64.

    I don't have a problem with steps 1 & 3 , but

    1. having a problem figuring out how to use AJAX to load the snapshot in to Binary data, if anyone could lead me in the right direction ?
    2. Also as is stated in the Manual, The URL is a blob: URL referring to data in memory. It can only be used in the same session, in the same browser, on the same device. Sharing the URL or saving it to be re-used in another session later will not work.
    3. What is the procedure to convert the URL back to Base64, as I can find the expression GetBase64, but do not know how to implement it ?

    I would pefer to send the Binary data to my server, but the way to convert the URL into Binary data does not seem to be straight forward or apparent.

    Cheers

  • Thanks Ashely and fellow Constructors!

    If anyone knows how long do Blob's exist? Seems like their is a window to write them into a file. Sorry new to this sort of transfer via PHP

    Think some wrapper may need to be activated for the PHP settings on our server and then maybe I'll be able to save the binary to a php but so far no luck.

    From what I have read in the Manual:

    The URL is a blob: URL referring to data in memory. It can only be used in the same session, in the same browser, on the same device. Sharing the URL or saving it to be re-used in another session later will not work.

    So It looks like we need the Binary data from the URL first, then it can be posted via AJAX to the PHP Script on the server.

    I Haven't figured out how to get the Binary data from the URL yet in C3, But as Ashley says it is possible, it would be nice if anyone could post an example of this.

    cheers

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • blob: URLs only last for the duration the browser window is open. That is irrelevant to this process though, because you immediately load it in to a Binary Data object and send it to the server.

  • blob: URLs only last for the duration the browser window is open. That is irrelevant to this process though, because you immediately load it in to a Binary Data object and send it to the server.

    Ok, but I can't work out how to actually load it into the Binary Data Object with AJAX, I would like have an event example, because I can't work out how to do that.

    cheers

  • Just use the 'Set response binary' action before the request.

  • TY Ashely for pointing the way!

    I'm still a little stuck on this do you mean like this:

    drive.google.com/file/d/1hrHOZQDLDliB6LT5uPHupm-KfJXFQSZU/view

  • You're confusing the two steps:

    1) load the canvas snapshot in to Binary Data

    2) post the data to the server

    These are two separate AJAX requests. The first should request the CanvasSnapshot URL. The second should post the Binary Data.

  • Yeah Just getting the browser link to blob still. Think Construct is doing everything correct but PHP or my server wants to encode everything as the local URL making it useless for emailing - as its in the local browser session. Googled a lot of writing the binary URL to a PHP file but nothing works. Creates blank PNG files. Tried reading the blob URL inline in the email img scr= and can't get that to work either. Haven't worked in PHP for years so I'm probably doing something dumb.

    Is their a way to just write the binary out in a PHP var based on the construct Blob URL and paste that into the email from PHP? Maybe its better to just give up on PHP and do with Javascript?

    drive.google.com/file/d/1sMOEn_01pg9YVZZiJ--o9rGXTCMizo2Z/view

  • Call me stupid, but I haven't got it to work yet.

    To be honest It was a simple process in C2, but without any working event examples, it's hard to work out how to implement it, obviously whoever wrote the Binary plugin knows how to do it, and it wouldn't take much to show a simple example to us.

    There is also a way to convert the snapshot binary back to base64, but yet again, until an example is shown, I have no idea how to do it.

    Anyway I suppose someone will work it out oneday.

  • use official binary plugin.

    but if you still want base64 you can try my plugin.

    github.com/erenertugrul/construct-plugins/raw/master/plugins/image_to_base64/c3/dist/image_base64_v1.2.c3addon

    example c3p file

    oyunkulturu.com/temp/canvas_base64.c3p

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