00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef OSGIMAGEFILETYPE_CLASS_DECLARATION
00040 #define OSGIMAGEFILETYPE_CLASS_DECLARATION
00041
00042 #include <list>
00043
00044 #include <OSGBaseTypes.h>
00045 #include <OSGIDString.h>
00046 #include <OSGImage.h>
00047
00048 OSG_BEGIN_NAMESPACE
00049
00054 class OSG_SYSTEMLIB_DLLMAPPING ImageFileType {
00055
00056
00057
00058
00059 public:
00060
00061
00065 enum
00066 {
00067 OSG_READ_SUPPORTED = 1,
00068 OSG_WRITE_SUPPORTED = 2
00069 };
00070
00072
00076 virtual ~ImageFileType (void);
00077
00079
00083 const Char8 *getMimeType (void) const;
00084
00085 const std::list<IDString> &getSuffixList(void) const;
00086
00087 virtual UInt32 getFlags(void) const;
00088
00090
00094 virtual bool read (ImagePtr &image, const Char8 *fileName ) = 0;
00095
00096 virtual bool write (const ImagePtr &image, const Char8 *fileName ) = 0;
00097
00098 virtual bool validateHeader( const Char8 *fileName, bool &implemented );
00099
00101
00105 static UInt64 restore ( ImagePtr &image, const UChar8 *buffer,
00106 Int32 memSize = -1 );
00107
00108 static UInt64 store ( const ImagePtr &image,
00109 const char *mimeType,
00110 UChar8 *buffer, Int32 memSize = -1 );
00111
00112 UInt64 store ( const ImagePtr &image, UChar8 *buffer,
00113 Int32 memSize = -1 );
00114
00115 virtual UInt64 maxBufferSize ( const ImagePtr &image );
00116
00118
00122 virtual UInt64 restoreData ( ImagePtr &image, const UChar8 *buffer,
00123 Int32 memSize = -1 );
00124
00125 virtual UInt64 storeData ( const ImagePtr &image, UChar8 *buffer,
00126 Int32 memSize = -1 );
00127
00128
00130
00134 void dump(void);
00135
00138
00139 protected:
00140
00141
00145 struct Head {
00146 Char8 mimeType[8];
00147 unsigned short pixelFormat;
00148 unsigned short width;
00149 unsigned short height;
00150 unsigned short depth;
00151 unsigned short mipmapCount;
00152 unsigned short frameCount;
00153 unsigned short frameDelay;
00154 unsigned short sideCount;
00155 unsigned short dataType;
00156 unsigned short _reserved3;
00157 unsigned short _reserved4;
00158 unsigned short attachmentSize;
00159
00160 bool netToHost (void);
00161 bool hostToNet (void);
00162
00163 };
00164
00167
00171 ImageFileType ( const Char8 *mimeType,
00172 const Char8 *suffixArray[],
00173 UInt16 suffixByteCount,
00174 UInt32 flags = OSG_READ_SUPPORTED );
00175
00177
00181 ImageFileType ( const ImageFileType &obj);
00182
00185
00186 private:
00187
00188 std::list<IDString> _suffixList;
00189
00190 IDString _mimeType;
00191
00192 UInt32 _flags;
00193 };
00194
00195 typedef ImageFileType* ImageFileTypeP;
00196
00197 OSG_END_NAMESPACE
00198
00199 #endif // OSGIMAGEFILETYPE_CLASS_DECLARATION