im_format.h

Go to the documentation of this file.
00001 /** \file
00002  * \brief File Format Access
00003  *
00004  * See Copyright Notice in im_lib.h
00005  */
00006 
00007 #include "im_file.h"
00008 #include "im_attrib.h"
00009 
00010 #ifndef __IM_FORMAT_H
00011 #define __IM_FORMAT_H
00012 
00013 
00014 class imFormat;
00015 
00016 /** \brief Image File Format Virtual Class (SDK Use Only) 
00017  * 
00018  * \par
00019  * Virtual Base class for file formats. All file formats inherit from this class.
00020  * \ingroup filesdk */
00021 class imFileFormatBase: public _imFile
00022 {
00023 public:
00024   const imFormat* iformat;
00025 
00026   imFileFormatBase(const imFormat* _iformat): iformat(_iformat) {}
00027   virtual ~imFileFormatBase() {}
00028 
00029   imAttribTable* AttribTable() {return (imAttribTable*)this->attrib_table;}
00030 
00031   /* Pure Virtual Methods. Every driver must implement all the following methods. */
00032 
00033   virtual int Open(const char* file_name) = 0; // Must initialize compression and image_count
00034   virtual int New(const char* file_name) = 0;
00035   virtual void Close() = 0;
00036   virtual void* Handle(int index) = 0;
00037   virtual int ReadImageInfo(int index) = 0;    // Should update compression
00038   virtual int ReadImageData(void* data) = 0;
00039   virtual int WriteImageInfo() = 0;            // Should update compression
00040   virtual int WriteImageData(void* data) = 0;  // Must update image_count
00041 };
00042 
00043 /** \brief Image File Format Descriptor (SDK Use Only) 
00044  * 
00045  * \par
00046  * All file formats must define these informations. They are stored by \ref imFormatRegister.
00047  * \ingroup filesdk */
00048 class imFormat
00049 {
00050 public:
00051   const char* format; 
00052   const char* desc;
00053   const char* ext;
00054   const char** comp;
00055   int comp_count, 
00056       can_sequence;
00057 
00058   virtual imFileFormatBase* Create() const = 0;
00059   virtual int CanWrite(const char* compression, int color_mode, int data_type) const = 0;
00060 
00061   imFormat(const char* _format, const char* _desc, const char* _ext, 
00062            const char** _comp, int _comp_count, int _can_sequence)
00063     :format(_format), desc(_desc), ext(_ext), comp(_comp), 
00064      comp_count(_comp_count), can_sequence(_can_sequence)
00065     {} 
00066   virtual ~imFormat() {}
00067 };
00068 
00069 extern "C"
00070 {
00071 
00072 /* Internal Use only */
00073 
00074 /* Opens a file with the respective format driver 
00075  * Uses the file extension to speed up the search for the format driver.
00076  * Used by "im_file.cpp" only. */
00077 imFileFormatBase* imFileFormatBaseOpen(const char* file_name, int *error);
00078 
00079 /* Opens a file with the given format
00080  * Used by "im_file.cpp" only. */
00081 imFileFormatBase* imFileFormatBaseOpenAs(const char* file_name, const char* format, int *error);
00082 
00083 /* Creates a file using the given format driver.
00084  * Used by "im_file.cpp" only. */
00085 imFileFormatBase* imFileFormatBaseNew(const char* file_name, const char* format, int *error);
00086 
00087 
00088 /* File Format SDK */
00089 
00090 /** Register a format driver.
00091  * \ingroup filesdk */
00092 void imFormatRegister(imFormat* iformat);
00093 
00094 
00095 }
00096 
00097 #endif

Generated on Thu Oct 1 11:40:01 2009 for IM by  doxygen 1.6.1