The Reslts

Here is a test image.

And here are the results of setting darkenAmount to 0.5.

How it Works

This block of code iterates over the images width and height looking at each pixel. For each pixel it calls the function DarkenColor. DarkenColor calculates the amount of “darkenning” to apply for each of the 3 RGB elements and returns a new Color object.

The LockedBits Class

You need to have the LockedBits class in your project in order to use this code. You can learn about it in our How to Load an Image in C# guide.

Other C# Image Processing Guides

You might be interested in some of our other C# Image Processing Guides.

Categories

About Efundies

The goal of efundies.com is to provide the Internet with a collection of fun, free, electronics projects and advice.
Jason Bauer is an owner and programmer for Portforward.com. He's allergic to twitter and facebook, but you can find more of his articles in the Guides section.