R – Efficient way to swap any given two colors in image using .NET Compact Framework

compact-frameworkgraphicswindows-mobile

Is there an efficient way to take and image and be able to replace a given color with another given color using .NET Compact Framework?

For example, to replace white with black or vice versa?

Best Answer

Using the Imaging API, you can get an IBitmapImage, lock the image data bits, loop over the bits via the BitmapData* and change the pixels of your choice.

Edit: I just noticed the NETCF tag, but I leave this answer for reference.