GDI+ Replace Colour

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

In an image, I want to replace a specific colour with a different colour.
Can this be done ?

Failing this, is it possible to overlay a transparent colour onto an image
so that a given colour in that image "appears" like another target colour ?
(a bit like mixing paints).
 
JezB said:
In an image, I want to replace a specific colour with a different colour.
Can this be done ?

Yes. 'Bitmap.GetPixel', 'Bitmap.SetPixel', for example.
 
The ImageAttributes class enables you to set a colour remap table that uses
a ColorMap array.

You should be able to map colour X to another colour but remember that this
will only be for that single colour. If there is any subtle tonal variation
in the bitmap, such as if it is a photograph or even it it was previously
saved as a JPEG image, this method will be very difficult to use.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Back
Top