PC Review


Reply
Thread Tools Rate Thread

How to draw a 1 pixel long line using Graphics.DrawLine?

 
 
=?Utf-8?B?RGF2ZSBMZWFjaA==?=
Guest
Posts: n/a
 
      8th Dec 2005
I am writing a Windows Forms application graphing routine using VS.NET 2003,
Visual C# and .NET Framework 1.1.

The Graphics.DrawLine(Pen,int,int,int,int) method seems to work okay unless
the desired line being drawn is only one pixel long (horizontally). I have
not found a way to get a horizontal line of only one pixel to be drawn. I
either get no line or a two pixel line.

Example method calls:

Graphics.DrawLine( Pen, 20, 50, 21, 50 ); // Results in two pixel long line.
Graphics.DrawLine( Pen, 20, 50, 20, 50 ); // Results in no pixels being
drawn.

So how do I get a one pixel long line?

Thanks,
Dave

 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      8th Dec 2005
"Dave Leach" <(E-Mail Removed)> schrieb:
>I am writing a Windows Forms application graphing routine using VS.NET
>2003,
> Visual C# and .NET Framework 1.1.
>
> The Graphics.DrawLine(Pen,int,int,int,int) method seems to work okay
> unless
> the desired line being drawn is only one pixel long (horizontally). I
> have
> not found a way to get a horizontal line of only one pixel to be drawn. I
> either get no line or a two pixel line.


<URL:http://www.bobpowell.net/single_pixel_lines.htm>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGF2ZSBMZWFjaA==?=
Guest
Posts: n/a
 
      8th Dec 2005
The link provided in the reply below deals with line width. I am asking how
to make a line 1 pixel in LENGTH. We are already able to draw lines that are
one pixel wide.

So again, the issue is how to draw a line that is one pixel in length?

Dave

"Herfried K. Wagner [MVP]" wrote:

> "Dave Leach" <(E-Mail Removed)> schrieb:
> >I am writing a Windows Forms application graphing routine using VS.NET
> >2003,
> > Visual C# and .NET Framework 1.1.
> >
> > The Graphics.DrawLine(Pen,int,int,int,int) method seems to work okay
> > unless
> > the desired line being drawn is only one pixel long (horizontally). I
> > have
> > not found a way to get a horizontal line of only one pixel to be drawn. I
> > either get no line or a two pixel line.

>
> <URL:http://www.bobpowell.net/single_pixel_lines.htm>
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>
>
>

 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      8th Dec 2005
"Dave Leach" <(E-Mail Removed)> schrieb:
> The link provided in the reply below deals with line width. I am asking
> how
> to make a line 1 pixel in LENGTH. We are already able to draw lines that
> are
> one pixel wide.
>
> So again, the issue is how to draw a line that is one pixel in length?


See:

<URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/9492fe4a2b69530a>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
=?Utf-8?B?RGF2ZSBMZWFjaA==?=
Guest
Posts: n/a
 
      9th Dec 2005
If this is how a 1 pixel "line" is drawn does no one else think that the
Graphics.DrawLine method is defective? Shouldn't the method support drawing
lines from 1 to N pixels in length?

Dave

"Herfried K. Wagner [MVP]" wrote:

> "Dave Leach" <(E-Mail Removed)> schrieb:
> > The link provided in the reply below deals with line width. I am asking
> > how
> > to make a line 1 pixel in LENGTH. We are already able to draw lines that
> > are
> > one pixel wide.
> >
> > So again, the issue is how to draw a line that is one pixel in length?

>
> See:
>
> <URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/9492fe4a2b69530a>
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>
>
>

 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      9th Dec 2005
"Dave Leach" <(E-Mail Removed)> schrieb:
> If this is how a 1 pixel "line" is drawn does no one else think that the
> Graphics.DrawLine method is defective? Shouldn't the method support
> drawing
> lines from 1 to N pixels in length?


'DrawLine' doesn't draw n pixels, it draws n units.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to draw a one-pixel line?? Loren Pechtel Microsoft C# .NET 33 7th Nov 2009 01:52 PM
Displaying pixel in a bitmap as a rectangular pixel Piotrekk Microsoft C# .NET 4 20th Aug 2007 06:39 PM
how to draw somthing (e.g. a line or pixel) on a dialog box? sadegh Microsoft VC .NET 0 6th May 2007 09:49 AM
processing huge bitmap pixel by pixel performance Buthrakaur Microsoft Dot NET Compact Framework 3 8th Jan 2007 09:56 AM
How to draw a one pixel line =?Utf-8?B?U29uaWM=?= Microsoft Dot NET 1 1st Aug 2006 02:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:46 PM.