first.cpp:726:38: error: member reference base type 'const MagickCore::Quantum' (aka 'const float') is not a structure or union
unsigned char r = pixelsArr[ i ].red * 255 / QuantumRange;
~~~~~~~~~~~~~~^~~~
first.cpp:727:38: error: member reference base type 'const MagickCore::Quantum' (aka 'const float') is not a structure or union
unsigned char g = pixelsArr[ i ].redQuantum * 255 / QuantumRange;
How to convert this float (which called Quantum) to R/G/B components?
"Quantum" is a scalar type, a simple number with no elements. Depending on your build, it is defined as an int, float, double or whatever. From your error message, it is a float.
snibgo wrote: ↑2017-03-31T19:15:26-07:00
getConstPixels() is declared in Image.h. It returns "PixelPacket *", which is not the same thing as "Quantum *".
Ah, you are using v7? getConstPixels() changed from v6. In v6, it returns PixelPacket*. In v7, it returns Quantum*.
When asking questions, please always state the version of IM you are using.
Sorry, I don't use Magick++ or MacickWand in v7. But you can see how getConstPixels is used, by an example in Image.cpp. You can call GetPixelInfoPixel to convert the returned Quantum* to an object of type PixelInfo.
The type PixelInfo is defined in MagickCore\pixel.h. This has element red, green, blue and many others.