- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/exr/ReaderWriterEXR.cpp
r12912 r13041 6 6 7 7 #if defined _WIN32 && !defined OSG_LIBRARY_STATIC 8 //Make the half format work against openEXR libs 8 //Make the half format work against openEXR libs 9 9 #define OPENEXR_DLL 10 10 #endif … … 94 94 Array2D<Rgba> pixels; 95 95 int width,height,numComponents; 96 96 97 97 try 98 { 98 { 99 99 C_IStream inStream(&fin); 100 100 RgbaInputFile rgbafile(inStream); … … 108 108 pixels.resizeErase (height, width); 109 109 110 rgbafile.setFrameBuffer((&pixels)[0][0] - dw.min.x - dw.min.y * width, 1, width); 110 rgbafile.setFrameBuffer((&pixels)[0][0] - dw.min.x - dw.min.y * width, 1, width); 111 111 rgbafile.readPixels(dw.min.y, dw.max.y); 112 112 } … … 120 120 return buffer; 121 121 } 122 122 123 123 //If there is no information in alpha channel do not store the alpha channel 124 124 numComponents = 3; … … 141 141 return NULL; 142 142 } 143 143 144 144 //Copy and allocate data to a unsigned char array that OSG can use for texturing 145 145 unsigned dataSize = (sizeof(half) * height * width * numComponents); … … 147 147 buffer = (unsigned char*)malloc(dataSize); 148 148 half* pOut = (half*) buffer; 149 149 150 150 for (long i = height-1; i >= 0; i--) 151 151 { … … 178 178 179 179 virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"exr"); } 180 180 181 181 virtual const char* className() const { return "EXR Image Reader"; } 182 182 183 183 virtual ReadResult readObject(std::istream& fin,const osgDB::ReaderWriter::Options* options =NULL) const 184 184 { … … 206 206 osgDB::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary); 207 207 if(!istream) return ReadResult::FILE_NOT_HANDLED; 208 208 209 209 ReadResult rr = readEXRStream(istream); 210 if(rr.validImage()) 210 if(rr.validImage()) 211 211 { 212 212 rr.getImage()->setFileName(fileName); … … 214 214 return rr; 215 215 } 216 216 217 217 virtual WriteResult writeImage(const osg::Image& image,std::ostream& fout,const Options*) const 218 218 { … … 234 234 235 235 bool success = writeEXRStream(img, fout, fileName); 236 236 237 237 fout.close(); 238 238 … … 276 276 //If texture is half format 277 277 if (dataType == GL_HALF_FLOAT_ARB) 278 { 278 { 279 279 for (long i = height-1; i >= 0; i--) 280 280 { … … 318 318 {outPixels[i][j].a = 1.0f;} 319 319 } 320 } 321 } 320 } 321 } 322 322 else 323 323 { … … 325 325 return false; 326 326 } 327 327 328 328 try 329 329 {
