Effect of MagickSetImageColormapColor?

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Effect of MagickSetImageColormapColor?

Post by el_supremo » 2006-10-14T15:14:29-07:00

I'm using windows binary installation of 6.2.9-8.
I've written a C program which uses MagickWand to extract part of a GIF image. It reads in the GIF (which has 64 colours), changes it to a grayscale image and then quantizes it to 16 colours. I then use MagickSetImageColormapColor to force the first colour in the map to pure black and the last colour in the map to pure white. The program then crops the image and writes it out.
If I do a histogram of the image before setting the map colours, the first colour index is rgb(2,2,2). If I do a histogram of the image after setting colour index zero to black, the histogram still reports that the colour is rgb(2,2,2).
The file when written to disk has the first colour set to pure black.

This is the sequence of events:

Code: Select all

identify of the original image reports:
293.gif GIF 300x918 300x918+0+0 PseudoClass 64c 8-bit 46.0059kb 

in the program:

// Histogram shows 64 colours. Index 0 is rgb(0,0,0)
	MagickSetImageType(m_wand, GrayscaleType);
// Histogram shows 60 colours. Index 0 is rgb(0,0,0)
	MagickQuantizeImage(m_wand, 16, GRAYColorspace, 0 , 0, 0);
// Histogram shows 16 colours. Index 0 is rgb(2,2,2)

// Now force index 0 to black and last index to white
// nc is the number of colours returned by MagickGetImageHistogram
	p_wand = NewPixelWand();
	p_wand = DestroyPixelWand(p_wand);

// Histogram shows 16 colours. Index 0 is still rgb(2,2,2)

// Crop the image, fix up virtual page in the GIF and write to a file
// Histogram shows 16 colours. Index 0 is still rgb(2,2,2) in memory

// Looking at the output image (atest.gif) with PSP 9 shows that colour 0 is rgb(0,0,0)
So it would seem that the colours in the image in memory are directly affected by MagickSetImageType and MagickQuantizeImage but that MagickSetImageColormapColor only takes effect when the image is written to disk.
Why doesn't MagickSetImageColormapColor take immediate effect like the others and how do I make it do that?


User avatar
Site Admin
Posts: 10908
Joined: 2003-05-31T11:32:55-07:00

Post by magick » 2006-10-14T15:48:00-07:00

We have a patch for the problem you reported in ImageMagick 6.3.0-1 Beta available sometime tommorrow. Thanks for alerting us to the bug.

Post Reply