[Mono-winforms-list] 1 pixel offset problem
Matt Zyzik
mzyzik at gmail.com
Thu Sep 4 23:11:19 EDT 2008
On Wed, Jul 30, 2008 at 11:43:04PM -0400, mzyzik at gmail.com wrote:
> On Mon, Jul 28, 2008 at 02:38:10AM +0300, Ivan N. Zlatev wrote:
> > mzyzik at gmail.com wrote:
> > > I see another potentially related bug with drawing. I am trying to draw
> > > some Bezier curves (with GraphicsPath); and the positioning and
> > > appearance is way off (at least with respect to MS .NET).
> > >
> > > Can someone comment on this? I have attached source code, makefile, and
> > > two screenshots (ms.net/windows vs. mono/linux).
> > >
> >
> > I see the bad rendering with SVN Head as well. Please file a bug[1] for
> > the System.Drawing component with a good description of the problem, a
> > self-contained test case and the screenshots attached.
> >
> > [1] http://mono-project.com/Bugs
> >
>
> I just filed a bug (Bug #413461)
>
> --Matt
With some more drawing experiments, I may have uncovered more bugs. I
need a confirmation. I attached two screenshots of renderings from both
frameworks (mono and ms.net), and they are noticeably different. The
common source code is attached as well.
Let me know if these are bugs and if a bug report should be filed.
--Matt
P.S. I am using libgdiplus-110213 and mono-111509.
-------------- next part --------------
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace SWFTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.ComponentModel.IContainer components;
SolidBrush pfsb;
LinearGradientBrush lgb;
GraphicsPath path;
Pen pFS;
int dX = 520;
int dY = 320;
int cirSize = 152;
public Form1()
{
pFS = new Pen(Color.Blue, 16);
lgb = new LinearGradientBrush(new Point(0,dY), new Point(0,dY+118), Color.FromArgb(160, Color.Blue), Color.Green);
pfsb = new SolidBrush(Color.FromArgb(150, Color.Orange));
path = new GraphicsPath(new Point[]
{
new Point(dX-64, dY-24),//start
new Point(dX-59, dY-34),//focal point 1
new Point(dX-52, dY-54),//focal point 2
new Point(dX-18, dY-66),//top
new Point(dX-34, dY-47),//focal point 1
new Point(dX-43, dY-27),//focal point 2
new Point(dX-44, dY-8),//end
}, new byte[]
{
(byte)PathPointType.Start,
(byte)PathPointType.Bezier,
(byte)PathPointType.Bezier,
(byte)PathPointType.Bezier,
(byte)PathPointType.Bezier,
(byte)PathPointType.Bezier,
(byte)PathPointType.Bezier,
});
InitializeComponent();
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
}
protected override void OnPaint(PaintEventArgs e)
{
//draw the plus
e.Graphics.DrawLine(pFS, dX-100, dY, dX+100, dY);
e.Graphics.DrawLine(pFS, dX, dY-100, dX, dY+100);
//draw circle
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.DrawEllipse(pFS, dX-(cirSize/2), dY-(cirSize/2), cirSize, cirSize);
//draw those pie chunks
e.Graphics.FillPie(pfsb, dX-cirSize/2, dY-cirSize/2, cirSize, cirSize, 0, 90);
e.Graphics.FillPie(pfsb, dX-cirSize/2, dY-cirSize/2, cirSize, cirSize, 180, 90);
//draw the gradient
e.Graphics.FillPath(lgb, path);
}
/// <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()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(111, 252);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// linkLabel1
//
this.linkLabel1.Location = new System.Drawing.Point(26, 74);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.TabIndex = 1;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "linkLabel1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(26, 117);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "button1";
this.button1.Click += new EventHandler(ohye);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(17, 157);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 3;
this.textBox1.Text = "textBox1";
//
//
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(613, 570);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
void ohye(object asdf, EventArgs fwe)
{
MessageBox.Show("yeah");
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
-------------- next part --------------
all:
mcs /r:System.Windows.Forms.dll /r:System.Drawing.dll /r:System.Data.dll /target:exe /out:digs.exe Form1.cs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linux.png
Type: image/png
Size: 9422 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-winforms-list/attachments/20080904/48b7ca60/attachment-0002.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: windows.png
Type: image/png
Size: 7766 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-winforms-list/attachments/20080904/48b7ca60/attachment-0003.png
More information about the Mono-winforms-list
mailing list