First of all, don't use
GetPixel
or
SetPixel
. This would be prohibitively slow, unless you want to retouch just a few pixels.
You need to use one of the
System.Drawing.Bitmap.LockBits
methods, please see:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits.aspx[
^],
see the code sample here:
http://msdn.microsoft.com/en-us/library/5ey6h79d.aspx[
^].
What you do is: get raw byte representation of bitmap data and modify the bytes directly. The layout of the bytes and bits in this data and interpretation of the data in the bit color and (transparency, it it is applicable) depends on pixel format; please see
System.Drawing.Imaging.PixelFormat
,
http://msdn.microsoft.com/en-us/library/3z132tat.aspx[
^].
You can save the bitmap using one of the
System.Drawing.Bitmap.Save
methods.
This is a pretty good short article explaining how it works:
http://www.bobpowell.net/lockingbits.htm[
^].
Please see my comments to the question about "delete pixel"; there is no such thing. You can only modify pixel properties such as color and transparency where transparency is supported by the pixel format you use.
—SA