• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Sprite copied from surface not identical to original image

A

Adiabat

Guest
Hi all,

I'm trying to cut out a small part of an image that may consist of several separate sprites. For what I'm trying to do the part that has been cut out must appear identical to the original part. To do this I'm using surfaces. The problem is that the two parts do not appear identical - in the example below the circle created from the surface appears slightly different from the original (lines are a little thicker I think). Is there anything I can do about this?

Thanks as always!

Draw event:
Code:
   display_reset(8, false);
 
   radius = 100;

// Draw a circle to the screen  
   draw_set_circle_precision(64);
   draw_circle(300,300,radius,true);
 
// Draw additional circles of slightly different radii to make outline thicker  
//   draw_circle(300,300,radius-1,true);
//   draw_circle(300,300,radius+1,true);
     
   var surf;
   surf = surface_create(700,700);
   surface_set_target(surf);
 
// Draw a circle to the surface "surf"  
   draw_circle(300,300,radius,true);
 
// Draw additional circles of slightly different radii to make outline thicker  
//   draw_circle(300,300,radius-1,true);
//   draw_circle(300,300,radius+1,true);


// Create custom sprite from surface - should be identical to original circle
   spr_custom = sprite_create_from_surface(surf,300-radius,300-radius,2*(radius+5),2*(radius+5),
                                           false,false,radius,radius);
   surface_reset_target();
   surface_free(surf);

// Draw custom sprite to screen for comparison with original circle      
   draw_sprite(spr_custom,0,510,300);
 

TheouAegis

Member
For starters, your circle is 300-radius-1 to 300+radius+1. Your min shoudl be 300-radius-1, not 300-radius. Which means your width and height should be 2*radius+4.
 
A

Adiabat

Guest
Thank you Theou.

Perhaps I'm misunderstanding you but "radius-1" was the radius of one of the additional circles that I was going to plot in order to make the lines thicker, but they were commented out in the original code.

In any case, I do not believe that any of the dimensions in "sprite_create_from_surface" are relevant to this problem. I would hope that any part copied from an original image would appear identical to the original part regardless of the chosen dimensions. In the code below I have simplified things a bit, following on from your suggestion, and have removed unnecessary lines. I have also moved the line "display_reset(8, false);" to a previous room.

I have attached an image of the two circles. To my eye the circle drawn from the surface appears subtly different from the original (slightly thicker I think). What are your thoughts?
Runner_161020_1924343 (1024x768).jpg
Code:
   radius = 100;

// Draw a circle to the screen 
   draw_set_circle_precision(64);
   draw_circle(300,300,radius,true);
    
   var surf;
   surf = surface_create(700,700);
   surface_set_target(surf);
 
// Draw a circle to the surface "surf" 
   draw_circle(300,300,radius,true);

// Create custom sprite from surface - should be identical to original circle
   spr_custom = sprite_create_from_surface(surf,300-radius,300-radius,
                                           2*radius+2,2*radius+2,
                                           false,false,radius,radius);
   surface_reset_target();
   surface_free(surf);

// Draw custom sprite to screen for comparison with original circle     
   draw_sprite(spr_custom,0,510,300);
 
A

Adiabat

Guest
Actually, I did not. I have now enabled views and have also checked "visible when room starts". The two circles are more similar but are still not quite identical. Out of interest why does enabling views have this effect?

Runner_161021_2022160 (1024x768).jpg
 

TheouAegis

Member
The other one is "clipped" because your surface width and height need to be 1 greater.

Having views on made the sprite thicker than the drawn circle for me. I couldn't counter it, though....
 
Top