Click here to Skip to main content
15,890,376 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've a black and white image with 32-bpp but I want to change its color to some specific like red or green...I searched and tested many .net applications but none of 'em could do that. So any idea ?
Posted

There is no real way to do this accurately, a greyscale image has discarded color info. You can do a color wash easy enough, my image processing articles show how to do that, but you won't turn greyscale back into real, accurate color.
 
Share this answer
 
Comments
Xmen Real 7-Jul-10 3:20am    
I have read all your articles about image processing but they all change color of colored images.
Xmen Real 7-Jul-10 3:25am    
Got an idea, see my answer and thanks for reply. Now I will have to read your articles again ;)
Xmen Real 7-Jul-10 3:59am    
Can you tell me how can I multiply colors ? Like Multiply effect in Photoshop
NOTE : This is just safe code and will be slow. I will change it to unsafe later but the following code is just for showing the idea ;).

void ChangeColor(Bitmap image)
{
    for (int x = 0; x < image.Width; x++)
    {
        for (int y = 0; y < image.Height; y++)
        {
            Color c = image.GetPixel(x, y);
            Color nc = Color.FromArgb(c.A, c.R, 0, 0);
            image.SetPixel(x, y, nc);
        }
    }
}
 
Share this answer
 

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