Contents
Image *ConstituteImage( const unsigned long width, const unsigned long height, const char *map, const StorageType type, const void *pixels, ExceptionInfo *exception );
ConstituteImage() returns an Image corresponding to an image stored in a raw memory array format. The pixel data must be in scanline order top-to-bottom. The data can be unsigned char, unsigned short int, unsigned int, unsigned long, float, or double. Float and double require the pixels to be normalized to the range [0..1], otherwise the range is [0..MaxVal] where MaxVal is the maximum possible value for that type.
Note that for most 32-bit architectures the size of an unsigned long is the same as unsigned int, but for 64-bit architectures observing the LP64 standard, an unsigned long is 64 bits, while an unsigned int remains 32 bits. This should be considered when deciding if the data should be described as "Integer" or "Long".
For example, to create a 640x480 image from unsigned red-green-blue character data, use
image=ConstituteImage(640,480,"RGB",CharPixel,pixels,&exception);
The format of the Constitute method is:
Image *ConstituteImage( const unsigned long width, const unsigned long height, const char *map, const StorageType type, const void *pixels, ExceptionInfo *exception );
MagickPassFail DispatchImage( const Image *image, const long x_offset, const long y_offset, const unsigned long columns, const unsigned long rows, const char *map, const StorageType type, void *pixels, ExceptionInfo *exception );
DispatchImage() extracts pixel data from an Image into a raw memory array. The pixel data is written in scanline order top-to-bottom using an arbitrary quantum order specified by 'map', and with quantum size specified by 'type'.
The output array data may be unsigned char, unsigned short int, unsigned int, unsigned long, float, or double. Float and double require the pixels to be normalized to the range [0..1], otherwise the range is [0..MaxVal] where MaxVal is the maximum possible value for that type.
The method returns MagickPass on success or MagickFail if an error is encountered.
Suppose we want want to extract the first scanline of a 640x480 image as character data in red-green-blue order:
DispatchImage(image,0,0,640,1,"RGB",0,pixels,exception);
The format of the DispatchImage method is:
MagickPassFail DispatchImage( const Image *image, const long x_offset, const long y_offset, const unsigned long columns, const unsigned long rows, const char *map, const StorageType type, void *pixels, ExceptionInfo *exception );
Image *PingImage( const ImageInfo *image_info, ExceptionInfo *exception );
PingImage() returns all the attributes of an image or image sequence except for the pixels. It is much faster and consumes far less memory than ReadImage(). On failure, a NULL image is returned and exception describes the reason for the failure.
The format of the PingImage method is:
Image *PingImage( const ImageInfo *image_info, ExceptionInfo *exception );
A description of each parameter follows:
Image *ReadImage( const ImageInfo *image_info, ExceptionInfo *exception );
ReadImage() reads an image or image sequence from a file or file handle. The method returns a NULL if there is a memory shortage or if the image cannot be read. On failure, a NULL image is returned and exception describes the reason for the failure.
The format of the ReadImage method is:
Image *ReadImage( const ImageInfo *image_info, ExceptionInfo *exception );
A description of each parameter follows:
Image *ReadInlineImage( const ImageInfo *image_info, const char *content, ExceptionInfo *exception );
ReadInlineImage() reads a Base64-encoded inline image or image sequence. The method returns a NULL if there is a memory shortage or if the image cannot be read. On failure, a NULL image is returned and exception describes the reason for the failure.
The format of the ReadInlineImage method is:
Image *ReadInlineImage( const ImageInfo *image_info, const char *content, ExceptionInfo *exception );
Use WriteImage() to write an image or an image sequence to a file or filehandle. If writing to a file on disk, the name is defined by the filename member of the image structure. WriteImage() returns MagickFailure is there is a memory shortage or if the image cannot be written. Check the exception member of image to determine the cause for any failure.
The format of the WriteImage method is:
MagickPassFail WriteImage( const ImageInfo *image_info, Image *image );
A description of each parameter follows:
MagickPassFail WriteImages( const ImageInfo *image_info, Image *image, const char *filename, ExceptionInfo *exception );
WriteImages() writes an image sequence into one or more files. While WriteImage() will also write an image sequence, it is limited to writing the sequence into a single file using a format which supports multiple frames. WriteImages() does not have that limitation since it will generate multiple output files if necessary (or when requested). When ImageInfo's adjoin flag is set to MagickFalse, the file name is expected to include a printf-style formatting string for the frame number (e.g. "image%02d.miff") so that the frames may be written.
The format of the WriteImages method is:
MagickPassFail WriteImages( const ImageInfo *image_info, Image *image, const char *filename, ExceptionInfo *exception );
unsigned int WriteImagesFile( const ImageInfo *image_info, Image *image, FILE *file, ExceptionInfo *exception );
WriteImagesFile() writes an image or image sequence to a stdio FILE handle. This may be used to append an encoded image to an already existing appended image sequence if the file seek position is at the end of an existing file.
The format of the WriteImagesFile method is:
unsigned int WriteImagesFile( const ImageInfo *image_info, Image *image, FILE *file, ExceptionInfo *exception );