Thea
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
CodecJpeg Class Reference

JPEG image codec. More...

#include <Image.hpp>

Inheritance diagram for CodecJpeg:
ImageCodec Codec INamedObject

Classes

struct  Options
 Options for JPEG encoding. More...
 

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

 CodecJpeg ()
 Default constructor. More...
 
 CodecJpeg (Options const &options_)
 Constructor to set encoding options. More...
 
MagicString const & getMagic () const
 Get the magic string for the codec, if it has one (else a string of all zeros). More...
 
char const * getName () const
 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...
 
void readImage (Image &image, BinaryInputStream &input, bool read_block_header) const
 Read an image from a binary input stream. More...
 
int8 setName (char const *s)
 Set the name of the object. More...
 
void writeImage (Image const &image, BinaryOutputStream &output, bool write_block_header) const
 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

JPEG image codec.

Definition at line 303 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.

Constructor & Destructor Documentation

CodecJpeg ( )

Default constructor.

Sets default options (quality 75, non-progressive encoding).

Definition at line 323 of file Image.hpp.

CodecJpeg ( Options const &  options_)

Constructor to set encoding options.

Definition at line 326 of file Image.hpp.

Member Function Documentation

MagicString const& getMagic ( ) const
virtual

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

Reimplemented from Codec.

Definition at line 328 of file Image.hpp.

char const* getName ( ) const
virtual

Get the name of the object.

Implements INamedObject.

Definition at line 328 of file Image.hpp.

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.

void readImage ( Image image,
BinaryInputStream input,
bool  read_block_header 
) const
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

Implements ImageCodec.

Definition at line 264 of file Image.cpp.

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.

void writeImage ( Image const &  image,
BinaryOutputStream output,
bool  write_block_header 
) const
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

Implements ImageCodec.

Definition at line 321 of file Image.cpp.

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 files: