- Online Community Forums » Programming Questions » Anti Alias

This thread is locked; no one can reply to it. rss feed Print
Anti Alias
duncan perham
Member #15,403
November 2013

im using al_draw_tinted_scaled_rotated_bitmap_region to draw 128X128 sprites, can be in various scales, I can draw the whole image transparent, easy enough, or use drawadd i think it was, but niether does what I would like. Is there anyway, that I can only draw the outter pixels translucent, basically anti alias the image.

I can think of a way to do it, programatically split the image into 2, cut off the edges of the sprites, store them in a second image, then when I draw the sprite, I draw the one with the edges cut off solid, then draw the one that had the edges translucent. If it was all done before hand, that would have little impact on performance. But is there a simpler way to anti alias a sprite JUST for al_draw functions???

Member #12,636
March 2011

It's not completely clear which effect you want, but I think you could first draw the "antialias" outline by using al_set_blender to manipulate the mage until it looks like an "antialias" or "shadow", and then drawing that bitmap a bit bigger. Then reset the blender to normal and draw the sprite at the real desired dimensions, without any color/alpha distortions. You can take a look at the 'ex_blend' example to get an idea of what I mean.

duncan perham
Member #15,403
November 2013

Thanks for the reply, I had considered that approach, but the sprites are quite detailed, and odd shapes, so drawing the sprite a bit bigger in the back ground may look odd, I will have a play with that mind you. What I am try to achive, my sprites have sharp edges, when they were rendred, it darkened the edges, its ok as it is, but I would like to soften them, I could programaticaly go through the sprite and lower the outter pixel colours a bit. Or what I was thinking was best, is as its drawn to the screen, it would be nice if it blended the outter line of pixels with whatever pixels were beind them, that should soften them I hope.

Member #8,789
June 2007

I'm not entirely sure I understand what you want but you may want to try using multisampling (with al_set_new_display_option before creating the display).
Also, if you want your sprites to have slightly transparent edges, why don't you give them ones in your sprite editor?

Dizzy Egg
Member #10,824
March 2009

You could create your images as a .png with an alpha channel I guess; set the outer 1 or 2 pixels to be 50% transparent on the channel, and then just render them...I could be wrong of course.

Please check out my songs:

Go to: