IM: im_format.h Source File

IM - An Imaging Tool

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.1 2005/04/02 22:07:00 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 
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() = 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 /* Creates a file using the given format driver.
00062  * Used by "im_file.cpp" only. */
00063 imFormat* imFormatNew(const char* file_name, const char* format, int *error);
00064 
00065 /* Registers all the internal formats.
00066  * Used by "im_format.cpp" only. */
00067 void imFormatRegisterAll(void);
00068 
00069 
00070 /* File Format SDK */
00071 
00072 /** Format function initialization definition.
00073  * \ingroup filesdk */
00074 typedef imFormat* (*imFormatFunc)();
00075 
00076 /** Register a format driver.
00077  * \ingroup filesdk */
00078 void imFormatRegister(imFormatFunc format_init);
00079 
00080 
00081 }
00082 
00083 #endif