This project has moved. For the latest updates, please go here.

Index color and RGB color

Sep 4, 2014 at 1:08 PM
I was working on an app which replace rgb values in a pcx using the below code

using (MagickImage image = new MagickImage(@"E:\Development\DOTNET\PCXEditor\RGBEditor\18975253ee.pcx")) { MagickColor target = new MagickColor(128, 118, 118);
MagickColor fill = new MagickColor(100, 105, 110);

image.Opaque(target, fill);

image.Write(@"E:\Development\DOTNET\PCXEditor\RGBEditor\1897525311-changed.pcx"); } The problem i was facing is the output PCX file is in RGB mode , I need this to be in INDEX color mode Any help is greatly Appreciated
Coordinator
Sep 4, 2014 at 1:37 PM
Can you add a link to your image? Feel free to contact me through CodePlex if you don't want to publicly share your image.
Sep 5, 2014 at 9:13 AM
Attached are the two links for the same pcx file before and after conversion.

http://school2.millinfo.net/19006477-BeforeConversion.pcx
http://school2.millinfo.net/19006477-AfterConversion.pcx
Coordinator
Sep 5, 2014 at 9:24 AM
Your links don't work here. Can you post your images somewhere else or fix your links?
Coordinator
Sep 7, 2014 at 7:17 AM
It seems I misunderstood your problem. Can you post your code in a code block (```C#) next time? If you want your image to be indexed you should set the ClassType to Pseudo:
using (MagickImage image = new MagickImage(@"E:\Development\DOTNET\PCXEditor\RGBEditor\18975253ee.pcx"))
{
  MagickColor target = new MagickColor(128, 118, 118);
  MagickColor fill = new MagickColor(100, 105, 110);

  image.Opaque(target, fill);

  image.ClassType = ClassType.Pseudo; // Or use the 'Quantize' method if you want more control.

  image.Write(@"E:\Development\DOTNET\PCXEditor\RGBEditor\1897525311-changed.pcx");
}