How to anti-alias text onto background?

BlitzMax Forums/BlitzMax Beginners Area/How to anti-alias text onto background?

Grey Alien(Posted 2005) [#1]
How can I get DrawText to antialias some text onto the background as hinted at in the docs. Using SetBlend ALPHABLEND and SetAlpha 0.5 will only draw the entire text transparent. What I want to do is antialias the edge of the text so it isn't pixelly. I would also like to do the same thing for images so that DrawImage will antialias the edges onto a background, any ideas?

thanks in advance.


Diablo(Posted 2005) [#2]
i think all you have to do is just use setblend ALPHABLEND but dont change the alpha value

also when you load a font using LoadImageFont make sure you use style=SOOMTHFONT - it should do this anyways


Oddball(Posted 2005) [#3]
Load the font twice the size you need then use SetScale(0.5,0.5) to reduce it's size this will create an anti-alias effect. The same can be done for images, but you must set the mipmapped flag for images.


Grey Alien(Posted 2005) [#4]
Hmm, so twice as large and shrink it. This will however anti-alias the entire image, not just the edge. If you wanted to keep the middle of the image "pure" and just do the edge how could this be done? Also did I read there was a smooth image flag for when loading images or was I imagining that.


Oddball(Posted 2005) [#5]
The FILTEREDIMAGE and MIPMAPPEDIMAGE flags only affect an image when it is scaled. I don't know if there is a way to anti-alias just the edge of an image. I think it's either the whole image or not at all.


Oddball(Posted 2005) [#6]
Could you not just anti-alias the edge of your image in your art package of choice?


TartanTangerine (was Indiepath)(Posted 2005) [#7]
You need some of this :-

http://www.blitzbasic.com/Community/posts.php?topic=49082


Grey Alien(Posted 2005) [#8]
If you antialias the edge in an art pacakge you ahve a choice, aniti alias to a uniform background (which might not be the same colour as your game) or anti-alias to your title-screen say, BUT what if you want to move the image around, you can't precalc every frame in an art package you need to do it on the fly. A technique I used in Blitz Plus was to create a "mask" image that was pure white in the middle and faded to black just on the edges, then when rendering I made a custom alpha blend routine that drew the white bits totally solid and the grey bits were blended with the background, this worked great, but I was wondering if there was a quick way to do this in max, probably not I guess :-(


Grey Alien(Posted 2005) [#9]
Thanks Tim, seems like you fixed something there! People further down in the thread were getting a problem, is this with your fixed version or did they fail to build it properly?


TartanTangerine (was Indiepath)(Posted 2005) [#10]
Look at the post I just made.

I made a Module for Bitmap fonts, it's kicking around here somewhere.


Oddball(Posted 2005) [#11]
Create your images with an alpha'd background then anti-alias the edge of the image in the art package. Then when you draw the images in max use SetBlend(ALPHABLEND) to preserve the alpha when drawing. This will blend them to whatever background you draw them over.


TartanTangerine (was Indiepath)(Posted 2005) [#12]
it's fixed, I expect this is in the offical update - when it comes.


Grey Alien(Posted 2005) [#13]
Oddball: "Create your images with an alpha'd background" How do I do that bit? And do you mean use SetBlend ALPHABLEND with default values i.e. SetAlpha 1.0? So this will result in a solid main image with an antialiased edge, sounds cool.


TartanTangerine (was Indiepath)(Posted 2005) [#14]
.PNG files have an alpha channel, I sent you an example in the email with that module.


Grey Alien(Posted 2005) [#15]
I need to read up on Alphachannels, I know what a transparent colour is say in a GIF or a single image mask colour in Blitz PLus.


Grey Alien(Posted 2005) [#16]
That's some weirdass font Tim you sent me, I can't figure it out at all.