Scaling signed intergers

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
seanburke1979

Scaling signed intergers

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

Re: Scaling signed intergers

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