Page 1 of 1

Is the ColorRGB class in Magick++ really that limited?

Posted: 2008-01-22T12:01:14-07:00
by tadpole
I'm interested in using the Magick++ API for a simple command line utility. To get and set the color of a pixel, you must specify a number between 0.0 and 1.0, such as ColorRGB(0.5,0.5,1). This offers only 11 different values each. Is there a way to specify the exact 24-bit value for a pixel, i.e. three numbers between 0 and 255?

Thanks.

Re: Is the ColorRGB class in Magick++ really that limited?

Posted: 2008-01-22T12:16:32-07:00
by magick
Simply normalize the color values. For an RGB value of 114,34,251, use ColorRGB(114/255.0,34/255.0,251/255.0).

Re: Is the ColorRGB class in Magick++ really that limited?

Posted: 2008-01-22T13:10:13-07:00
by tadpole
So do you mean that it accepts decimals beyond the tenths place, or does it truncate and get an approximated color? A division like 144/255 gives you about 0.4470588235, but even that may not get the exact color because it's an irrational number.

Re: Is the ColorRGB class in Magick++ really that limited?

Posted: 2008-01-22T14:14:41-07:00
by magick
We use normalized color values because ImageMagick can be built at different internal depths. The default is Q16 but some folks use Q8 or Q32. Your normalized color value is automatically scaled to whatever depth your version of ImageMagick was built at.