Smoother curves using CDC functions

Hi all

Can I do antialiasing using CDC functions?
If not, how to achieve smoother curves for bitmaps in memory.

I have seen some GUI applications doing an excellent job at drawing fine curves. How do these applications do it. Do they use GDI+ ?

Just wondering what mapping mode of the CDC functions give the best results (may be not exact but close to antialiasing).

Thanks for your comments.
[432 byte] By [Hitesh1903] at [2007-11-18 15:18:16]
# 1 Re: Smoother curves using CDC functions
I think that's not possible with GDI. You could use GDI+, write your own vector-rasterizer supporting antialiasing or take a look at A high quality rendering engine for C++ (http://www.antigrain.com/). I haven't tried it, but the screenshots look awesome! AND it has a really nice license:
Permission to copy, use, modify, sell and distribute this software is granted provided this copyright notice appears in all copies. This software is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.
Marc G at 2007-11-11 1:59:16 >
# 2 Re: Smoother curves using CDC functions
My requirement for smoother curves is for a personal project and the use itself is quite limited. I wouldn't prefer falling back to any library dependent code.

I am drawing very limited amount of user-defined shapes in memory and then rendering them on the screen. All my other stuff is fixed and so I can easily use pre-rendered bitmaps.

Can't I do something with CDC to get better results ?
Hitesh1903 at 2007-11-11 2:00:16 >
# 3 Re: Smoother curves using CDC functions
Hi,

I suggest you apply OpenGL in your program to draw the graphics.

How to begin with OpenGL...

Try to grab some simple example to start your OpenGL with MFC

http://myopendemo.hypermart.net
http://nehe.gamedev.net
http://www.gametutorials.com
cwc36 at 2007-11-11 2:01:17 >
# 4 Re: Smoother curves using CDC functions
Sorry I did not mention this before but I am already using DirectX. :)

My application requires me to build certian textures in memory because they are more of user input event based. Further, the options for this input will require me to build probably more than a 1000 different textures. So, I decided to make those as bitmaps in memory. But I don't get them anywhere close to looking good.

I really don't expect them to be as good as the real 32bpp bitmaps but something that look good. These textures wil make only a small part of the complete application. Most of my memory based textures are some region of a circle (basically a pie). What I am looking for is some way to make the arc of the pie smoother.
Hitesh1903 at 2007-11-11 2:02:14 >
# 5 Re: Smoother curves using CDC functions
I'm pretty sure DirectX has some way to do Rendering To Texture. So no need to use CDC.
Marc G at 2007-11-11 2:03:22 >
# 6 Re: Smoother curves using CDC functions
Yeah there are ways to render to texture.

But Directx still does not provide functions to draw something like a pie whose angle changes depending on the user input. I have to draw about 100 pie shaped figures on screen all with probably different angles. I don't think its a good idea to create a texture with all the 360 degree variants of angles for pie and keep in memory.

So I opted to build a bitmap in memory depending on the angle for the pie and render this bitmap as a texture. But I am getting preety bad results as far as creating the bitmap is concerned. I get jagged lines and so was looking for some easy solution to overcome this.
Hitesh1903 at 2007-11-11 2:04:24 >
# 7 Re: Smoother curves using CDC functions
What if you rendered your shapes much bigger to a CDC and then use DirectX to scale this texture? DirectX will scale it down nicely given the impression of AA.
Marc G at 2007-11-11 2:05:20 >
# 8 Re: Smoother curves using CDC functions
That was my assumption too. But did not work. :-(

I tried making bitmaps of size 512x512 and then rendering them to a texture of size 128x128. It still gives me the same staircase like appearence.
Hitesh1903 at 2007-11-11 2:06:23 >
# 9 Re: Smoother curves using CDC functions
Hello,

I am in the same situation except I am not using DirectX. I am using MFC only. I am drawing several pies but the results are poor. I was thinking of drawing them to a larger sized memory contect and then resizing that to a small and final output hoping that it would give the impression of Antialiasing. However just as it was suggested in the earlier post, this is not the case.

What else can I do? Surely there must be a way to achieve such an effect/result.

Thanks,

Aristotel
greekgoddj at 2007-11-11 2:07:22 >
# 10 Re: Smoother curves using CDC functions
Hello,

I am in the same situation except I am not using DirectX. I am using MFC only. I am drawing several pies but the results are poor. I was thinking of drawing them to a larger sized memory contect and then resizing that to a small and final output hoping that it would give the impression of Antialiasing. However just as it was suggested in the earlier post, this is not the case.

What else can I do? Surely there must be a way to achieve such an effect/result.

Thanks,

Aristotel
You do realise that this is a very old thread....

Anyway, to draw nice vector based graphics, you should definitely take a look at AntiGrain (www.antigrain.com). I now used it myself and it is really great.
Marc G at 2007-11-11 2:08:27 >
# 11 Re: Smoother curves using CDC functions
Hello Marc,

Yup I realize its old..but related to my needs :)

I have seen AntiGrain but due to the nature of the project I am working on, I cannot use 3rd party libraries etc.

I cannot use GDI+ as it is not available on Windows 98. I thought i could use StretchBlt with the HALFTONE mode as sated in the thread http://www.dev-archive.com/forum/showthread.php?t=239897&highlight=antialiasing (also an old thread). However according to the MSDN documentation the HALFTONE is not possible on 95/98/ME...

Any other ideas?

Thanks!
greekgoddj at 2007-11-11 2:09:27 >
# 12 Re: Smoother curves using CDC functions
You can use GDI+ on Windows 98 if you distribute the GDI+ package as can be read in the MSDN:
Gdiplus.dll is included with Windows XP. For information about which operating systems are required to use a particular class or method, see the More Information section of the documentation for the class or method. GDI+ is available as a redistributable for Windows NT 4.0 SP6, Windows 2000, Windows 98, and Windows Me. To download the latest redistributable, see http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdkredist.htm
Marc G at 2007-11-11 2:10:28 >
# 13 Re: Smoother curves using CDC functions
Thanks for that...its a possibility but my client finds the size of the DLL too large (1.6MB, 0.9MB zipped), to add to the product. It seems the only other option is to try and implement an antialiasing alrogithm myself...good luck to me!

Thanks though :)
greekgoddj at 2007-11-11 2:11:22 >
# 14 Re: Smoother curves using CDC functions
but my client finds the size of the DLL too large (1.6MB, 0.9MB zipped), to add to the product.Too large? Are you distributing the product on floppy disks? :confused:

It seems the only other option is to try and implement an antialiasing alrogithm myself...good luck to me!Don't know if I would consider that an option - reinventing a complex functionality which is already available in a library is not really an option. Are you aware that in order to draw antialiased lines using GDI, you will have to reimplement all the line drawing functions (LineTo, Rectangle, Ellipse...) yourself. How many years did your customer give you for that task?
gstercken at 2007-11-11 2:12:30 >
# 15 Re: Smoother curves using CDC functions
And why aren't you allowed to use AntiGrain as I posted before? When you use antigrain, you don't require to distribute any additional DLLs and the library is pretty compact.
Marc G at 2007-11-11 2:13:26 >
# 16 Re: Smoother curves using CDC functions
hehe floppy disks..no..its on CD and online...but the software is part of a bigger product whichis already big enough and they dont want me to add an extra MB for somehting which is only needed in a small part of the product.

Yes i do realize the complexity of re implementing an anti aliasing algorithm...and its a scary thought!

Anti-Grain looks good and personally I find the lisence is great..but the client's client does not want to have to include extra credits, notes, etc regarding the use of it.

The complexities f working for client's clients. :)
greekgoddj at 2007-11-11 2:14:30 >
# 17 Re: Smoother curves using CDC functions
I think I might have misunderstood the lisence agreement of Anti-Grain. I will look at it in more detail and get back to you.
greekgoddj at 2007-11-11 2:15:29 >