Yes, if you really need to access individual pixels, the only reasonable way to go is using
System.Drawing.Bitmap.LockBits
:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits.aspx[
^].
Now, if you are creating the instance of
Graphics
somewhere using its constructor and draw, the graphics will not persist on screen. You need to override
System.Windows.Graphics.Control.OnPaint
or handle the event
System.Windows.Graphics.Control.Paint
and do all your rendering in the handler, using the instance of
Graphics
passed to the handler in the event arguments. Please see my past answers:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[
^] (the background is explained here),
Drawing Lines between mdi child forms[
^],
capture the drawing on a panel[
^],
How to speed up my vb.net application?[
^].
—SA