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 /** \brief Image File Format Driver (SDK Use Only)
00015 *
00016 * \par
00017 * Virtual Base class for file formats. All file formats inherit from this class.
00018 * \ingroup filesdk */
00019 class imFormat: public _imFile
00020 {
00021 public:
00022 const char* format;
00023 const char* desc;
00024 const char* ext;
00025 const char** comp;
00026 int comp_count,
00027 can_sequence;
00028
00029 imFormat(const char* _format, const char* _desc, const char* _ext,
00030 const char** _comp, int _comp_count, int _can_sequence)
00031 :format(_format), desc(_desc), ext(_ext), comp(_comp),
00032 comp_count(_comp_count), can_sequence(_can_sequence)
00033 {}
00034 virtual ~imFormat() {}
00035
00036 imAttribTable* AttribTable() {return (imAttribTable*)this->attrib_table;}
00037
00038 /* Pure Virtual Methods. Every driver must implement all the following methods. */
00039
00040 virtual int Open(const char* file_name) = 0; // Must initialize compression and image_count
00041 virtual int New(const char* file_name) = 0;
00042 virtual void Close() = 0;
00043 virtual void* Handle(int index) = 0;
00044 virtual int ReadImageInfo(int index) = 0; // Should update compression
00045 virtual int ReadImageData(void* data) = 0;
00046 virtual int WriteImageInfo() = 0; // Should update compression
00047 virtual int WriteImageData(void* data) = 0; // Must update image_count
00048 virtual int CanWrite(const char* compression, int color_mode, int data_type) const = 0;
00049 };
00050
00051 extern "C"
00052 {
00053
00054 /* Internal Use only */
00055
00056 /* Opens a file with the respective format driver
00057 * Uses the file extension to speed up the search for the format driver.
00058 * Used by "im_file.cpp" only. */
00059 imFormat* imFormatOpen(const char* file_name, int *error);
00060
00061 /* Opens a file with the given format
00062 * Used by "im_file.cpp" only. */
00063 imFormat* imFormatOpenAs(const char* file_name, const char* format, int *error);
00064
00065 /* Creates a file using the given format driver.
00066 * Used by "im_file.cpp" only. */
00067 imFormat* imFormatNew(const char* file_name, const char* format, int *error);
00068
00069
00070 /* File Format SDK */
00071
00072 /** Register a format driver.
00073 * \ingroup filesdk */
00074 void imFormatRegister(imFormat* iformat);
00075
00076
00077 }
00078
00079 #endif