[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]

details vigra/codec.hxx VIGRA

00001 /************************************************************************/
00002 /*                                                                      */
00003 /*               Copyright 2001-2002 by Gunnar Kedenburg                */
00004 /*       Cognitive Systems Group, University of Hamburg, Germany        */
00005 /*                                                                      */
00006 /*    This file is part of the VIGRA computer vision library.           */
00007 /*    ( Version 1.2.0, Aug 07 2003 )                                    */
00008 /*    You may use, modify, and distribute this software according       */
00009 /*    to the terms stated in the LICENSE file included in               */
00010 /*    the VIGRA distribution.                                           */
00011 /*                                                                      */
00012 /*    The VIGRA Website is                                              */
00013 /*        http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/      */
00014 /*    Please direct questions, bug reports, and contributions to        */
00015 /*        koethe@informatik.uni-hamburg.de                              */
00016 /*                                                                      */
00017 /*  THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR          */
00018 /*  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED      */
00019 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
00020 /*                                                                      */
00021 /************************************************************************/
00022 
00023 #ifndef VIGRA_CODEC_HXX
00024 #define VIGRA_CODEC_HXX
00025 
00026 #include <memory>
00027 #include <string>
00028 #include <vector>
00029 
00030 // possible pixel types:
00031 // "undefined", "UINT8", "INT16", "INT32", "FLOAT", "DOUBLE"
00032 
00033 // possible compression types:
00034 // "undefined", "RLE", "LZW", "LOSSLESS", "JPEG"
00035 
00036 // possible file types:
00037 // "undefined", "TIFF", "VIFF", "JPEG", "PNG", "PNM", "BMP", "SUN", "XPM"
00038 
00039 // possible name extensions:
00040 // "undefined", "tif", "tiff", "jpg", "jpeg", "png", "pnm", "bmp", "sun",
00041 // "xpm" (also capital forms)
00042 
00043 namespace vigra
00044 {
00045     // codec description
00046 
00047     struct CodecDesc
00048     {
00049         std::string fileType;
00050         std::vector<std::string> pixelTypes;
00051         std::vector<std::string> compressionTypes;
00052         std::vector<std::vector<char> > magicStrings;
00053         std::vector<std::string> fileExtensions;
00054     };
00055 
00056     // Decoder and Encoder are pure virtual types that define a common
00057     // interface for all image file formats impex supports.
00058 
00059     struct Decoder
00060     {
00061         virtual ~Decoder() {};
00062         virtual void init( const std::string & ) = 0;
00063         virtual void close() = 0;
00064         virtual void abort() = 0;
00065 
00066         virtual std::string getFileType() const = 0;
00067         virtual std::string getPixelType() const = 0;
00068 
00069         virtual unsigned int getWidth() const = 0;
00070         virtual unsigned int getHeight() const = 0;
00071         virtual unsigned int getNumBands() const = 0;
00072         virtual unsigned int getOffset() const = 0;
00073 
00074         virtual const void * currentScanlineOfBand( unsigned int ) const = 0;
00075         virtual void nextScanline() = 0;
00076     };
00077 
00078     struct Encoder
00079     {
00080         virtual ~Encoder() {};
00081         virtual void init( const std::string & ) = 0;
00082         virtual void close() = 0;
00083         virtual void abort() = 0;
00084 
00085         virtual std::string getFileType() const = 0;
00086         virtual unsigned int getOffset() const = 0;
00087 
00088         virtual void setWidth( unsigned int ) = 0;
00089         virtual void setHeight( unsigned int ) = 0;
00090         virtual void setNumBands( unsigned int ) = 0;
00091         virtual void setCompressionType( const std::string &, int = -1 ) = 0;
00092         virtual void setPixelType( const std::string & ) = 0;
00093         virtual void finalizeSettings() = 0;
00094 
00095         virtual void * currentScanlineOfBand( unsigned int ) = 0;
00096         virtual void nextScanline() = 0;
00097     };
00098 
00099     // codec factory for registration at the codec manager
00100 
00101     struct CodecFactory
00102     {
00103         virtual CodecDesc getCodecDesc() const = 0;
00104         virtual std::auto_ptr<Decoder> getDecoder() const = 0;
00105         virtual std::auto_ptr<Encoder> getEncoder() const = 0;
00106     };
00107 
00108     // factory functions to encapsulate the codec managers
00109     //
00110     // codecs are selected according to the following order:
00111     // - (if provided) the FileType
00112     // - (in case of decoders) the file's magic string
00113     // - the filename extension
00114 
00115     std::auto_ptr<Decoder>
00116     getDecoder( const std::string &, const std::string & = "undefined" );
00117 
00118     std::auto_ptr<Encoder>
00119     getEncoder( const std::string &, const std::string & = "undefined" );
00120 
00121     // functions to query the capabilities of certain codecs
00122 
00123     std::vector<std::string> queryCodecPixelTypes( const std::string & );
00124 
00125     bool isPixelTypeSupported( const std::string &, const std::string & );
00126 }
00127 
00128 #endif // VIGRA_CODEC_HXX

© Ullrich Köthe (koethe@informatik.uni-hamburg.de)
Cognitive Systems Group, University of Hamburg, Germany

html generated using doxygen and Python
VIGRA 1.2.0 (7 Aug 2003)