How to manipulate images at the pixel level in C#

Kamil Zadora picture Kamil Zadora · Oct 10, 2008 · Viewed 93.9k times · Source

How do I manipulate images at the pixel level in C#?

I need to be able to read/modify each bitmap pixel RGB values separately.

A code sample would be appreciated.

Answer

Marc Gravell picture Marc Gravell · Oct 10, 2008

If you want speed, then LockBits. See here for a good walkthrough by Bob Powell. If you just want to edit a few, then GetPixel/SetPixel should do what you want.