Thread: Draw single pixel

  1. #1
    Registered User
    Join Date
    Dec 2007

    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
    Okay, I found a solution. I use FillRectangle of the Graphics class :

                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
    Oregon, USA
    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, 07: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, 01:34 PM
  4. Drawing a single pixel
    By SMB3Master in forum C++ Programming
    Replies: 14
    Last Post: 05-26-2003, 06:17 AM