Ocean
Ocean::Media::Special::Image Class Reference

This class implements read and write functions for all file formats supported by the Special media library. More...

Static Public Member Functions

static Frame decodeImage (const void *buffer, const size_t size, const std::string &imageBufferTypeIn=std::string(), std::string *imageBufferTypeOut=nullptr)
 Decodes (reads/loads) an image from a given binary buffer. More...
 
static bool encodeImage (const Frame &frame, const std::string &imageType, std::vector< uint8_t > &buffer, const bool allowConversion=true, bool *hasBeenConverted=nullptr)
 Encodes (writes) a given frame as image (with specified image type) to a resulting buffer. More...
 
static Frame readImage (const std::string &filename)
 Reads/loads an image from a specified file. More...
 
static bool writeImage (const Frame &frame, const std::string &filename, const bool allowConversion=true, bool *hasBeenConverted=nullptr)
 Writes a given frame to a specified file. More...
 

Detailed Description

This class implements read and write functions for all file formats supported by the Special media library.

Member Function Documentation

◆ decodeImage()

static Frame Ocean::Media::Special::Image::decodeImage ( const void *  buffer,
const size_t  size,
const std::string &  imageBufferTypeIn = std::string(),
std::string *  imageBufferTypeOut = nullptr 
)
static

Decodes (reads/loads) an image from a given binary buffer.

Parameters
bufferThe buffer from which the image will be loaded, must be valid
sizeThe size of the given buffer in bytes, with range [1, infinity)
imageBufferTypeInType of the given image that is stored in the buffer, should be specified if known (e.g. the file extension of a corresponding image file)
imageBufferTypeOutOptional type of the given image that is stored in the buffer, as determined by the decoder (if possible)
Returns
The frame containing the image information, an invalid frame if the image could not be loaded
See also
writeImage().

◆ encodeImage()

static bool Ocean::Media::Special::Image::encodeImage ( const Frame frame,
const std::string &  imageType,
std::vector< uint8_t > &  buffer,
const bool  allowConversion = true,
bool *  hasBeenConverted = nullptr 
)
static

Encodes (writes) a given frame as image (with specified image type) to a resulting buffer.

Parameters
frameThe frame to be written, must be valid
imageTypeThe file extension of the image to be created (e.g. jpg, png, bmp, or tif), must be defined
bufferThe resulting buffer storing the binary information of the BMP image
allowConversionTrue, to allow an internal conversion of the frame if BMP does not support the given frame type; False, to prevent a conversion and to stop creating the buffer
hasBeenConvertedOptional resulting statement whether the frame had to be converted to a different pixel format before it could be written; True, if so; False, if not
Returns
True, if succeeded; False, if the frame could not be written as BMP image e.g., if the frame contained an alpha channel
See also
readImage().

◆ readImage()

static Frame Ocean::Media::Special::Image::readImage ( const std::string &  filename)
static

Reads/loads an image from a specified file.

Parameters
filenameThe name of the file from which the image will be loaded, must be valid
Returns
The frame containing the image information, an invalid frame if the image could not be loaded
See also
writeImage().

◆ writeImage()

static bool Ocean::Media::Special::Image::writeImage ( const Frame frame,
const std::string &  filename,
const bool  allowConversion = true,
bool *  hasBeenConverted = nullptr 
)
static

Writes a given frame to a specified file.

Parameters
frameThe frame to be written, must be valid
filenameThe name of the file to which the frame will be written, must contain a valid image extension like e.g. jpg, png, bmp, or tif), must be valid
allowConversionTrue, to allow an internal conversion of the frame if BMP does not support the given frame type; False, to prevent a conversion and to stop creating the buffer
hasBeenConvertedOptional resulting statement whether the frame had to be converted to a different pixel format before it could be written; True, if so; False, if not
Returns
True, if succeeded
See also
readImage().

The documentation for this class was generated from the following file: