Page 1 of 1

Scaling signed intergers

Posted: 2007-12-06T07:15:14-07:00
by seanburke1979
How does IM handle signed integers in the PixelPacket structure?* When I am reading a signed integer with ReadBlob, should I subtract a factor of (1 << (depth - 1)) before loading into the pixel packet structure, or does this happen further down the line? My intuition tells me that IM stores it as an unsigned integer and GetImagePixels is smart enough to correct if the "QuantumFormat" property is set to "SignedQuantumFormat." Is this correct?

* - For a non-HDRI build.

Sean

Re: Scaling signed intergers

Posted: 2007-12-06T07:28:32-07:00
by magick
We have a number of macros to handle assigning values to a pixel component. You probably want to use RoundToQuantum() in magick/quantum.h. Other useful macros are available in magick/quantum-private.h.