PC Review


Reply
Thread Tools Rate Thread

Drawing a single pixel

 
 
Rob T
Guest
Posts: n/a
 
      23rd Feb 2005
This seems like a really stupid question, but here it goes........

is there a command to draw a single pixel?

The closest I can get is to draw a line that is 2 pixels wide, or do create
another image that's 1x1 with the color of the pixel, then do a DrawImage to
insert that image into the 'master' image...which seems like a huge waste!

Thanks.


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      23rd Feb 2005
"Rob T" <(E-Mail Removed)> schrieb:
> [Drawing a single pixel]


\\\
Private Sub Form1_Paint( _
ByVal sender As Object, _
ByVal e As PaintEventArgs _
) Handles MyBase.Paint
e.Graphics.FillRectangle( _
Brushes.Red, _
New Rectangle(100, 100, 1, 1) _
)
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
 
Reply With Quote
 
Bob Powell [MVP]
Guest
Posts: n/a
 
      23rd Feb 2005
See the GDI+ FAQ.

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

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

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

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





"Rob T" <(E-Mail Removed)> wrote in message
news:%23g2%(E-Mail Removed)...
> This seems like a really stupid question, but here it goes........
>
> is there a command to draw a single pixel?
>
> The closest I can get is to draw a line that is 2 pixels wide, or do
> create another image that's 1x1 with the color of the pixel, then do a
> DrawImage to insert that image into the 'master' image...which seems like
> a huge waste!
>
> Thanks.
>



 
Reply With Quote
 
Bob Powell [MVP]
Guest
Posts: n/a
 
      23rd Feb 2005
What happens if the page units are set to inches? ;-)

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

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

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

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





"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "Rob T" <(E-Mail Removed)> schrieb:
>> [Drawing a single pixel]

>
> \\\
> Private Sub Form1_Paint( _
> ByVal sender As Object, _
> ByVal e As PaintEventArgs _
> ) Handles MyBase.Paint
> e.Graphics.FillRectangle( _
> Brushes.Red, _
> New Rectangle(100, 100, 1, 1) _
> )
> End Sub
> ///
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      23rd Feb 2005
Bob,

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> schrieb:
> What happens if the page units are set to inches? ;-)


I read the article in your FAQ now and learned something new :-).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
 
Reply With Quote
 
Rob T
Guest
Posts: n/a
 
      23rd Feb 2005
Good trick with the -1 for the pen width. Drawing the rectangle worked
fine. you still can't draw a line unless it's more than one pixel long:
objGraphics.DrawLine(New Pen(Color.Black, -1), New Point(5,5), New
Point(5,5)) Doesn't work.

No big deal if the FillRectangle works.......

Thanks guys!

BTW Bob. I adapted your c# graphics editor into a little VB app this week.
It's a bit different from yours now, I you had some good trick in yours that
I was able to adapt. Thanks!


"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Bob,
>
> "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> schrieb:
>> What happens if the page units are set to inches? ;-)

>
> I read the article in your FAQ now and learned something new :-).
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>



 
Reply With Quote
 
Bob Powell [MVP]
Guest
Posts: n/a
 
      23rd Feb 2005
Excellent. I love it when people use my code!


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

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

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

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





"Rob T" <(E-Mail Removed)> wrote in message
news:%23%(E-Mail Removed)...
> Good trick with the -1 for the pen width. Drawing the rectangle worked
> fine. you still can't draw a line unless it's more than one pixel long:
> objGraphics.DrawLine(New Pen(Color.Black, -1), New Point(5,5), New
> Point(5,5)) Doesn't work.
>
> No big deal if the FillRectangle works.......
>
> Thanks guys!
>
> BTW Bob. I adapted your c# graphics editor into a little VB app this
> week. It's a bit different from yours now, I you had some good trick in
> yours that I was able to adapt. Thanks!
>
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Bob,
>>
>> "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> schrieb:
>>> What happens if the page units are set to inches? ;-)

>>
>> I read the article in your FAQ now and learned something new :-).
>>
>> --
>> M S Herfried K. Wagner
>> M V P <URL:http://dotnet.mvps.org/>
>> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

>
>



 
Reply With Quote
 
Steve McLellan
Guest
Posts: n/a
 
      23rd Feb 2005
How different the A-Team could have been if that had been Hannibal's
motto...

"> Excellent. I love it when people use my code!
>
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>



 
Reply With Quote
 
Rob T
Guest
Posts: n/a
 
      24th Feb 2005
Careful....you're showing you age!

"Steve McLellan" <sjm AT fixerlabs DOT com> wrote in message
news:(E-Mail Removed)...
> How different the A-Team could have been if that had been Hannibal's
> motto...
>
> "> Excellent. I love it when people use my code!
>>
>>
>> --
>> Bob Powell [MVP]
>> Visual C#, System.Drawing
>>

>
>



 
Reply With Quote
 
Steve McLellan
Guest
Posts: n/a
 
      24th Feb 2005
I don't know... it was a long running series :-)

"Rob T" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Careful....you're showing you age!
>
> "Steve McLellan" <sjm AT fixerlabs DOT com> wrote in message
> news:(E-Mail Removed)...
>> How different the A-Team could have been if that had been Hannibal's
>> motto...
>>
>> "> Excellent. I love it when people use my code!
>>>
>>>
>>> --
>>> Bob Powell [MVP]
>>> Visual C#, System.Drawing
>>>

>>
>>

>
>



 
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
Two questions - drawing a single pixel and writing vertically C Microsoft VB .NET 6 18th Sep 2010 08:57 PM
Drawing A Pixel Abby Brown Microsoft C# .NET 6 28th Jul 2009 05:35 PM
Drawing a simple pixel to the foreground Carsten Schmitt Microsoft C# .NET 4 24th Oct 2006 07:22 PM
Drawing a single pixel Rob T Microsoft VB .NET 9 24th Feb 2005 02:22 PM
Copy pixel data from System.Drawing.Bitmap Dennis Myrén Microsoft C# .NET 1 24th Aug 2004 03:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:19 AM.