VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Gr::ImageDecoder Class Reference

An interface for decoding encoded images into a raw format. More...

#include <grimagedecoder.h>

Classes

struct  ScaleToFit
 Describes scale-to-fit target dimensions. More...
 

Public Member Functions

 ImageDecoder ()
 Default constructor.
 
void setup (int scale, bool monochrome_out)
 Sets the scale factor.
 
ImageType decode (const G::Path &path_in, ImageData &out, const ScaleToFit &=ScaleToFit())
 Decodes a file, with a scale-to-fit option. More...
 
ImageType decode (const ImageType &type_in, const G::Path &path_in, ImageData &out, ScaleToFit=ScaleToFit())
 Decodes a file with the given image type, with a scale-to-fit option. More...
 
ImageType decode (const ImageType &type_in, const char *data_in, size_t, ImageData &out, const ScaleToFit &=ScaleToFit())
 Decodes the image buffer and returns the raw image type. More...
 
ImageType decode (const ImageType &type_in, const std::vector< char > &data_in, ImageData &out, const ScaleToFit &=ScaleToFit())
 Decodes the image buffer and returns the raw image type. More...
 
ImageType decode (const ImageType &type_in, const ImageBuffer &data_in, ImageData &out, const ScaleToFit &=ScaleToFit())
 Decodes the image buffer and returns the raw image type. More...
 
ImageType decodeInPlace (ImageType type_in, char *&p, size_t size_in, ImageData &store)
 Decodes an image buffer with raw decoding done in-place. More...
 

Static Public Member Functions

static ImageType readType (const G::Path &path, bool do_throw=true)
 A convenience function to read a file's image type. More...
 

Detailed Description

An interface for decoding encoded images into a raw format.

The input images can be in raw, png, jpeg or pnm formats.

Note that raw format is not self-describing, so raw images often use a binary pnm format when stored to file and these files are trivially decoded into the raw format as they are read in.

Definition at line 47 of file grimagedecoder.h.

Member Function Documentation

Gr::ImageType Gr::ImageDecoder::decode ( const G::Path path_in,
ImageData out,
const ScaleToFit scale_to_fit = ScaleToFit() 
)

Decodes a file, with a scale-to-fit option.

Scale-to-fit scaling takes precedence over the decoder's default scale factor. Returns the raw image type. Throws on error.

Definition at line 56 of file grimagedecoder.cpp.

Gr::ImageType Gr::ImageDecoder::decode ( const ImageType type_in,
const G::Path path_in,
ImageData out,
ScaleToFit  scale_to_fit = ScaleToFit() 
)

Decodes a file with the given image type, with a scale-to-fit option.

This is a more efficient overload if the file type is already known. Scale-to-fit scaling overrides the decoder's default scale factor. Returns the raw image type. Throws on error.

Definition at line 61 of file grimagedecoder.cpp.

Gr::ImageType Gr::ImageDecoder::decode ( const ImageType type_in,
const char *  data_in,
size_t  n,
ImageData out,
const ScaleToFit scale_to_fit = ScaleToFit() 
)

Decodes the image buffer and returns the raw image type.

Throws on error.

Definition at line 119 of file grimagedecoder.cpp.

Gr::ImageType Gr::ImageDecoder::decode ( const ImageType type_in,
const std::vector< char > &  data_in,
ImageData out,
const ScaleToFit scale_to_fit = ScaleToFit() 
)

Decodes the image buffer and returns the raw image type.

Throws on error.

Definition at line 114 of file grimagedecoder.cpp.

Gr::ImageType Gr::ImageDecoder::decode ( const ImageType type_in,
const ImageBuffer data_in,
ImageData out,
const ScaleToFit scale_to_fit = ScaleToFit() 
)

Decodes the image buffer and returns the raw image type.

Throws on error.

Definition at line 159 of file grimagedecoder.cpp.

Gr::ImageType Gr::ImageDecoder::decodeInPlace ( ImageType  type_in,
char *&  p,
size_t  size_in,
Gr::ImageData out_store 
)

Decodes an image buffer with raw decoding done in-place.

The image pointer is passed by reference and is either unchanged after an in-place decode, or it is set to point into the supplied contiguous ImageData object.

Definition at line 194 of file grimagedecoder.cpp.

Gr::ImageType Gr::ImageDecoder::readType ( const G::Path path,
bool  do_throw = true 
)
static

A convenience function to read a file's image type.

Throws on error, by default.

Definition at line 66 of file grimagedecoder.cpp.


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