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 #include <iosfwd>
00048
00049 OSG_BEGIN_NAMESPACE
00050
00055 class OSG_SYSTEMLIB_DLLMAPPING ImageFileType {
00056
00057
00058
00059
00060 public:
00061
00062
00066 enum
00067 {
00068 OSG_READ_SUPPORTED = 1,
00069 OSG_WRITE_SUPPORTED = 2
00070 };
00071
00073
00077 virtual ~ImageFileType (void);
00078
00080
00084 void setOptions(const Char8 *options);
00085
00086
00088
00092 const Char8 *getMimeType (void) const;
00093
00094 const std::list<IDString> &getSuffixList(void) const;
00095
00096 virtual UInt32 getFlags(void) const;
00097
00098 const Char8 *getOptions (void);
00099
00101
00105 virtual bool read (ImagePtr &image, const Char8 *fileName );
00106
00107 virtual bool write (const ImagePtr &image, const Char8 *fileName );
00108
00109 virtual bool validateHeader( const Char8 *fileName, bool &implemented );
00110
00111 virtual bool read (ImagePtr &image, std::istream &is, const std::string &mimetype);
00112
00113 virtual bool write (const ImagePtr &image, std::ostream &os, const std::string &mimetype);
00114
00115 virtual std::string determineMimetypeFromStream(std::istream &is);
00116
00118
00122 static UInt64 restore ( ImagePtr &image, const UChar8 *buffer,
00123 Int32 memSize = -1 );
00124
00125 static UInt64 store ( const ImagePtr &image,
00126 const char *mimeType,
00127 UChar8 *buffer, Int32 memSize = -1 );
00128
00129 UInt64 store ( const ImagePtr &image, UChar8 *buffer,
00130 Int32 memSize = -1 );
00131
00132 virtual UInt64 maxBufferSize ( const ImagePtr &image );
00133
00135
00139 virtual UInt64 restoreData ( ImagePtr &image, const UChar8 *buffer,
00140 Int32 memSize = -1 );
00141
00142 virtual UInt64 storeData ( const ImagePtr &image, UChar8 *buffer,
00143 Int32 memSize = -1 );
00144
00145
00147
00151 void dump(void);
00152
00155
00156 protected:
00157
00158
00162 struct Head {
00163 Char8 suffix[8];
00164 unsigned short pixelFormat;
00165 unsigned short width;
00166 unsigned short height;
00167 unsigned short depth;
00168 unsigned short mipmapCount;
00169 unsigned short frameCount;
00170 unsigned short frameDelay;
00171 unsigned short sideCount;
00172 unsigned short dataType;
00173 unsigned short _reserved3;
00174 unsigned short _reserved4;
00175 unsigned short attachmentSize;
00176
00177 bool netToHost (void);
00178 bool hostToNet (void);
00179
00180 };
00181
00182 std::string _options;
00183
00186
00190 ImageFileType ( const Char8 *mimeType,
00191 const Char8 *suffixArray[],
00192 UInt16 suffixByteCount,
00193 UInt32 flags = OSG_READ_SUPPORTED );
00194
00197
00198 private:
00199
00200
00204 ImageFileType (const ImageFileType &obj);
00205
00207
00211 const ImageFileType & operator= (const ImageFileType &obj);
00212
00215 std::list<IDString> _suffixList;
00216
00217 IDString _mimeType;
00218
00219 UInt32 _flags;
00220 };
00221
00222 typedef ImageFileType* ImageFileTypeP;
00223
00224 OSG_END_NAMESPACE
00225
00226 #endif // OSGIMAGEFILETYPE_CLASS_DECLARATION