[Mono-bugs] [Bug 442428] New: Problem on GraphicsPath. AddArc when angle is bigger than 180

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Nov 6 14:46:27 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=442428


           Summary: Problem on GraphicsPath.AddArc when angle is bigger than
                    180
           Product: Mono: Class Libraries
           Version: 2.0
          Platform: i686
        OS/Version: openSUSE 11.0
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: libgdiplus
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: psantosl at codicesoftware.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Community User


Created an attachment (id=250447)
 --> (https://bugzilla.novell.com/attachment.cgi?id=250447)
Source code

Description of Problem:

Graphics.AddArc creates wrong angle when bigger than 180.

We've found a problem on GraphicsPath.AddArc when angle is bigger than 180.

Please find attached a couple of screenshots running on Windows and Linux.

I'm also attaching a sample app which reproduces the error. Don't know 
exactly where the problem is but I think it is a good testcase to fix it.




How often does this happen? 

ALWAYS

Additional Information:

A couple of screenshots and the code.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;

namespace WindowsApplication16
{
    public class Form1 : System.Windows.Forms.Form
    {
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.TrackBar trackBar1;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.ComponentModel.Container components = null;
        public Form1()
        {
            InitializeComponent();
        }

        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if (components != null) 
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }

        #region Windows Forms
        private void InitializeComponent()
        {
            this.panel1 = new System.Windows.Forms.Panel();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.trackBar1 = new System.Windows.Forms.TrackBar();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
           
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
            this.SuspendLayout();
            // 
            // panel1
            // 
            this.panel1.Location = new System.Drawing.Point(32, 16);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(632, 512);
            this.panel1.TabIndex = 0;
            this.panel1.Paint += new
System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
            // 
            // label1
            // 
            this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif",
9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
            this.label1.Location = new System.Drawing.Point(32, 544);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(48, 23);
            this.label1.TabIndex = 2;
            this.label1.Text = "Angle:";
            // 
            // label2
            // 
            this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif",
9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
            this.label2.Location = new System.Drawing.Point(104, 544);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(64, 23);
            this.label2.TabIndex = 3;
            this.label2.Text = "0º";
            // 
            // trackBar1
            // 
            this.trackBar1.Location = new System.Drawing.Point(160, 536);
            this.trackBar1.Maximum = 36;
            this.trackBar1.Name = "trackBar1";
            this.trackBar1.Size = new System.Drawing.Size(512, 45);
            this.trackBar1.TabIndex = 4;
            this.trackBar1.ValueChanged += new
System.EventHandler(this.trackBar1_ValueChanged);
            // 
            // label3
            // 
            this.label3.Location = new System.Drawing.Point(32, 584);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(640, 19);
            this.label3.TabIndex = 5;
            this.label3.Text = "When the angle >= 180º, the GraphicPath
doesn\'t match with its defined lines. ";
            // 
            // label4
            // 
            this.label4.Location = new System.Drawing.Point(32, 608);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(632, 15);
            this.label4.TabIndex = 6;
            this.label4.Text = "The bug is on the
GraphicsPath.AddArc(Rectangle, float, float) method";
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(696, 630);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.trackBar1);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.panel1);
            this.Name = "Form1";
            this.Text = "Form1";
           
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
            this.ResumeLayout(false);

        }
        #endregion

        [STAThread]
        static void Main() 
        {
            Application.Run(new Form1());
        }

        private float angle = 0;

        private void panel1_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
        {
            //constants
            int total_size = 400;
            int separation = 30;

            Rectangle inside_rect = new Rectangle(separation, separation,
total_size, total_size);
            Rectangle outside_rect = new Rectangle(inside_rect.Location,
inside_rect.Size);
            outside_rect.Inflate(separation, separation);

            e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.DarkGray),
2), outside_rect);
            e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.DarkGray),
2), inside_rect);

            //Create a graphic path similar to the previous drawed figure
            GraphicsPath figure = new GraphicsPath();
            //0 degrees are 3 o'clock, 180 degreess are 9 o'clock
            figure.AddArc(outside_rect, angle, -angle);
            figure.AddLine(outside_rect.Right, (total_size/2) + separation,
outside_rect.Right - separation, (total_size/2) + separation);
            figure.AddArc(inside_rect, 0, angle);
            figure.CloseFigure();

            //Now we draw the created path on blue
            e.Graphics.DrawPath(new Pen(new SolidBrush(Color.Blue), 2),
figure);

            //And Paint a figure with a red pen (are overlapped)
            e.Graphics.DrawArc(new Pen(new SolidBrush(Color.Red), 2),
outside_rect, angle, -angle);
            e.Graphics.DrawLine(new Pen(new SolidBrush(Color.Red), 2),
outside_rect.Right, (total_size/2) + separation, outside_rect.Right -
separation, (total_size/2) + separation);
            e.Graphics.DrawArc(new Pen(new SolidBrush(Color.Red), 2),
inside_rect, 0, angle);

            //Blue draw and red draw always should be the same (when angle >
180 it is not the same)
        }

        private void trackBar1_ValueChanged(object sender, System.EventArgs e)
        {
            angle = (float) trackBar1.Value * 10;
            label2.Text = ((int) angle).ToString() + "º";
            panel1.Invalidate();
        }
    }
}


-- 
Configure bugmail: https://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