Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | List of all members
om::images::io::ImageConverter Class Reference

A class that handles encoding and decoding image data to/from various formats. More...

#include <omImageConverter.h>

Public Member Functions

 ImageConverter ()
 Create a default image converter which can encode or decode any of the supported image formats. More...
 
Size getTranscoderCount () const
 Return the total number of transcoders that this image converter supports. More...
 
ImageTranscodergetTranscoder (const ImageFormat &format) const
 Return a pointer to the transcoder for the specified image format. More...
 
Bool addTranscoder (ImageTranscoder *newTranscoder)
 Add a new transcoder to this image converter. More...
 
Bool removeTranscoder (const ImageFormat &format)
 Remove the transcoder from this converter with the specified image format. More...
 
void clearTranscoders ()
 Remove all transcoders from this image converter. More...
 
Bool canEncode (const ImageFormat &format) const
 Return whether or not an image can be encoded in the specified format. More...
 
Bool canEncode (const ImageFormat &format, const Image &image) const
 Return whether or not an image can be encoded in the specified format. More...
 
Bool encode (const ImageFormat &format, const Image &image, DataOutputStream &stream) const
 Encode an image using the specified format and send the output to the specified data output stream. More...
 
Bool encode (const ImageFormat &format, const Image &image, const UTF8String &filePath) const
 Encode an image using the specified format, writing the output to the specified file path. More...
 
Bool encode (const Image &image, const UTF8String &filePath) const
 Encode an image using an inferred format, writing the output to the specified file path. More...
 
Bool canDecode (const ImageFormat &format) const
 Return whether or not the specified image format can be decoded. More...
 
Bool canDecode (const ImageFormat &format, const UByte *inputData, Size inputDataSizeInBytes) const
 Return whether or not the specified data can be decoded. More...
 
Bool decode (const ImageFormat &format, const UByte *inputData, Size inputDataSizeInBytes, Image &image) const
 Decode the data from the specified data pointer and return an image. More...
 
Bool decode (const ImageFormat &format, DataInputStream &stream, Image &image) const
 Decode the data from the specified DataInputStream and return an image. More...
 
Bool decode (const ImageFormat &format, const UTF8String &filePath, Image &image) const
 Decode the image at the specified file path. More...
 
Bool decode (const UTF8String &filePath, Image &image) const
 Decode the image at the specified file path. More...
 

Detailed Description

A class that handles encoding and decoding image data to/from various formats.

Constructor & Destructor Documentation

om::images::io::ImageConverter::ImageConverter ( )

Create a default image converter which can encode or decode any of the supported image formats.

In order to encode unsupported image formats, the user should create a class that inherits from ImageTranscoder and add it to this converter for the correct format.

Member Function Documentation

Size om::images::io::ImageConverter::getTranscoderCount ( ) const
inline

Return the total number of transcoders that this image converter supports.

ImageTranscoder* om::images::io::ImageConverter::getTranscoder ( const ImageFormat format) const

Return a pointer to the transcoder for the specified image format.

If that format is not supported by the converter, a NULL pointer is returned.

Bool om::images::io::ImageConverter::addTranscoder ( ImageTranscoder newTranscoder)

Add a new transcoder to this image converter.

If transcoder pointer is not NULL, the transcoder is added to the converter for its format (accessed by calling getFormat() on the transcoder). If there already exists a transcoder for that format, it is replaced. The method returns whether or not the new transcoder was successfully added.

Bool om::images::io::ImageConverter::removeTranscoder ( const ImageFormat format)

Remove the transcoder from this converter with the specified image format.

If there is a transcoder with that format, it is removed and TRUE is returned. Otherwise, the converter is unchanged and FALSE is returned.

void om::images::io::ImageConverter::clearTranscoders ( )

Remove all transcoders from this image converter.

After this operation, the image converter will not be able to decode or encode images in any format until new transcoder objects are added to it.

Bool om::images::io::ImageConverter::canEncode ( const ImageFormat format) const

Return whether or not an image can be encoded in the specified format.

Bool om::images::io::ImageConverter::canEncode ( const ImageFormat format,
const Image image 
) const

Return whether or not an image can be encoded in the specified format.

If TRUE is returned, the image is in a format that is compatible with this image converter. Otherwise, the image is not compatible and cannot be encoded.

Bool om::images::io::ImageConverter::encode ( const ImageFormat format,
const Image image,
DataOutputStream stream 
) const

Encode an image using the specified format and send the output to the specified data output stream.

If the encoding succeeds, the encoded image data is sent to the data output stream and TRUE is returned. Otherwise, FALSE is returned and no data is sent to the stream.

Bool om::images::io::ImageConverter::encode ( const ImageFormat format,
const Image image,
const UTF8String &  filePath 
) const

Encode an image using the specified format, writing the output to the specified file path.

The method encodes the image as the given format, or attempts to guess the format if it is UNDEFINED.

If the encoding succeeds, the encoded image data is sent to the file location and TRUE is returned. Otherwise, FALSE is returned and the file is not written.

Bool om::images::io::ImageConverter::encode ( const Image image,
const UTF8String &  filePath 
) const
inline

Encode an image using an inferred format, writing the output to the specified file path.

The method attempts to guess the output format for the image based on the file path extension.

If the encoding succeeds, the encoded image data is sent to the file location and TRUE is returned. Otherwise, FALSE is returned and the file is not written.

Bool om::images::io::ImageConverter::canDecode ( const ImageFormat format) const

Return whether or not the specified image format can be decoded.

Bool om::images::io::ImageConverter::canDecode ( const ImageFormat format,
const UByte inputData,
Size  inputDataSizeInBytes 
) const

Return whether or not the specified data can be decoded.

If the ImageFormat::UNDEFINED is specified, the method tries all possible decoders to see if any of them can decode the image data.

Bool om::images::io::ImageConverter::decode ( const ImageFormat format,
const UByte inputData,
Size  inputDataSizeInBytes,
Image image 
) const

Decode the data from the specified data pointer and return an image.

The image is returned in the specified output image reference. If the ImageFormat::UNDEFINED is specified, the method attempts to guess the format of the image.

If the decoding succeeds, the function creates an image and places it in the image output reference paramter and TRUE is returned. Otherwise, if the decoding fails, FALSE is returned.

Bool om::images::io::ImageConverter::decode ( const ImageFormat format,
DataInputStream stream,
Image image 
) const

Decode the data from the specified DataInputStream and return an image.

The image is returned in the specified output image reference. If the ImageFormat::UNDEFINED is specified, the method attempts to guess the format of the image.

If the decoding succeeds, the function creates an image and places it in the image output reference paramter and TRUE is returned. Otherwise, if the decoding fails, FALSE is returned.

Bool om::images::io::ImageConverter::decode ( const ImageFormat format,
const UTF8String &  filePath,
Image image 
) const

Decode the image at the specified file path.

The image is returned in the specified output image reference. The method decodes the image as the given format, or attempts to guess the format if it is UNDEFINED.

If the decoding succeeds, the function creates an image and places it in the image output reference paramter and TRUE is returned. Otherwise, if the decoding fails, FALSE is returned.

Bool om::images::io::ImageConverter::decode ( const UTF8String &  filePath,
Image image 
) const

Decode the image at the specified file path.

The image is returned in the specified output image reference. The method attempts to guess the format of the image based on the file type extension of the path.

If the decoding succeeds, the function creates an image and places it in the image output reference paramter and TRUE is returned. Otherwise, if the decoding fails, FALSE is returned.


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