Convert an Image to Grayscale with Compact Framework on Windows Mobile

May 19, 2009 — Leave a comment

I’m working with a customer and they have a requirement to convert an image to gray scale.  Using direct pixel access method discussed here and extension methods it’s pretty straight forward.

Basically all we are doing is getting direct access to the pixel data using a pointer and modifying the RGB values with the parameters sent by the user.  In our main code where we want to convert the image, lets say we have an image in a PictureBox that we want to convert and store the result in a new PictureBox all we have to do is call one line of code:

Here is a sample of the input/output:


And you can download the source for converting an image to grayscale here

No Comments

Be the first to start the conversation.

Leave a Reply