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