How to make a printscreen from surface and sprite

Good day, GameMakerz.

I have been facing some troubles creating a printscreen system on an app I am creating.

I am using a surface to have things drawn on the screen by the player (painting area) and I have a sprite drawn by the program on top of that surface.

My issue is that I am not able to add the sprite to the saved image (or save both in the printscreen file at same time).

Please see the printscreens:
  • 1st is in app what you see.

  • 2nd is the area needed to be saved to the printscreen, marked with a red rectangle.

  • 3rd is what is actual saved to the printscreen file.


Any help would greatly be appreciated! Thanks in advance.

TC
 

Attachments

Hello Lord KJWilliams.

Yes, indeed I am. Nothing really fancy. Mostly a gift for my niece, but I might put it available for free on android.
Please provide your program code. It sounds like your not defining the first image as a surface to add the second image to. Thats my best answer without seeing your code. Also, there is a function called surface_exists() that you should use that checks that the first surface exists before you add the next surface. So if the first surface disappears then you have the program redraw it again, and then add the next surface in your program, before you save it.
 
Last edited:
Thanks for the reply @Lord KJWilliams.
I hope my code is not too messy and easy enough to understand.

control
object code:


Create

if instance_exists(obj_paperbig)
{
var sw = 1610/2;
var sh = 1340/2;
var bor = 50;
//draw_rectangle(xpospp-sw+bor,ypospp-sh+bor,xpospp+sw-bor,ypospp-sh-bor,false);
surface = surface_create(sw*2,sh*2-bor*4);
}

Step

//If surface doesn't exist, create it
if !surface_exists(surface)
{
//surface = surface_create(700,600);
if instance_exists(obj_paperbig)
{
var sw = 1610/2;
var sh = 1340/2;
var bor = 50;
surface = surface_create(sw*2,sh*2-bor*4);
}
}

Draw

if instance_exists(obj_paperbig)
{
var sw = 1610/2;
var sh = 1340/2;
var bor = 50;
var xpospp = obj_paperbig.x;
var ypospp = obj_paperbig.y;
draw_rectangle_color(xpospp-sw+bor,ypospp-sh+bor+bor+bor,xpospp+sw-bor,ypospp+sh-bor,c_white,c_white,c_white,c_white,false);
draw_surface(surface,xpospp-sw,ypospp-sh+bor*2.5);
draw_sprite(spr_drawing,0,xpospp,ypospp); // Draw Collection and Corresponding Drawing // This is the sprite of the drawing that is not saved in the printscreen
}


save object code:

Left Mouse Button Released

// Code to print screen and save to file - Prompt User for File name
if mouse_check_button_released(mb_left) && distance_to_point(mouse_x,mouse_y) <= 1
{
var file = get_save_filename("png|*.png", "");
if file != ""
{
surface_save(control.surface,file);
}
}

So, somewhere there, I should create a surface based on the sprite "spr_drawing"?
 
Thanks for the reply @Lord KJWilliams.
(snipped)
Your trying to save your sprite which is not part of a surface. Thats why your background is missing. Your also using the wrong function to save a surface, if your trying to save it as a .png ( its surface_save() ). But before you leap to your conclusion, I recommend reading the online manual , on surfaces to get a better idea. Then you will see what your doing wrong. Its more complicated than you think it is.
 
Last edited:
I will read the manual, on surfaces once again, to see if I understand it better.
It does not seem easy at all, otherwise I wouldn't come ask for help.

Thanks for your time.
 
Top