How do I take and store screenshots?

Get help using Construct 2

Post » Fri Mar 21, 2014 1:23 am

I used this capx to have an idea c:\Program Files\Construct 2\examples\Taking screenshots.capx

But where does it download the snapshow? i didnt find it anywhere, im using note webkit as a preview , does it matter?


PS: another question: if i would like the snapshot to picture the whole layout instead of the screen, how could i do?
B
65
S
22
G
4
Posts: 358
Reputation: 6,555

Post » Fri Mar 21, 2014 1:57 am

Message: Danwood can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Basically this is my same questions viewtopic.php?f=147&t=91622&p=717752&hilit=snapshot#p717752

It recived no answer, i'm going loco as well now :P
B
65
S
22
G
4
Posts: 358
Reputation: 6,555

Post » Fri Mar 21, 2014 4:11 am

OK I just spent like 3 days figuring this out.. so.. here goes!

You take a screenshot with CanvasSnapshot. You already know that. My chrome bugs out if I try to use the snapshot on the same frame it was generated so I put a 0.1 second wait after it.

You can take that screenshot and download it locally like in the example app. If you want to send it elsewhere, the CanvasSnapshot system expression contains a Base64 encoded PNG image prepended with the MIME type and set off the from the actual data with a comma. If you strip off the crap in the front and URLEncode the data you can send that via an Ajax POST action. You can do both of these in a single action; I set my post variable to ""imagedata=" & URLEncode(replace(CanvasSnapshot, "data:image/png;base64,", ""))" and just post that since I use GET parameters for everything else.

On the server side, remember that PHP automatically URL decodes so you just need to do base64_decode on your POST data. Don't do a manual urldecode or you'll corrupt your data. Once you do all that you'll have your PNG screenshot data in PHP and you can do whatever you want with it.

As for screenshotting certain things, all you can do in Construct is take a snapshot of the entire canvas. You can edit it in GD on the server side if you want to though to crop out what you don't want.
B
9
S
3
Posts: 37
Reputation: 749

Post » Thu Jul 10, 2014 10:55 pm

@nusbaumc I'm doing something similar however I need to email that image I'm capturing ... I'm stuck only because my php script doesn't seem to be receiving the POST... or i may be over-processing it into nothingness...because I'm receiving a 0kb attachment.
Freefall Bird
B
47
S
9
G
5
Posts: 280
Reputation: 5,796

Post » Fri Oct 10, 2014 7:28 am

Thanks for your work @nusbaumc! Is there a possibility you could explain how to just get the raw base64 string?
B
10
S
1
Posts: 12
Reputation: 427


Return to How do I....?

Who is online

Users browsing this forum: Huemerson, jorgmaquoi, Yahoo [Bot] and 8 guests