Send PNG to Server [Extension]

Gintonic

  • Posts: 69
I want to share this little (openFL) extension with you.
With this extension  you can send an actor (the bitmapdata of an actor) as a png file to the server.
With the screenshot extension you can save the screenshot of a game on the server and send the link to facebook withe the facebook extention.
The block:
send PNG from [actor] to Url [http://myserver.com/savepng.php] with filename [myscreenshot.png]

You will need a serverside script (see example in readme.txt)

Tested on android, ios, flash (don't forget the crossdomain.xml).

Have fun :)

« Last Edit: February 03, 2015, 09:52:40 pm by Jon »

1MrPaul1

  • *
  • Posts: 1265
Do not try it yet, but it can be very useful extension, thank you for sharing!

1MrPaul1

  • *
  • Posts: 1265
Can you explain more about "serverside script" "crossdomain.xml"?
which server we need hot and where to apple the script and what is the crossdomain.xml

Gintonic

  • Posts: 69
crossdomain.xml you will need, if your flash game and the url your calling  ist not on the same server:
http://community.stencyl.com/index.php/topic,24742.msg142249.html#msg142249

When you want to send an image from your app, for example a screenshot, the extension takes the bitmapData from it, encodes it to png and base64 encodes it, so you can send it to your server. At serverside you will need a script, that recieves the data and decodes it again to png and, for example, saves it. If you have an apache server with php you can take a look at the script in the readme.txt.

dripple

  • Posts: 747
Great one. Thanks.
Sure, my games won't get better with all the new features of Stencyl.
But I do have more fun creating bad ones.


MayazCastle Keeper

Jon

  • *
  • Posts: 17516
Quote
With the screenshot extension you can save the screenshot of a game

I wasn't aware that this existed - where is it located?

Gintonic

  • Posts: 69
It's only in the zip in my first post.   Sorry, haven't seen, that your talking about the screenshot extension.

« Last Edit: February 28, 2014, 01:26:57 am by Gintonic »

Jon

  • *
  • Posts: 17516
From what I can tell, the included function can capture an actor as an image but not the entire contents of the screen.

Jon

  • *
  • Posts: 17516
This seems to do the trick - it was so much shorter than I expected. Checked it into the nightlies (not really usable by anybody but devs at this point, but that'll change in the future).

Paired with your extension, this is now a way to submit a screenshot to a server.

Code: [Select]
public function captureScreenshot():BitmapData
{
var img:BitmapData = new BitmapData(getScreenWidth(), getScreenHeight());
img.draw(nme.Lib.current.stage);
return img;
}

EDIT: This code is directed at the original poster. It is not meant to be dropped in to any game.

« Last Edit: June 18, 2014, 01:34:10 pm by Jon »

Gintonic

  • Posts: 69
Quote
With the screenshot extension you can save the screenshot of a game

I wasn't aware that this existed - where is it located?

http://community.stencyl.com/index.php/topic,26840.msg154767.html#msg154767

kinglir

  • Posts: 93
thanks for the extension:

1. when i use the extension on X1 screens  - the png on the server is  in low quality, it looks like the image capture on full size  X4 and than rescaled to X1 and lost data in the process. what im doing wrong?
2. i'm capturing the all stage, how can i get the core functions / behaviors of stencyl like "current screen as image" work in your extension?

thanks again


alesaux

  • Posts: 5
This seems to do the trick - it was so much shorter than I expected. Checked it into the nightlies (not really usable by anybody but devs at this point, but that'll change in the future).

Paired with your extension, this is now a way to submit a screenshot to a server.

Code: [Select]
public function captureScreenshot():BitmapData
{
var img:BitmapData = new BitmapData(getScreenWidth(), getScreenHeight());
img.draw(nme.Lib.current.stage);
return img;
}

Hi

Sorry - complete Newbie here.... where abouts does this code need to be put? I've tried putting it in the SendPngtoServer.hx file and I continue to get:

" Unknown identifier : getScreenWidth"

Is there something else I should be importing...? And do any code blocks in Stencyl need to change?

If I can find out where this code goes this will make the Facebook integration even better!!!

Thanks in advance... Stencyl is brilliant!!!

Jon

  • *
  • Posts: 17516
This contains some references to nme that will need to be updated to openfl for this extension to function in 3.3 and above. Please update. Thanks!