Click to See Complete Forum and Search --> : Slanted Ellipse? gdi/gdi+.


pirateninja
June 5th, 2007, 08:36 PM
Here is an example for someone who doesn't get what I am talking about.
http://ohnoitsaninja.com:1337/prog/slantedelipse.bmp

I need to be able to make a slanted ellipse. The standard Ellipse in GDI doesn't support a slanted Ellipse that I know of.

Does anyone know of a way of doing this easier than using a combination of Ellipse and RotBlt( which is too slow and leaves holes in the image ) ?

JVene
June 5th, 2007, 11:47 PM
After a brief thought on the subject, I see no other good alternatives but to implement your own ellipse drawing function, with caveats.

It appears what you would want is a rotation parameter that sets the angle of the line between the foci, or at least the rectangle inside which the ellipse is inscribed.

The 'net is replete with algorithms, including those with anti-aliasing and filled ellipses. It is widely recognized that ellipses parallel to the axis are faster because they're easier, but performance should be superior to a rotated blit.

However, performance will be better by far if your algorithm is implemented on a DIB, along with all else you intend to present, the blit the results - as in standard buffered display typical in GDI work. This means you can assign color values to locations in the DIB instead of using SetPixel for each point.

I found this link http://www.spiritone.com/~joeltr/polygonwar2_00000b.htm

Which discusses an algorithm for rotated ellipses, and promises a filled example somewhere, though it's in some dialect of BASIC - it should be possible to interpret that.

pirateninja
June 7th, 2007, 12:06 AM
For anyone who is interested I ended up using multiple ellipses stacked on top of each other.