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 OSGHDRIMAGEFILETYPE
00040 #define OSGHDRIMAGEFILETYPE
00041 #ifdef __sig
00042 #pragma once
00043 #endif
00044
00045 #include <OSGSystemDef.h>
00046
00047 #include <OSGBaseTypes.h>
00048 #include <OSGImageFileType.h>
00049
00050 OSG_BEGIN_NAMESPACE
00051
00056 class OSG_SYSTEMLIB_DLLMAPPING HDRImageFileType : public ImageFileType
00057 {
00058
00059 public:
00060
00061
00065 virtual ~HDRImageFileType (void);
00066
00068
00072 static HDRImageFileType& the (void);
00073
00075
00079 virtual bool read (ImagePtr &image, const Char8 *fileName);
00080
00081 virtual bool write (const ImagePtr &image, const Char8 *fileName);
00082
00083 virtual bool read ( ImagePtr &image,
00084 std::istream &is, const std::string &mimeType);
00085
00086 virtual bool write ( const ImagePtr &image,
00087 std::ostream &os, const std::string &mimeType);
00088
00091
00092 protected:
00093
00094
00098 HDRImageFileType ( const Char8 *mimeType,
00099 const Char8 *suffixArray[], UInt16 suffixByteCount,
00100 UInt32 flags );
00101
00103
00107 virtual UInt64 restoreData ( ImagePtr &image, const UChar8 *buffer,
00108 Int32 memSize = -1 );
00109
00110 virtual UInt64 storeData ( const ImagePtr &image, UChar8 *buffer,
00111 Int32 memSize = -1 );
00114
00115 private:
00116
00117 HDRImageFileType (const HDRImageFileType &obj);
00118
00119 typedef unsigned char RGBE[4];
00120
00121 bool checkHDR(FILE *file, int &width, int &height);
00122 bool checkHDR(std::istream &is, int &width, int &height);
00123
00124 bool radiance2fp(FILE *file, Real32 *data, int width, int height);
00125 bool radiance2fp(std::istream &is, Real32 *data, int width, int height);
00126
00127 bool freadcolrs(FILE *file, RGBE *scan, int width);
00128 bool freadcolrs(std::istream &is, RGBE *scan, int width);
00129
00130 bool oldreadcolrs(FILE *file, RGBE *scan, int width);
00131
00132 void RGBE2Float(RGBE rgbe, Real32 *fcol);
00133 void RGBE2Half( RGBE rgbe, Real16 *fcol);
00134
00135 int fwritecolrs(FILE *file, Real32 *scan, RGBE *rgbe_scan, int width, int height);
00136 int fwritecolrs(FILE *file, Real16 *scan, RGBE *rgbe_scan, int width, int height);
00137
00138 int fwritecolrs(std::ostream &os, Real32 *scan, RGBE *rgbe_scan, int width, int height);
00139 int fwritecolrs(std::ostream &os, Real16 *scan, RGBE *rgbe_scan, int width, int height);
00140
00141 int fwriteRGBE( FILE *file, RGBE *rgbe_scan, int width, int height);
00142 int fwriteRGBE( std::ostream &os, RGBE *rgbe_scan, int width, int height);
00143
00144 void half2RGBE(Real16 *fcol, RGBE rgbe);
00145 void float2RGBE(Real32 *fcol, RGBE rgbe);
00146
00147 typedef ImageFileType Inherited;
00148
00149 static HDRImageFileType _the;
00150
00151 };
00152
00153 typedef HDRImageFileType* HDRImageFileTypeP;
00154
00155 OSG_END_NAMESPACE
00156
00157 #endif // OSGHDRIMAGEFILETYPE