Ocean
Ocean IO Image Library

The Ocean IO Image Library provides image encoding, decoding, loading, and saving functionalities. More...

Collaboration diagram for Ocean IO Image Library:

Data Structures

class  Ocean::IO::Image::Comfort
 This class provides functions for image encoding and decoding which will increase binary size when used. More...
 

Functions

OCEAN_IO_IMAGE_EXPORT Frame Ocean::IO::Image::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...
 
OCEAN_IO_IMAGE_EXPORT bool Ocean::IO::Image::encodeImage (const Frame &frame, const std::string &imageType, std::vector< uint8_t > &buffer, const Properties &properties=Properties())
 Encodes (writes) a given frame as image (with specified image type) to a resulting buffer. More...
 
OCEAN_IO_IMAGE_EXPORT Frame Ocean::IO::Image::readImage (const std::string &filename)
 Reads/loads an image from a specified file. More...
 
OCEAN_IO_IMAGE_EXPORT bool Ocean::IO::Image::writeImage (const Frame &frame, const std::string &filename, const Properties &properties=Properties())
 Writes a given frame to a specified file. More...
 
static bool Ocean::IO::Image::Comfort::encodeImage (const Frame &frame, const std::string &imageType, std::vector< uint8_t > &buffer, const bool allowConversion, bool *hasBeenConverted=nullptr, const Properties &properties=Properties())
 Encodes (writes) a given frame as image (with specified image type) to a resulting buffer. More...
 
static bool Ocean::IO::Image::Comfort::writeImage (const Frame &frame, const std::string &filename, const bool allowConversion, bool *hasBeenConverted=nullptr, const Properties &properties=Properties())
 Writes a given frame to a specified file. More...
 

Detailed Description

The Ocean IO Image Library provides image encoding, decoding, loading, and saving functionalities.

The library is platform independent.

Function Documentation

◆ decodeImage()

OCEAN_IO_IMAGE_EXPORT Frame Ocean::IO::Image::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.

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
encodeImage(), readImage().

◆ encodeImage() [1/2]

static bool Ocean::IO::Image::Comfort::encodeImage ( const Frame frame,
const std::string &  imageType,
std::vector< uint8_t > &  buffer,
const bool  allowConversion,
bool *  hasBeenConverted = nullptr,
const Properties properties = Properties() 
)
static

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

In case, the pixel format of the given frame is not supported by the destination, the function may convert the frame internally (depending on 'allowConversion'). As this function supports the conversion of color spaces, the binary impact when using this function may be quite high.
Note: Depending on the encoder, a provided quality value may not have any impact, e.g., png images do not support a loosely compression.

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 resulting image
allowConversionTrue, to allow an internal conversion of the frame if the image type 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
propertiesThe properties to be used when writing the image, must be valid
Returns
True, if succeeded; False, if the frame could not be encoded e.g., if the pixel format could not be converted to a valid pixel format or if the imageType is unknown
See also
readImage().

◆ encodeImage() [2/2]

OCEAN_IO_IMAGE_EXPORT bool Ocean::IO::Image::encodeImage ( const Frame frame,
const std::string &  imageType,
std::vector< uint8_t > &  buffer,
const Properties properties = Properties() 
)

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

In case, the pixel format of the given frame is not supported by the destination, the function will fail.
As this function does not provide an automatic color space conversion, the binary impact when using this function will be quite small.
Note: Depending on the encoder, a provided quality value may not have any impact, e.g., png images do not support a loosely compression.

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 given image
propertiesThe properties to be used when writing the image, must be valid
Returns
True, if succeeded; False, if the frame could not be encoded e.g., if the pixel format is not supported or if the imageType is unknown
See also
decodeImage(), writeImage().

◆ readImage()

OCEAN_IO_IMAGE_EXPORT Frame Ocean::IO::Image::readImage ( const std::string &  filename)

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() [1/2]

static bool Ocean::IO::Image::Comfort::writeImage ( const Frame frame,
const std::string &  filename,
const bool  allowConversion,
bool *  hasBeenConverted = nullptr,
const Properties properties = Properties() 
)
static

Writes a given frame to a specified file.

In case, the pixel format of the given frame is not supported by the destination, the function may convert the frame internally (depending on 'allowConversion'). As this function supports the conversion of color spaces, the binary impact when using this function may be quite high.
Note: Depending on the encoder, a provided quality value may not have any impact, e.g., png images do not support a loosely compression.

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 the image type does not support the given frame type; False, to prevent a conversion and to stop writing the image
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
propertiesThe properties to be used when writing the image, must be valid
Returns
True, if succeeded
See also
readImage().

◆ writeImage() [2/2]

OCEAN_IO_IMAGE_EXPORT bool Ocean::IO::Image::writeImage ( const Frame frame,
const std::string &  filename,
const Properties properties = Properties() 
)

Writes a given frame to a specified file.

In case, the pixel format of the given frame is not supported by the destination, the function will fail.
As this function does not provide an automatic color space conversion, the binary impact when using this function will be quite small.
Note: Depending on the encoder, a provided quality value may not have any impact, e.g., png images do not support a loosely compression.

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
propertiesThe properties to be used when writing the image, must be valid
Returns
True, if succeeded
See also
readImage().