This might not be exactly what you're looking for, but it might be useful to you if you're looking for performance in doing some pixel operations .. and I thought it would be worth mentioning it here.
Since you've already loaded the image with Image imageIn
you can actually directly access the image buffer without doing any copies hence saving time and resources :
public void DoStuffWithImage(System.Drawing.Image imageIn)
{
// Lock the bitmap's bits.
Rectangle rect = new Rectangle(0, 0, imageIn.Width, imageIn.Height);
System.Drawing.Imaging.BitmapData bmpData =
imageIn.LockBits(rect, System.Drawing.Imaging.ImageLockMode.Read,
imageIn.PixelFormat);
// Access your data from here this scan0,
// and do any pixel operation with this imagePtr.
IntPtr imagePtr = bmpData.Scan0;
// When you're done with it, unlock the bits.
imageIn.UnlockBits(bmpData);
}
For some more information, look at this MSDN page
ps: This bmpData.Scan0 will of course give you only access to the pixel payload. aka, no headers !
imageIn.PixelFormat
property. – Vanguard