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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tadpole

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

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post 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).
tadpole

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

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post 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.
Post Reply