PixelPacket color format

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
nicolas1

PixelPacket color format

Post by nicolas1 »

Hello,

What is format and alignment of data (PixelPacket ) accessed by AcquireImagePixels? I have some problems with transparency using buffer returned by AcquireImagePixels. Areas with transparent color is black. (Q==8)

regards,
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: PixelPacket color format

Post by magick »

The PixelPacket structure is defined in magick/pixel.h and is defined as follows:

Code: Select all

typedef struct _PixelPacket
{
#if defined(MAGICKCORE_WORDS_BIGENDIAN)
  Quantum
    red,
    green,
    blue,
    opacity;
#else
  Quantum
    blue,
    green,
    red,
    opacity;
#endif
} PixelPacket;
Where Quantum is unsigned char for the Q8 version of ImageMagick.
nicolas1

Re: PixelPacket color format

Post by nicolas1 »

Is it possible to change order of pixelpacket components? It is necessary to use buffer in third-party software without making conversion.
Is it possible to make opacity as 255-opacity (255 means maximum component value)?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: PixelPacket color format

Post by magick »

The pixel component order does not matter to ImageMagick. Change it in the header and compile / install. Unfortunately the only way to get / set alpha is with (QuantumRange - opacity).
Post Reply