How to change color of images in C# Application

Sajjad Arif Gul - April 3, 2016 - 5 comments

This C# Tutorial explains "How to edit any image or picture in C#?". This application will change Image colors by using System.Drawing.Imaging; Library. Apply general color tones to an image in this application. You can Download this application with its visual studio files.

Image Attributes in C#

In this application use the scroll bars to select a target color. Moving the image’s colors towards the target color may change the image’s overall brightness, so the program also includes a brightness scroll bar you can use to adjust the result. The code divides the brightness value by 128 to get a brightness scaling factor. The scroll bar can tackle values between 0 and 255 so this scale factor ranged between 0 and roughly 2. Next the program takes the red, green and blue components of the target color and divides them by 255 to get a value between 0 and 1. It then scales the results by the brightness scale factor. The program plugs the resulting color component scale factors into the ColorMatrix. Having created the ColorMatrix object, the code creates an ImageAttributes object and uses it to draw the image. This method is extremely fast so you can drag the scroll bars back and forth to change the result in real time. This gives a sense of how fast drawing with an ImageAttributes object is.

Source Code:

Check Its source Code


Check Output Video


Download this application in with visual studio files.

Author avatar

Sajjad Arif Gul
Hi! I am Sajjad Arif Gul, Software Engineer, Web & Mobile Developer from Karachi Pakistan. I love sharing my knowledge that could possibly help someone’s life in some capacity. Happy Coding.

Related posts


  1. Sajjad! if you have put an option for selecting an image from computer to edit it, it would have helped alot.

  2. i will work on this app after my exams. :p

  3. Thanks Buddy. Can you give me code of putting frame on image which we are trying to edit ?

  4. you can create your own Photoshop application this way . by the way thanks for this. Can u give me same code for ?

  5. Awesome. plz create a setup of this application so i can use it for my facebook profile pictures upload.

Post a Comment

Your email address will not be published. Required fields are marked *