[Mono-bugs] [Bug 492299] Graphics.Clear(Color) doesn't work on clipped Graphics

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Jun 25 10:20:03 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=492299

User alexander.shulgin at yessoftware.com added comment
http://bugzilla.novell.com/show_bug.cgi?id=492299#c1





--- Comment #1 from Alex Shulgin <alexander.shulgin at yessoftware.com>  2009-06-25 08:20:02 MDT ---
Created an attachment (id=300394)
 --> (http://bugzilla.novell.com/attachment.cgi?id=300394)
(Test images from my system)

The original sample works on my Ubuntu 9.04.  However, there's another related
problem: gfx.Clear() works with excluded elliptic region, but not with custom
region created from a bit more complex GraphicsPath (rounded rectangle).

Sample code:

using System;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace test
{
    public class Program
    {
        public static void Main() {
            CreateTestBitmap(100, 100,
                             MakeRoundRect(10, 10, 80, 80, 20))
                .Save("region-exclude-roundrect.png");

            using (GraphicsPath gp = new GraphicsPath()) {
                gp.AddEllipse(10, 10, 80, 80);
                CreateTestBitmap(100, 100, gp)
                    .Save("region-exclude-ellipse.png");
            }
        }

        static Bitmap CreateTestBitmap(int width, int height, GraphicsPath gp)
{
            Bitmap bmp = new Bitmap(width, height);
            using (Graphics gfx = Graphics.FromImage(bmp)) {
                gfx.Clear(Color.Red);
                gfx.SetClip(new Region(gp), CombineMode.Exclude);
                gfx.Clear(Color.Blue);
            }
            return bmp;
        }

        static GraphicsPath MakeRoundRect(int x, int y, int width, int height,
int radius) {
            GraphicsPath gp = new GraphicsPath();
            int D = radius*2;
            gp.AddArc(x + width - D, y, D, D, 270, 90);
            gp.AddArc(x + width - D, y + height - D, D, D, 0, 90);
            gp.AddArc(x, y + height - D, D, D, 90, 90);
            gp.AddArc(x, y, D, D, 180, 90);
            gp.CloseFigure();
            return gp;
        }
    }
}

The test images from my system are attached.

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list