*Buffer = EncodeImage(#Image [, ImagePlugin [, Flags [, Depth]]])
Encode the specified image into a memory buffer.


#Image The image to encode.
ImagePlugin (optional) The format to encode the image in. This can be one of the following values:
  #PB_ImagePlugin_BMP      : encode the image in BMP (default)
  #PB_ImagePlugin_JPEG     : encode the image in JPEG (UseJPEGImageEncoder() has to be used)
  #PB_ImagePlugin_JPEG2000 : encode the image in JPEG2000 (UseJPEG2000ImageEncoder() has to be used)
  #PB_ImagePlugin_PNG      : encode the image in PNG (UsePNGImageEncoder() has to be used)
Flags (optional) Parameters for the image plug-in. For now, only the quality setting is supported: a number from 0 (worse quality) to 10 (maximum quality). Only the JPEG and JPEG 2000 plugins currently support it (default quality is set to '7' if no flags are specified).

When an image is encoded using palletized depth (1, 4 or 8), the following flag is available for combination:
  #PB_Image_FloydSteinberg: Apply a Floyd-Steinberg dithering.
Depth (optional) The depth in which to save the image. Valid values are 1, 4, 8, 24 and 32. The default value is the original image depth. For now, only PNG encoder support palletized image format (1, 4 or 8-bit).

Return value

Returns a pointer to a newly allocated memory buffer containing the encoded image, or zero if the encoding has failed. MemorySize() can be used to get the size of the encoded image. FreeMemory() has to be used to free the buffer after use.

See Also

LoadImage(), ImagePlugin library

Supported OS


<- CreateImage() - Image Index - FreeImage() ->