GDI+ Clipping seems to ignore SmoothingMode RRS feed

  • Question

  • I have encountered an issue which hopefully someone can recommend a fix for.

    It appears that the anti-aliasing smoothing mode is IGNORED COMPLETELY by the GDI+ clipping functions. A simple example (below) illustrates the problem:

    Suppose the graphics smoothing mode is set to "SmoothingModeAntiAlias" and an ellipse is filled using FillEllipse. The boundary is smooth (anti-aliased) as it should be.

    Next, set the clipping region of graphics object to the same-sized ellipse (using SetClip to a path with the ellipse added). Now use FillRectangle to create the (clipped) ellipse. No matter how the smoothing mode is changed, the resulting ellipse is NOT anti-aliased! In fact, its rendering is very close to the "SmoothingModeHighSpeed" smoothing setting (NO anti-aliasing).

    Admittedly this is a contrived example. However, there are many situations with more complicated "paths" that are used for clipping, and it would be nice if the resulting filled path boundary could be rendered smoothly (anti-aliased). My question is this: is there a way to do that using the clipping methods of GDI+ (I'm guessing, apparently NOT)? Thanks for any suggestions.

    Here is the example code snippet. If you run it, you will notice particularly at the top/bottom and left/right of the clipped ellipse, there are significant regions of aliasing, compared with the smooth ellipse.


    using namespace Gdiplus;

    Graphics g(hDC);    //hDC is set externally


    //Draw smoothed ellipse

     RectF rcF(10,20,400,600);
     SolidBrush red(Color(255,255,0,0));

    //Draw ellipse by clipping a rectangle

     GraphicsPath path;


    Wednesday, May 9, 2012 11:55 AM


All replies