Please see my comment to the question.
One of the way to perform necessary calculations is using
System.Drawing
, more exactly:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits.aspx[
^].
There are some code samples on the pages of each of these methods, just to understand how to use them. Most important thing here is not to use
GetPixel/SetPixel
as those method would work prohibitively slowly for your purpose.
—SA