Thea
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
ImageCodec Class Referenceabstract

Abstract base class for all image codecs. More...

#include <Image.hpp>

Inheritance diagram for ImageCodec:
Codec INamedObject CodecJpeg

Public Types

typedef std::array< int8,(size_t) MAGIC_LENGTHMagicString
 The type of the codec's magic string (an array of MAGIC_LENGTH bytes). More...
 

Public Member Functions

virtual MagicString const & getMagic () const
 Get the magic string for the codec, if it has one (else a string of all zeros). More...
 
virtual char const * getName () const =0
 Get the name of the object. More...
 
 operator intx () const
 Implicitly convert to an integer value for use in switch statements etc. More...
 
bool operator== (Codec const &other) const
 Check if two codecs are equal. More...
 
virtual void readImage (Image &image, BinaryInputStream &input, bool read_block_header) const =0
 Read an image from a binary input stream. More...
 
int8 setName (char const *s)
 Set the name of the object. More...
 
virtual void writeImage (Image const &image, BinaryOutputStream &output, bool write_block_header) const =0
 Write an image to a binary output stream. More...
 

Static Public Member Functions

static MagicString toMagic (std::string const &s)
 Convenience function to convert a string literal to a magic string. More...
 

Static Public Attributes

static intx const MAGIC_LENGTH = 8
 The standard length (in bytes) of the codec's magic string as used in BlockHeader. More...
 

Detailed Description

Abstract base class for all image codecs.

Definition at line 228 of file Image.hpp.

Member Typedef Documentation

typedef std::array<int8, (size_t)MAGIC_LENGTH> MagicString
inherited

The type of the codec's magic string (an array of MAGIC_LENGTH bytes).

Definition at line 42 of file Codec.hpp.

Member Function Documentation

virtual MagicString const& getMagic ( ) const
virtualinherited

Get the magic string for the codec, if it has one (else a string of all zeros).

Reimplemented in CodecJpeg.

Definition at line 127 of file Codec.hpp.

virtual char const* getName ( ) const
pure virtualinherited
operator intx ( ) const
inherited

Implicitly convert to an integer value for use in switch statements etc.

This value will be common to all instances of the codec class

Definition at line 136 of file Codec.hpp.

bool operator== ( Codec const &  other) const
inherited

Check if two codecs are equal.

All instances of a codec class must be considered equal.

Definition at line 130 of file Codec.hpp.

virtual void readImage ( Image image,
BinaryInputStream input,
bool  read_block_header 
) const
pure virtual

Read an image from a binary input stream.

If read_block_header is true, extra information about the image block (such as its size and type) will be read first from the input stream. Else, the entire input will be treated as the image block (the size() function of the stream must return the correct value in this case).

See also
writeImage

Implemented in CodecJpeg.

int8 setName ( char const *  s)
virtualinherited

Set the name of the object.

Returns
True if the name was successfully set, else false (e.g. if the name is read-only).

Implements INamedObject.

Definition at line 124 of file Codec.hpp.

static MagicString toMagic ( std::string const &  s)
staticinherited

Convenience function to convert a string literal to a magic string.

Definition at line 139 of file Codec.hpp.

virtual void writeImage ( Image const &  image,
BinaryOutputStream output,
bool  write_block_header 
) const
pure virtual

Write an image to a binary output stream.

Optionally prefixes extra information about the image block such as its size and type (which may have not been specified in the encoding format itself).

See also
readImage

Implemented in CodecJpeg.

Member Data Documentation

intx const MAGIC_LENGTH = 8
staticinherited

The standard length (in bytes) of the codec's magic string as used in BlockHeader.

Definition at line 39 of file Codec.hpp.


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