This is not quite the same problem. My code was calling DrawLines with the
same points just with different Pens. Your code (DrawPath, FillPath)
exhibits the same behavior as DrawRectangle, FillRectangle. The Rectangle
"Glenn Spies" <glenn.spies@creuna.se> wrote in message
news:uEdwaysoDHA.2584@TK2MSFTNGP09.phx.gbl...
> I too have the same problem that a filled path does not fill the same path
> as when it is with drawpath.
>
> Code follows:
>
> using System;
>
> using System.Drawing;
>
> using System.Collections;
>
> using System.ComponentModel;
>
> using System.Windows.Forms;
>
> using System.Drawing.Drawing2D;
>
> namespace ControlsTest
>
> {
>
> /// <summary>
>
> /// Summary description for NewControlsTest.
>
> /// </summary>
>
> public class NewControlsTest : System.Windows.Forms.Form
>
> {
>
> /// <summary>
>
> /// Required designer variable.
>
> /// </summary>
>
> private System.ComponentModel.Container components = null;
>
> private System.Windows.Forms.Panel panel1;
>
> public NewControlsTest()
>
> {
>
> //
>
> // Required for Windows Form Designer support
>
> //
>
> InitializeComponent();
>
> //
>
> // TODO: Add any constructor code after InitializeComponent call
>
> //
>
> panel1.Paint += new PaintEventHandler(panel1_paint);
>
> }
>
> public static GraphicsPath SmoothOutline(Rectangle r, int cornerSize)
>
> {
>
> GraphicsPath gp = new GraphicsPath();
>
> if (!r.IsEmpty)
>
> {
>
> gp.AddArc(r.Left, r.Top, cornerSize, cornerSize, 180, 90);
>
> gp.AddArc(r.Left + r.Width - cornerSize, r.Top, cornerSize, cornerSize,
270,
> 90);
>
> gp.AddArc(r.Left + r.Width - cornerSize, r.Top + r.Height- cornerSize,
> cornerSize, cornerSize, 0, 90);
>
> gp.AddArc(r.Left, r.Top + r.Height- cornerSize, cornerSize, cornerSize,
90,
> 90);
>
> gp.CloseFigure();
>
> }
>
> return gp;
>
> }
>
> private void panel1_paint(object sender, PaintEventArgs e)
>
> {
>
> Graphics g = e.Graphics;
>
> g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
>
> g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
>
> Rectangle r = new Rectangle(new Point(0,0) , panel1.Size);
>
> int w = r.Width;
>
> int h = r.Height;
>
> w-=1;
>
> h-=1;
>
> r.Location = new Point(0,0);
>
> r.Width = w;
>
> r.Height = h;
>
> System.Drawing.Drawing2D.GraphicsPath gp = SmoothOutline(r, 50);
>
> gp.FillMode = System.Drawing.Drawing2D.FillMode.Alternate;
>
> g.DrawPath(Pens.White, gp);
>
> g.FillPath(Brushes.Red, SmoothOutline(r, 50)); //does not cover all of the
> path
>
>
> g.Clip = new Region(SmoothOutline(r, 50));
>
>
> }
>
> /// <summary>
>
> /// Clean up any resources being used.
>
> /// </summary>
>
> protected override void Dispose( bool disposing )
>
> {
>
> if( disposing )
>
> {
>
> if(components != null)
>
> {
>
> components.Dispose();
>
> }
>
> }
>
> base.Dispose( disposing );
>
> }
>
> #region Windows Form Designer generated code
>
> /// <summary>
>
> /// Required method for Designer support - do not modify
>
> /// the contents of this method with the code editor.
>
> /// </summary>
>
> private void InitializeComponent()
>
> {
>
> System.Resources.ResourceManager resources = new
> System.Resources.ResourceManager(typeof(NewControlsTest));
>
> this.panel1 = new System.Windows.Forms.Panel();
>
> this.SuspendLayout();
>
> //
>
> // panel1
>
> //
>
> this.panel1.Anchor = System.Windows.Forms.AnchorStyles.None;
>
> this.panel1.BackColor = System.Drawing.Color.Transparent;
>
> this.panel1.Location = new System.Drawing.Point(168, 64);
>
> this.panel1.Name = "panel1";
>
> this.panel1.Size = new System.Drawing.Size(300, 100);
>
> this.panel1.TabIndex = 0;
>
> //
>
> // NewControlsTest
>
> //
>
> this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
>
> this.BackgroundImage =
> ((System.Drawing.Bitmap)(resources.GetObject("$this.BackgroundImage")));
>
> this.ClientSize = new System.Drawing.Size(736, 266);
>
> this.Controls.AddRange(new System.Windows.Forms.Control[] {
>
> this.panel1});
>
> this.Name = "NewControlsTest";
>
> this.Text = "NewControlsTest";
>
> this.ResumeLayout(false);
>
> }
>
> #endregion
>
> }
>
> }
>
> Any suggestions would be appreciated
>
>
>
> /Glenn
>
> "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
> news:eVTs1g5nDHA.976@tk2msftngp13.phx.gbl...
> > The problem goes away when you set the PixelOffsetMode to High Quality.
> >
> > --
> > Bob Powell [MVP]
> > C#, System.Drawing
> >
> > The October edition of Well Formed is now available.
> > Find out how to use DirectX in a Windows Forms control
> >
http://www.bobpowell.net/currentissue.htm > >
> > Answer those GDI+ questions with the GDI+ FAQ
> >
http://www.bobpowell.net/gdiplus_faq.htm > >
> > Read my Blog at
http://bobpowelldotnet.blogspot.com > >
> > "Brock" <brockreeve@me.com> wrote in message
> > news:%23ste6eznDHA.1740@TK2MSFTNGP12.phx.gbl...
> > > I am seeing inconsistent drawing behavior when calling
> > Graphics.DrawLines()
> > > with a pen created from a non solid brush vs. a Graphics.Drawlines()
> call
> > > with a pen created from a solid brush. The line between the same
points
> > is
> > > drawn differently. To see this, create a windows forms project in
VS.NET
> > > 2003 and override OnPaint and add the following code:
> > >
> > > PointF[] points = new PointF[11];
> > > points[0] = new PointF(28, 12);
> > > points[1] = new PointF(45, 116);
> > > points[2] = new PointF(62, 168);
> > > points[3] = new PointF(79, 169);
> > > points[4] = new PointF(96, 127);
> > > points[5] = new PointF(114, 78);
> > > points[6] = new PointF(130, 164);
> > > points[7] = new PointF(147, 106);
> > > points[8] = new PointF(164, 70);
> > > points[9] = new PointF(181, 36);
> > > points[10] = new PointF(199, 16);
> > >
> > > e.Graphics.FillRectangle(Brushes.Black, e.ClipRectangle);
> > > using(LinearGradientBrush brush = new
> LinearGradientBrush(e.ClipRectangle,
> > > Color.White, Color.White, LinearGradientMode.Horizontal))
> > > using(Pen linearPen = new Pen(brush))
> > > {
> > > e.Graphics.DrawLines(linearPen, points);
> > > e.Graphics.DrawLines(Pens.Yellow, points);
> > > }
> > >
> > > Notice that you can see the white line as well as the yellow line. Am
I
> > > doing something wrong? I need both to draw the same. Is there some
> > property
> > > on the Graphics object I can set?
> > >
> > >
> >
> >
>
>