Color Modes

MagickCore, C API: Get or Set Image Pixels

Cache



AcquirePixelCacheNexus

AcquirePixelCacheNexus() allocates the NexusInfo structure.

The format of the AcquirePixelCacheNexus method is:

NexusInfo **AcquirePixelCacheNexus(const size_t number_threads)

A description of each parameter follows:

number_threads
the number of nexus threads.

AcquirePixelCachePixels

AcquirePixelCachePixels() returns the pixels associated with the specified image.

The format of the AcquirePixelCachePixels() method is:

const void *AcquirePixelCachePixels(const Image *image,
  MagickSizeType *length,ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
length
the pixel cache length.
exception
return any errors or warnings in this structure.

GetAuthenticIndexQueue

GetAuthenticIndexQueue() returns the authentic black channel or the colormap indexes associated with the last call to QueueAuthenticPixels() or GetVirtualPixels(). NULL is returned if the black channel or colormap indexes are not available.

The format of the GetAuthenticIndexQueue() method is:

IndexPacket *GetAuthenticIndexQueue(const Image *image)

A description of each parameter follows:

image
the image.

GetAuthenticPixelQueue

GetAuthenticPixelQueue() returns the authentic pixels associated with the last call to QueueAuthenticPixels() or GetAuthenticPixels().

The format of the GetAuthenticPixelQueue() method is:

PixelPacket *GetAuthenticPixelQueue(const Image image)

A description of each parameter follows:

image
the image.

GetAuthenticPixels

GetAuthenticPixels() obtains a pixel region for read/write access. If the region is successfully accessed, a pointer to a PixelPacket array representing the region is returned, otherwise NULL is returned.

The returned pointer may point to a temporary working copy of the pixels or it may point to the original pixels in memory. Performance is maximized if the selected region is part of one row, or one or more full rows, since then there is opportunity to access the pixels in-place (without a copy) if the image is in memory, or in a memory-mapped file. The returned pointer must *never* be deallocated by the user.

Pixels accessed via the returned pointer represent a simple array of type PixelPacket. If the image type is CMYK or if the storage class is PseduoClass, call GetAuthenticIndexQueue() after invoking GetAuthenticPixels() to obtain the black color component or colormap indexes (of type IndexPacket) corresponding to the region. Once the PixelPacket (and/or IndexPacket) array has been updated, the changes must be saved back to the underlying image using SyncAuthenticPixels() or they may be lost.

The format of the GetAuthenticPixels() method is:

PixelPacket *GetAuthenticPixels(Image *image,const ssize_t x,
  const ssize_t y,const size_t columns,const size_t rows,
  ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
x,y,columns,rows
These values define the perimeter of a region of pixels.
exception
return any errors or warnings in this structure.

GetOneAuthenticPixel

GetOneAuthenticPixel() returns a single pixel at the specified (x,y) location. The image background color is returned if an error occurs.

The format of the GetOneAuthenticPixel() method is:

MagickBooleanType GetOneAuthenticPixel(const Image image,const ssize_t x,
  const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
x,y
These values define the location of the pixel to return.
pixel
return a pixel at the specified (x,y) location.
exception
return any errors or warnings in this structure.

GetOneVirtualMagickPixel

GetOneVirtualMagickPixel() returns a single pixel at the specified (x,y) location. The image background color is returned if an error occurs. If you plan to modify the pixel, use GetOneAuthenticPixel() instead.

The format of the GetOneVirtualMagickPixel() method is:

MagickBooleanType GetOneVirtualMagickPixel(const Image image,
  const ssize_t x,const ssize_t y,MagickPixelPacket *pixel,
  ExceptionInfo exception)

A description of each parameter follows:

image
the image.
x,y
these values define the location of the pixel to return.
pixel
return a pixel at the specified (x,y) location.
exception
return any errors or warnings in this structure.

GetOneVirtualMethodPixel

GetOneVirtualMethodPixel() returns a single pixel at the specified (x,y) location as defined by specified pixel method. The image background color is returned if an error occurs. If you plan to modify the pixel, use GetOneAuthenticPixel() instead.

The format of the GetOneVirtualMethodPixel() method is:

MagickBooleanType GetOneVirtualMethodPixel(const Image image,
  const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
  const ssize_t y,Pixelpacket *pixel,ExceptionInfo exception)

A description of each parameter follows:

image
the image.
virtual_pixel_method
the virtual pixel method.
x,y
These values define the location of the pixel to return.
pixel
return a pixel at the specified (x,y) location.
exception
return any errors or warnings in this structure.

GetOneVirtualPixel

GetOneVirtualPixel() returns a single virtual pixel at the specified (x,y) location. The image background color is returned if an error occurs. If you plan to modify the pixel, use GetOneAuthenticPixel() instead.

The format of the GetOneVirtualPixel() method is:

MagickBooleanType GetOneVirtualPixel(const Image image,const ssize_t x,
  const ssize_t y,PixelPacket *pixel,ExceptionInfo exception)

A description of each parameter follows:

image
the image.
x,y
These values define the location of the pixel to return.
pixel
return a pixel at the specified (x,y) location.
exception
return any errors or warnings in this structure.

GetVirtualIndexQueue

GetVirtualIndexQueue() returns the virtual black channel or the colormap indexes associated with the last call to QueueAuthenticPixels() or GetVirtualPixels(). NULL is returned if the black channel or colormap indexes are not available.

The format of the GetVirtualIndexQueue() method is:

const IndexPacket *GetVirtualIndexQueue(const Image *image)

A description of each parameter follows:

image
the image.

GetVirtualPixelQueue

GetVirtualPixelQueue() returns the virtual pixels associated with the last call to QueueAuthenticPixels() or GetVirtualPixels().

The format of the GetVirtualPixelQueue() method is:

const PixelPacket *GetVirtualPixelQueue(const Image image)

A description of each parameter follows:

image
the image.

GetVirtualPixels

GetVirtualPixels() returns an immutable pixel region. If the region is successfully accessed, a pointer to it is returned, otherwise NULL is returned. The returned pointer may point to a temporary working copy of the pixels or it may point to the original pixels in memory. Performance is maximized if the selected region is part of one row, or one or more full rows, since there is opportunity to access the pixels in-place (without a copy) if the image is in memory, or in a memory-mapped file. The returned pointer must *never* be deallocated by the user.

Pixels accessed via the returned pointer represent a simple array of type PixelPacket. If the image type is CMYK or the storage class is PseudoClass, call GetAuthenticIndexQueue() after invoking GetAuthenticPixels() to access the black color component or to obtain the colormap indexes (of type IndexPacket) corresponding to the region.

If you plan to modify the pixels, use GetAuthenticPixels() instead.

Note, the GetVirtualPixels() and GetAuthenticPixels() methods are not thread- safe. In a threaded environment, use GetCacheViewVirtualPixels() or GetCacheViewAuthenticPixels() instead.

The format of the GetVirtualPixels() method is:

const PixelPacket *GetVirtualPixels(const Image *image,const ssize_t x,
  const ssize_t y,const size_t columns,const size_t rows,
  ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
x,y,columns,rows
These values define the perimeter of a region of pixels.
exception
return any errors or warnings in this structure.

QueueAuthenticPixels

QueueAuthenticPixels() queues a mutable pixel region. If the region is successfully initialized a pointer to a PixelPacket array representing the region is returned, otherwise NULL is returned. The returned pointer may point to a temporary working buffer for the pixels or it may point to the final location of the pixels in memory.

Write-only access means that any existing pixel values corresponding to the region are ignored. This is useful if the initial image is being created from scratch, or if the existing pixel values are to be completely replaced without need to refer to their preexisting values. The application is free to read and write the pixel buffer returned by QueueAuthenticPixels() any way it pleases. QueueAuthenticPixels() does not initialize the pixel array values. Initializing pixel array values is the application's responsibility.

Performance is maximized if the selected region is part of one row, or one or more full rows, since then there is opportunity to access the pixels in-place (without a copy) if the image is in memory, or in a memory-mapped file. The returned pointer must *never* be deallocated by the user.

Pixels accessed via the returned pointer represent a simple array of type PixelPacket. If the image type is CMYK or the storage class is PseudoClass, call GetAuthenticIndexQueue() after invoking GetAuthenticPixels() to obtain the black color component or the colormap indexes (of type IndexPacket) corresponding to the region. Once the PixelPacket (and/or IndexPacket) array has been updated, the changes must be saved back to the underlying image using SyncAuthenticPixels() or they may be lost.

The format of the QueueAuthenticPixels() method is:

PixelPacket *QueueAuthenticPixels(Image *image,const ssize_t x,
  const ssize_t y,const size_t columns,const size_t rows,
  ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
x,y,columns,rows
These values define the perimeter of a region of pixels.
exception
return any errors or warnings in this structure.

SetPixelCacheVirtualMethod

SetPixelCacheVirtualMethod() sets the "virtual pixels" method for the pixel cache and returns the previous setting. A virtual pixel is any pixel access that is outside the boundaries of the image cache.

The format of the SetPixelCacheVirtualMethod() method is:

VirtualPixelMethod SetPixelCacheVirtualMethod(const Image *image,
  const VirtualPixelMethod virtual_pixel_method)

A description of each parameter follows:

image
the image.
virtual_pixel_method
choose the type of virtual pixel.

SyncAuthenticPixels

SyncAuthenticPixels() saves the image pixels to the in-memory or disk cache. The method returns MagickTrue if the pixel region is flushed, otherwise MagickFalse.

The format of the SyncAuthenticPixels() method is:

MagickBooleanType SyncAuthenticPixels(Image *image,
  ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
exception
return any errors or warnings in this structure.