[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Drawing with PointF and SizeF structure

wansch

12/22/2004 2:59:00 PM

Hello all,

I'm a newbie to programming and my question is:
For what is it good to draw with float values in graphic routines since
pixels are always integer.

Also I have tried the following code and ask myself if this is correct:
class F1 : Form
{
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;

Pen p1 = new Pen(Color.Red);

//Line 1: 11 pixel long
PointF ptf1 = new PointF(25.5f, 45.4f);
PointF ptf2 = new PointF(36.3f, 45.4f);

g.DrawLine(p1, ptf1, ptf2);

//Line 2: 12 pixel long
PointF ptf3 = new PointF(25.5f, 55f);
PointF ptf4 = new PointF(36.3f, 55f);

g.DrawLine(p1, ptf3, ptf4);

p1.Dispose();
}
}

1 Answer

Bob Powell

12/22/2004 8:24:00 PM

0

You might like to read the beginners guide to GDI+ on my site.

This explains why floats are used and how to take advanage of them.

http://www.bobpowell.net/beginn...

For more of these articles as they arrive subscribe to the RSS feed on the
main page.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tips...

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/f...

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"wansch" <wansch@discussions.microsoft.com> wrote in message
news:F4D92EC1-9D96-44D3-85FF-AA5B0AE51154@microsoft.com...
> Hello all,
>
> I'm a newbie to programming and my question is:
> For what is it good to draw with float values in graphic routines since
> pixels are always integer.
>
> Also I have tried the following code and ask myself if this is correct:
> class F1 : Form
> {
> protected override void OnPaint(PaintEventArgs e)
> {
> Graphics g = e.Graphics;
>
> Pen p1 = new Pen(Color.Red);
>
> //Line 1: 11 pixel long
> PointF ptf1 = new PointF(25.5f, 45.4f);
> PointF ptf2 = new PointF(36.3f, 45.4f);
>
> g.DrawLine(p1, ptf1, ptf2);
>
> //Line 2: 12 pixel long
> PointF ptf3 = new PointF(25.5f, 55f);
> PointF ptf4 = new PointF(36.3f, 55f);
>
> g.DrawLine(p1, ptf3, ptf4);
>
> p1.Dispose();
> }
> }
>