View Full Version : Anti-aliasing edges of 2D graphics

01-08-2007, 08:19 AM
Hi. I'm new to Delphi game programming and am still in the process of choosing a game library/component set to use for my first project. I originally thought of using DirectX, but as I am very poorly informed in this field, any recommendations are welcome. I am looking for a simple yet powerful set that can do the following:


This is screenshot from a game where one graphic (the girl) is displayed against a background graphic. Note how there is no sharp contrast between the edges of the character image and the background. It has been suggested to me that this is done using multiple levels of transparency as opposed to the single transparency colour used by Bitmap files. It has also been pointed out to me that DirectDraw does not support PNG files that have better support for transparency (at least not by default).

Could someone please recommend me a solution for dealing with hard edges like this and possibly suggest a game library/component set that allows it? For example, if you think using PNG files is the solution, could you please recommend me a good component set that allows for PNGs?

Bear in mind that I have no experience in game programming with Delphi.

Thank you in advance.

01-08-2007, 11:02 AM
You can work with pngs using various means. My suggestion is to use something like DanJetX or Asphyre - they both use 3d hardware to render anything you may want. It is very straightforward to create 2d environments using these libraries.

I have most experience with DanJetx and I found it easy to learn and use.

01-08-2007, 01:01 PM
Tga files could be an option as well as they are more widely supported too. Only drawback could be the filesize, but there are ways to counter that.

01-08-2007, 01:59 PM
Phoenix which uses OpenGL is also an option.
You may also take a look at Galfars Vampyre Imaging Library (http://www.pascalgamedevelopment.com/viewtopic.php?t=4627) which have functions to load images ready to use in SDL, OpenGL and DirectX. This gives you the option to use pretty much any library and any image format supported by Imaging.

01-08-2007, 03:26 PM
Wouldn't using vector graphics be the best solution to all your problems?

On a similar note, what are the possibilities with delphi, to use vector graphics?

01-08-2007, 04:39 PM
If he were to scale and do other transformations to his image, vector gfx would be an excellent solution, but if he's just going to show images like the one in the picture I would stick with rasters. He could get the same result with PNG-file or by using some dithering or anti aliasing the edges.

About Vectors in Delphi, I've seen some few libraries, but none off the suitable for game development.

02-08-2007, 06:19 AM
Thank you very much for your input. Please, more suggestions are welcome. If there is little support for vectors in Delphi, then I'm afraid taking that route is not an option for me. Besides, the most important feature for me right now is anti-aliasing. Well, so far, I have been recommended the following:

- Asphyr
- DanJetX
- Phoenix (with OpenGL)

Could someone please provide me with links to where I could download these packages and perhaps some tutorials or samples to get me started? I'm sorry if I seem lazy, but please understand that I am trying to squeeze this in between three other major projects I'm tackling simultaneously.

02-08-2007, 10:16 AM
There ya go. :)

Asphyre 3 (http://www.afterwarp.net/forum/thread87.html)
DanJetX (http://dan.mirgames.ru/main.php?page=djx)
Phoenix (http://www.phoenixlib.net/)

02-08-2007, 10:13 PM
Check out the guide I posted last month at http://www.pascalgamedevelopment.com/files/Pascal_Game_Library_Guide.pdf

02-08-2007, 11:24 PM
Every graphics library propably can do the trick you need, even default Delphi API. For that there is package called PNGImage. This makes possible for these images to load into TImage too
What PNG does is add alpha layer in addition to RGB, and DirectX as well as OpenGL can draw it well. Loading the texture and rendering depends on the engine then. If engine doesn't support Png, you can use the PNGImage units to make own loading procedure using the scanlines... as a last resort.

03-08-2007, 06:14 AM
Thank you for the links, chronozphere. I have downloaded those libraries and hope to find some time this weekend to check them out.

That Pascal Game Library Guide is very enlightening. Thank you, WILL.

And User137, it would be faster and more efficient if the engine itself supports PNG, wouldn't it? Since I haven't already started with any specific library, I think I'll try to pick one that does this. Thank you for your contribution.