
Draw a single pixel dotOnce again GDI+ resolution independence jumps up to bite you in the soft and tender parts. There is no PlotPixel function in GDI+ that allows you to draw directly on the GDI Graphics surface as we used to be able to in GDI.. To draw a dot of a specific colour on your screen you must resort to the following shenanigans.
The following example assume that they are in a Paint event handler. [C#] Bitmap bm=new Bitmap(1,1); bm.SetPixel(0,0,Color.Red); e.Graphics.DrawImageUnscaled(bm,<xPosition>,<yPosition>); [VB] Dim bm as new Bitmap(1,1) bm.SetPixel(0,0,Color.Red) e.Graphics.DrawImageUnscaled(bm,<xPosition>,<yPosition>) Remember that you don't have to create the bitmap every time you draw it. You can store a 1 pixel bitmap for the lifetime of the application and just copy it over and over. |
Copyright Robert W. Powell 2003, All rights reserved