Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
3.75/5 (4 votes)
See more:
Hi All,

I need to change Colors in an image but like "color balance" in photoshop


I used this code:


C#
Bitmap bmp = new Bitmap(this.BackgroundImage);
for (int x = 0; x < bmp.Width; x++)
{
    for (int y = 0; y < bmp.Height; y++)
    {
          bmp.SetPixel(x, y, Color.Black);
        
    }
}

this.BackgroundImage = bmp;



but the whole colors in my image changed to black...

How can I solve this color balance problem...

Please help.

Thanks in Advance.
Posted
Updated 1-May-17 16:36pm
v2
Comments
Sergey Alexandrovich Kryukov 14-Jun-11 1:51am    
There are many different operations for re-touching color balance producing different results based on different data. Which one do you need? All of them?
--SA
version_2.0 14-Jun-11 2:05am    
Please help, I am totally blank about it..

Give me tutorial link for that...

OK, now I see you're using System.Drawing. For performance reasons, never use SetPixel/GetPixel! Use System.Drawing.Bitmap.LockBits. The MSDN help page has a code sample:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx[^].

There are different approaches to color balance. You can implement the simplest approach: a manual balance. You present reg, green and blue sliders; the user adds or reduces the contribution of each; and you retouch each color component one by one for each pixel.

—SA
 
Share this answer
 
I tried answering twice. Even though my answer provided a direct solution to the problem as stated by the OP, it was deleted--twice--marked as not an answer without explanation. So to anyone looking for an actual answer to this problem--you're just out of luck. Thank your fellow site members.
 
Share this answer
 
Comments
Shahin Khorshidnia 13-Jul-17 5:36am    
Hello, if I were you I would not stick to trivial matters.
Shahin Khorshidnia 29-Jul-17 5:30am    
Ok Member 11425182, Thanks for the advice.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900