• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Potential bug with surface_copy_part()?

V

Verburner

Guest
I have converted a little project I was trying around with in Game Maker: Studio to GMS2 and had unexpected results. When trying to fix the problem I was able to trace it back to one particular function, namely surface_copy_part().

What I am experiencing, is that the resulting image will be vertically distorted in the target surface, if the 5th argument, the x position to copy from in the source, is not equal to 0. An example code would be:

surf = surface_create(200,200);
surface_set_target(surf);
draw_clear_alpha(c_black,0);
draw_sprite(spr_circle,0,100,100);
surface_reset_target();

surf_part = surface_create(100,100);
surface_set_target(surf_part);
draw_clear_alpha(c_black,0);
surface_copy_part(surf_part,0,0,surf,50,50,100,100);
draw_surface(surf_part,0,0);
surface_reset_target();

Then draw surf_part to the screen in the draw event.

In GMS1 this will copy the sprite into the second surface just fine. In GMS2 the resulting image will be stretched along the x axis.

I am not a very experienced user, so I'd like to have a second opinion on this before reporting it. Might just be overlooking some change in GMS2..
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
surface_copy and surface_copy_part are bugged, I'm afraid. I believe this has already been bugged but feel free to file it with YYG just in case...
 

babyjeans

Member
While I'm not 100% on what you're doing - there was another thread about this issue with the surface_copy_part bug and there was the suggestion to use the draw_surface/draw_surface_part functions instead as a work around. You might be able to achieve what you want that way, while we wait for a bug fix!
 
V

Verburner

Guest
While I'm not 100% on what you're doing - there was another thread about this issue with the surface_copy_part bug and there was the suggestion to use the draw_surface/draw_surface_part functions instead as a work around. You might be able to achieve what you want that way, while we wait for a bug fix!
The problem is, that I need to use it in conjunction with the sprite_create_from_surface() function, which uses the bottom left pixel as a reference for background to remove. I was using the surface_copy_part function to create a new surface with column of alpha pixels on the left, to ensure this works as intended. Got any workaround for that too perhaps? (as a sidenote: I wrote the example code only to demonstrate the issue, it has nothing to do with my project)
 
Top