# ImageMagick PixelPacket Structure

The PixelPacket structure is used to represent DirectClass color pixels in ImageMagick. If the image is indicated as a PseudoClass image, its DirectClass representation is only valid immediately after calling SyncImage(). If an image is set as PseudoClass and the DirectClass representation is modified, the image should then be set as DirectClass. Use QuantizeImage() to restore the PseudoClass colormap if the DirectClass representation is modified.

The members of the PixelPacket structure are shown in the following table:

PixelPacket Structure Members
Member | Type | Interpretation
RGBColorspace (4) | RGBColorspace + matte (4) | CMYKColorspace
red | Quantum | Red | Red | Cyan
green | Quantum | Green | Green | Magenta
blue | Quantum | Blue | Blue | Yellow
opacity | Quantum | Opacity | Opacity | Black
index | Quantum | Index into image colormap(2) | Index into image colormap(2) | Index into image colormap(2)

Notes:

1. Quantum is an unsigned short (MaxRGB=65535) if ImageMagick is built using -DQuantumLeap. Otherwise it is an unsigned char (MaxRGB=255).
2. RGB index is only valid for PseudoClass images (class=PseudoClass).
3. SyncImage() may be used to synchronize the DirectClass color pixels to the current PseudoClass colormap.
4. For pixel representation purposes, all colorspaces are treated like RGBColorspace except for CMYKColorspace.

Image manipulation software that works like magic.