Screenshot without application_surface

S

sparwen

Guest
I want to make a screenshot of the players record for a facebook sharing. And i want to add the game Icon / QR on that screenshot, so what im doing is drawing the icon and QR and then im using screen_save_part to make the screenshot.

But this makes it a little bit weird when you actually can se the Icon / QR (for 1 step) in the gameplay.

Is there anyway i can use surface to maybe copy the screen to outside the room and draw the Icon / QR there
and make the screenshot there instead, so the player wont see the added Icon / QR?

This is my code:

if var_print = 1
{
draw_sprite(spr_icon,0,0,0);
draw_sprite(spr_qr,0,display_get_gui_width(),0);
screen_save_part("share.png", 0, 0,display_get_width(),display_get_height()/2.5);
var_print = 0;
}
 

FrostyCat

Redemption Seeker
If you absolutely can't use application_surface, save the screen as a PNG, load it back as a background, create a surface of the same size, draw the background and then the QR code onto that surface, then save the surface to the final PNG.

It's convoluted, but you set the rules up that way.
 
S

sparwen

Guest
Okey It works, but it´s sooo slow, it takes like 3 seconds before its done...


screen_save("share.png");
spr_screen = sprite_add("share.png",1,0,0,0,0)
surf_temp = surface_create(800,1280);

surface_set_target(surf_temp)
draw_sprite(spr_screen,0,0,0);
draw_sprite(spr_icon,0,0,0);
draw_sprite(spr_qr,0,display_get_gui_width(),0);
surface_save_part(surf_temp,"share.png", 0, 0,display_get_width(),display_get_height()/2.5);
surface_reset_target();


Any Idea why?
Im guessing the save/load/save? :)
So if i want to use the application_surface?
 
E

eltantillo

Guest
Okey It works, but it´s sooo slow, it takes like 3 seconds before its done...


screen_save("share.png");
spr_screen = sprite_add("share.png",1,0,0,0,0)
surf_temp = surface_create(800,1280);

surface_set_target(surf_temp)
draw_sprite(spr_screen,0,0,0);
draw_sprite(spr_icon,0,0,0);
draw_sprite(spr_qr,0,display_get_gui_width(),0);
surface_save_part(surf_temp,"share.png", 0, 0,display_get_width(),display_get_height()/2.5);
surface_reset_target();


Any Idea why?
Im guessing the save/load/save? :)
So if i want to use the application_surface?
Writing and reading from disk is a slow process. You should better make a copy of the application surface to another surface
 
S

sparwen

Guest
Okey this is veery frustrating.... this most be a bug?...

what i did to speed up things was that I created a sprite to use instead of taking an actual screenshot.
works fine but there most be something wrong, because I can draw a sprite on the new surface, but I cant draw a text??

This is the code...


surf_temp = surface_create(800,1280);
surface_set_target(surf_temp);
draw_sprite(spr_share,0,0,0);
draw_sprite(spr_icon,0,400,225);
surface_save_part(surf_temp,"share.png", 0, 0,800,450);
surface_reset_target();

This works fine, the output "share.png" has the image spr_share with spr_icon draw on top of it....

surf_temp = surface_create(800,1280);
surface_set_target(surf_temp);
draw_sprite(spr_share,0,0,0);
draw_text(400,225,"Hello");
surface_save_part(surf_temp,"share.png", 0, 0,800,450);
surface_reset_target();

This doesn´t work? I can´t see the text? Can´t you draw a text on a surface? the tutorial clearly says you can?

Im Confused?...


SOLVED:

Separated the Drawing and the "saving" in Draw Gui Begin / Draw Gui End
 
Last edited by a moderator:

RangerX

Member
Did you try turning on the application surface, create your background, and then turn off the application surface immediately again?
Should be pretty fast I think.
 
S

sparwen

Guest
Did you try turning on the application surface, create your background, and then turn off the application surface immediately again?
Should be pretty fast I think.
Yep that is what im doing actually, but there need to be a save_file somewhere because the FacebookShare function requires a .png file and not a sprite?
And i think that its the saving that is slowing me down?
 
M

montiedragon

Guest
If you can't draw to the application surface, you can always just copy it to another surface. It eliminates loading a file.


surf_temp = surface_create(800,1280);
surface_copy(surf_temp, 0, 0, application_surface);

surface_set_target(surf_temp)
draw_sprite(spr_icon,0,0,0);
draw_sprite(spr_qr,0,display_get_gui_width(),0);
surface_save_part(surf_temp,"share.png", 0, 0,display_get_width(),display_get_height()/2.5);
surface_reset_target();
surface_free(surf_temp);​

edit: added "surface_free(surf_temp);" to prevent memory leak
 
Last edited by a moderator:

RangerX

Member
Yep that is what im doing actually, but there need to be a save_file somewhere because the FacebookShare function requires a .png file and not a sprite?
And i think that its the saving that is slowing me down?
If you need to save the surface, there's no way around using "surface_save()". And you can save it as a .png no prob. Same with "screen_save()".
 
Top