- NAME
- SYNOPSIS
- FUNCTION DESCRIPTIONS

- AcquireCacheView
- AcquireImagePixels
- AcquireOnePixel
- DestroyCacheInfo
- DestroyImagePixels
- GetCacheView
- GetCacheViewIndexes
- GetImagePixels
- GetImageVirtualPixelMethod
- GetIndexes
- GetOnePixel
- GetPixels
- ModifyCache
- OpenCacheView
- ReadStream
- ReferenceCache
- SetCacheView
- SetImagePixels
- SetImageVirtualPixelMethod
- SyncImagePixels
- WriteStream

# NAME

pixel_cache - Image pixel cache (working pixels).

# SYNOPSIS

const PixelPacket * AcquireCacheView( const ViewInfo *view, const long x, const long y, const unsigned long columns, const unsigned long rows, ExceptionInfo *exception );

const PixelPacket * AcquireImagePixels( const Image *image, const long x, const long y, const unsigned long columns, const unsigned long rows, ExceptionInfo *exception );

PixelPacket AcquireOnePixel( const Image image, const long x, const long y, ExceptionInfo exception );

void DestroyCacheInfo( Cache cache );

void DestroyImagePixels( Image *image );

PixelPacket * GetCacheView( ViewInfo *view, const long x, const long y, const unsigned long columns, const unsigned long rows );

IndexPacket * GetCacheViewIndexes( const ViewInfo *view );

PixelPacket * GetImagePixels( Image *image, const long x, const long y, const unsigned long columns, const unsigned long rows );

VirtualPixelMethod GetImageVirtualPixelMethod( const Image *image );

IndexPacket * GetIndexes( const Image *image );

PixelPacket GetOnePixel( const Image image, const long x, const long y );

PixelPacket * GetPixels( const Image image );

MagickPassFail ModifyCache( Image *image );

ViewInfo * OpenCacheView( Image *image );

Image * ReadStream( const ImageInfo *image_info, StreamHandler stream, ExceptionInfo *exception );

Cache ReferenceCache( Cache cache_info );

PixelPacket * SetCacheView( ViewInfo *view, const long x, const long y, const unsigned long columns, const unsigned long rows );

PixelPacket * SetImagePixels( Image *image, const long x, const long y, const unsigned long columns, const unsigned long rows );

SetImageVirtualPixelMethod( const Image *image, const VirtualPixelMethod method );

MagickPassFail SyncCacheView( ViewInfo *view );

MagickPassFail SyncImagePixels( Image *image );

MagickPassFail WriteStream( const ImageInfo *image_info, Image *, StreamHandler stream );

# FUNCTION DESCRIPTIONS

## AcquireCacheView

Method AcquireCacheView gets pixels from the in-memory or disk pixel cache as defined by the geometry parameters. A pointer to the pixels is returned if the pixels are transferred, otherwise a NULL is returned.

The format of the AcquireCacheView method is:

> const PixelPacket *AcquireCacheView ( const ViewInfo *view, const long x, const long y, const unsigned long columns, const unsigned long rows, ExceptionInfo *exception );

A description of each parameter follows:

pixels:

  Method GetCacheView returns a null pointer if an error occurs, otherwise a pointer to the view pixels.

view:

  The address of a structure of type ViewInfo.

x,y,columns,rows:

  These values define the perimeter of a region of pixels.

exception:

  Return any errors or warnings in this structure.

## AcquireImagePixels

> AcquireImagePixels() obtains a pixel region for read-only access. 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 area 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 RAM, or in a memory-mapped file. The returned pointer should *never *be deallocated by the user.

Pixels accessed via the returned pointer represent a simple array of type PixelPacket. If the image storage class is PsudeoClass, call `GetIndexes()` after invoking `GetImagePixels()` to obtain the colormap indexes (of type IndexPacket) corresponding to the region.

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

> The format of the AcquireImagePixels() method is:

> const PixelPacket *AcquireImagePixels ( const Image *image, const long x, const long y, const unsigned long columns, const unsigned long rows, ExceptionInfo *exception );

A description of each parameter follows:

status:

  `AcquireImagePixels()` returns a pointer to the pixels if they are transferred, otherwise a NULL is returned.

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.

## AcquireOnePixel

> AcquireOnePixel() 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 GetOnePixel ( ) instead. This function is convenient but performance will be poor if it is used too often.

> The format of the AcquireOnePixel() method is:

> PixelPacket AcquireOnePixel ( const Image image, const long x, const long y, ExceptionInfo exception );

A description of each parameter follows:

pixels:

  `AcquireOnePixel()` returns a pixel at the specified (x,y) location.

image:

  The image.

x,y:

  These values define the location of the pixel to return.

exception:

  Return any errors or warnings in this structure.

## DestroyCacheInfo

> DestroyCacheInfo() deallocates memory associated with the pixel cache.

> The format of the DestroyCacheInfo() method is:

> void DestroyCacheInfo ( Cache cache );

A description of each parameter follows:

cache:

  Specifies a pointer to a Cache structure.

## DestroyImagePixels

> DestroyImagePixels() deallocates memory associated with the pixel cache.

> The format of the DestroyImagePixels() method is:

> void DestroyImagePixels ( Image *image );

A description of each parameter follows:

image:

  The image.

## GetCacheView

> GetCacheView() gets pixels from the in-memory or disk pixel cache as defined by the geometry parameters. A pointer to the pixels is returned if the pixels are transferred, otherwise a NULL is returned.

The format of the GetCacheView method is:

> PixelPacket *GetCacheView ( ViewInfo *view, const long x, const long y, const unsigned long columns, const unsigned long rows );

A description of each parameter follows:

pixels:

  Method GetCacheView returns a null pointer if an error occurs, otherwise a pointer to the view pixels.

view:

  The address of a structure of type ViewInfo.

x,y,columns,rows:

  These values define the perimeter of a region of pixels.

## GetCacheViewIndexes

Method GetCacheViewIndexes returns the indexes associated with the specified view.

The format of the GetCacheViewIndexes method is:

> IndexPacket *GetCacheViewIndexes ( const ViewInfo *view );

A description of each parameter follows:

indexes:

  Method GetCacheViewIndexes returns the indexes associated with the specified view.

view:

  The address of a structure of type ViewInfo.

## GetImagePixels

> GetImagePixels() 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 area 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 RAM, or in a memory-mapped file. The returned pointer should *never* be deallocated by the user.

> Pixels accessed via the returned pointer represent a simple array of type PixelPacket. If the image storage class is PsudeoClass, call GetIndexes() after invoking GetImagePixels ( ) to obtain 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 SyncPixelCache ( ) or they may be lost.

> The format of the GetImagePixels() method is:

> PixelPacket *GetImagePixels ( Image *image, const long x, const long y, const unsigned long columns, const unsigned long rows );

A description of each parameter follows:

status:

  `GetImagePixels()` returns a pointer to the pixels if they are transferred, otherwise a NULL is returned.

image:

  The image.

x,y,columns,rows:

  These values define the perimeter of a region of pixels.

## GetImageVirtualPixelMethod

> GetImageVirtualPixelMethod() gets the "virtual pixels" method for the image. A virtual pixel is any pixel access that is outside the boundaries of the image cache.

> The format of the GetImageVirtualPixelMethod() method is:

> VirtualPixelMethod GetImageVirtualPixelMethod ( const Image *image );

A description of each parameter follows:

image:

  The image.

## GetIndexes

> GetIndexes() returns the colormap indexes associated with the last call to SetImagePixels ( ) or GetImagePixels ( ) . NULL is returned if colormap indexes are not available.

> The format of the GetIndexes() method is:

> IndexPacket *GetIndexes ( const Image *image );

A description of each parameter follows:

indexes:

  `GetIndexes()` returns the indexes associated with the last call to `SetImagePixels()` or GetImagePixels().

image:

  The image.

## GetOnePixel

> GetOnePixel() returns a single pixel at the specified ( x, y ) location. The image background color is returned if an error occurs. This function is convenient but performance will be poor if it is used too often.

> The format of the GetOnePixel() method is:

> PixelPacket GetOnePixel ( const Image image, const long x, const long y );

A description of each parameter follows:

image:

  The image.

x,y:

  These values define the location of the pixel to return.

## GetPixels

> GetPixels() returns the pixels associated with the last call to SetImagePixels ( ) or GetImagePixels ( ) . This is useful in order to access an already selected region without passing the geometry of the region.

> The format of the GetPixels() method is:

> PixelPacket *GetPixels ( const Image image );

A description of each parameter follows:

pixels:

  `GetPixels()` returns the pixels associated with the last call to `SetImagePixels()` or GetImagePixels().

image:

  The image.

## ModifyCache

> ModifyCache() ensures that there is only a single reference to the pixel cache to be modified, updating the provided cache pointer to point to a clone of the original pixel cache if necessary.

The format of the ModifyCache method is:

> MagickPassFail ModifyCache ( Image *image );

A description of each parameter follows:

image:

  The image.

## OpenCacheView

> OpenCacheView() opens a view into the pixel cache.

The format of the OpenCacheView method is:

> ViewInfo *OpenCacheView ( Image *image );

A description of each parameter follows:

image:

  The image.

## ReadStream

> ReadStream() makes the image pixels available to a user supplied callback method immediately upon reading a scanline with the ReadImage ( ) method.

> The format of the ReadStream() method is:

> Image *ReadStream ( const ImageInfo *image_info, StreamHandler stream, ExceptionInfo *exception );

A description of each parameter follows:

image_info:

  The image info.

stream:

  a callback method.

exception:

  Return any errors or warnings in this structure.

## ReferenceCache

> ReferenceCache() increments the reference count associated with the pixel cache returning a pointer to the cache.

The format of the ReferenceCache method is:

> Cache ReferenceCache ( Cache cache_info );

A description of each parameter follows:

cache_info:

  The cache_info.

## SetCacheView

> SetCacheView() gets pixels from the in-memory or disk pixel cache as defined by the geometry parameters. A pointer to the pixels is returned if the pixels are transferred, otherwise a NULL is returned.

The format of the SetCacheView method is:

> PixelPacket *SetCacheView ( ViewInfo *view, const long x, const long y, const unsigned long columns, const unsigned long rows );

A description of each parameter follows:

view:

  The address of a structure of type ViewInfo.

x,y,columns,rows:

  These values define the perimeter of a region of pixels.

## SetImagePixels

> SetImagePixels() initializes a pixel region for write-only access. If the region is successfully intialized 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 while 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 pre-existing values. The application is free to read and write the pixel buffer returned by SetImagePixels() any way it pleases. SetImagePixels ( ) does not initialize the pixel array values. Initializing pixel array values is the application's responsibility.

Performance is maximized if the selected area 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 RAM, or in a memory-mapped file. The returned pointer should *never* be deallocated by the user.

Pixels accessed via the returned pointer represent a simple array of type PixelPacket. If the image storage class is PsudeoClass, call `GetIndexes()` after invoking `GetImagePixels()` to obtain 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 `SyncPixelCache()` or they may be lost.

> The format of the SetImagePixels() method is:

> PixelPacket *SetImagePixels ( Image *image, const long x, const long y, const unsigned long columns, const unsigned long rows );

A description of each parameter follows:

pixels:

  SetImagePixels returns a pointer to the pixels if they are transferred, otherwise a NULL is returned.

image:

  The image.

x,y,columns,rows:

  These values define the perimeter of a region of pixels.

## SetImageVirtualPixelMethod

> SetImageVirtualPixelMethod() sets the "virtual pixels" method for the image. A virtual pixel is any pixel access that is outside the boundaries of the image cache.

> The format of the SetImageVirtualPixelMethod() method is:

> SetImageVirtualPixelMethod ( const Image *image, const VirtualPixelMethod method );

A description of each parameter follows:

image:

  The image.

type:

  choose from these access types:

          EdgeVPType:  the edge pixels of the image extend infinitely.
          Any pixel outside the image is assigned the same value as the
          pixel at the edge closest to it.
          TileVPType:  the image extends periodically or tiled.  The pixels
          wrap around the edges of the image.
          MirrorVPType:  mirror the image at the boundaries.
          ConstantVPType:  every value outside the image is a constant as
          defines by the pixel parameter.
    =head2 SyncCacheView

> SyncCacheView() saves the view pixels to the in-memory or disk cache. The method returns MagickPass if the pixel region is synced, otherwise MagickFail.

The format of the SyncCacheView method is:

> MagickPassFail SyncCacheView ( ViewInfo *view );

A description of each parameter follows:

view:

  The address of a structure of type ViewInfo.

## SyncImagePixels

> SyncImagePixels() saves the image pixels to the in-memory or disk cache. The method returns MagickPass if the pixel region is synced, otherwise MagickFail.

> The format of the SyncImagePixels() method is:

> MagickPassFail SyncImagePixels ( Image *image );

A description of each parameter follows:

status:

  `SyncImagePixels()` returns MagickPass if the image pixels are transferred to the in-memory or disk cache otherwise MagickFail.

image:

  The image.

## WriteStream

> WriteStream() makes the image pixels available to a user supplied callback method immediately upon writing pixel data with the WriteImage ( ) method.

> The format of the WriteStream() method is:

> MagickPassFail WriteStream ( const ImageInfo *image_info, Image *, StreamHandler stream );

A description of each parameter follows:

image_info:

  The image info.

stream:

  A callback method.