Draw single pixel

This is a discussion on Draw single pixel within the C# Programming forums, part of the General Programming Boards category; Im new to c#. In c++ I have made a window and painted it with dots and concentric circles, like ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    214

    Draw single pixel

    Im new to c#. In c++ I have made a window and painted it with dots and concentric circles, like a radar PPI screen. Trying to do this in c#, I can't find how to draw a single pixel on the window.

    Also, what should I be drawing on: the form, panel, picturebox...?

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    214
    Okay, I found a solution. I use FillRectangle of the Graphics class :

    Code:
                using (Graphics g = e.Graphics)
                {
                    Pen WhitePen = new Pen(Color.White, 1);
                    System.Drawing.SolidBrush whiteBrush;
                    whiteBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
    
                    Rectangle panelRec = this.ClientRectangle;
                    int x = panelRec.Width / 2;
                    int y = panelRec.Height / 2;
                    g.FillRectangle(whiteBrush, x, y, 1, 1);     
                    
                }
    It draws a white dot in the center of the panel.

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,164
    That would work, but I think using g.DrawLine() would be more efficient.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pixel by pixel graphics, what's the name of this technique?
    By PedroTuga in forum Game Programming
    Replies: 6
    Last Post: 12-14-2012, 06:06 PM
  2. setting a single pixel
    By megafiddle in forum Windows Programming
    Replies: 8
    Last Post: 03-24-2011, 10:38 AM
  3. Single Entry Single Exit
    By robwhit in forum C Programming
    Replies: 5
    Last Post: 11-11-2007, 12:34 PM
  4. Drawing a single pixel
    By SMB3Master in forum C++ Programming
    Replies: 14
    Last Post: 05-26-2003, 06:17 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21