#include <OSGDATImageFileType.h>
Inheritance diagram for osg::DATImageFileType:

Safe Store/Restore | |
| UInt64 | store (const ImagePtr &image, UChar8 *buffer, Int32 memSize=-1) |
| virtual UInt64 | maxBufferSize (const ImagePtr &image) |
| *static UInt64 | restore (ImagePtr &image, const UChar8 *buffer, Int32 memSize=-1) |
| static UInt64 | store (const ImagePtr &image, const char *mimeType, UChar8 *buffer, Int32 memSize=-1) |
Public Member Functions | |
Destructor | |
| *virtual | ~DATImageFileType (void) |
Read/Write | |
| *virtual bool | read (ImagePtr &image, const Char8 *fileName) |
| virtual bool | write (const ImagePtr &image, const Char8 *fileName) |
Buffer | |
| *virtual UInt64 | restoreData (ImagePtr &image, const UChar8 *buffer, Int32 memSize=-1) |
| virtual UInt64 | storeData (const ImagePtr &image, UChar8 *buffer, Int32 memSize=-1) |
Static Public Member Functions | |
Get Methods | |
| *static DATImageFileType & | the (void) |
Protected Member Functions | |
Default Constructor | |
| * | DATImageFileType (const Char8 *mimeType, const Char8 *suffixArray[], UInt16 suffixByteCount) |
Copy Constructor | |
| * | DATImageFileType (const DATImageFileType &obj) |
Private Types | |
| typedef ImageFileType | Inherited |
| enum | KeyType { UNKNOWN_KT = 0, OBJECT_FILE_NAME_KT, RESOLUTION_KT, SLICE_THICKNESS_KT, FORMAT_KT, FILE_OFFSET_KT, ENDIAN_KT } |
Static Private Member Functions | |
| static void | initTypeMap (void) |
Static Private Attributes | |
| static DATImageFileType | _the |
| static std::map< std::string, KeyType > | _keyStrMap |
| static std::map< std::string, FormatDesc > | _formatStrMap |
Classes | |
| struct | FormatDesc |
All the type specific code is included in the class. Does not depend on external libs.
Definition at line 55 of file OSGDATImageFileType.h.
|
|
Definition at line 116 of file OSGDATImageFileType.h. |
|
|
Definition at line 120 of file OSGDATImageFileType.h. 00121 { 00122 UNKNOWN_KT = 0, 00123 00124 OBJECT_FILE_NAME_KT, 00125 RESOLUTION_KT, 00126 SLICE_THICKNESS_KT, 00127 FORMAT_KT, 00128 FILE_OFFSET_KT, 00129 ENDIAN_KT 00130 };
|
|
|
Definition at line 65 of file OSGImageFileType.h. 00066 { 00067 OSG_READ_SUPPORTED = 1, 00068 OSG_WRITE_SUPPORTED = 2 00069 };
|
|
|
Destructor Definition at line 561 of file OSGDATImageFileType.cpp.
|
|
||||||||||||||||
|
Constructor used for the singleton object Definition at line 539 of file OSGDATImageFileType.cpp. 00542 : ImageFileType ( mimeType, suffixArray, suffixByteCount ) 00543 { 00544 return; 00545 }
|
|
|
Dummy Copy Constructor Definition at line 551 of file OSGDATImageFileType.cpp. 00552 : ImageFileType(obj) 00553 { 00554 return; 00555 }
|
|
|
Class method to get the singleton Object Definition at line 104 of file OSGDATImageFileType.cpp. References _the. 00105 { 00106 return _the; 00107 }
|
|
||||||||||||
|
Tries to fill the image object with the data read from the given fileName. Returns true on success. Implements osg::ImageFileType. Definition at line 118 of file OSGDATImageFileType.cpp. References _formatStrMap, _keyStrMap, osg::beginEditCP(), osg::endEditCP(), ENDIAN_KT, FILE_OFFSET_KT, osg::PathHandler::findFile(), FINFO, FLOG, FNOTICE, FORMAT_KT, FWARNING, osg::ImageFileHandler::getPathHandler(), initTypeMap(), osg::isGZip(), OBJECT_FILE_NAME_KT, osg::Image::OSG_FLOAT32_IMAGEDATA, osg::Image::OSG_INVALID_IMAGEDATATYPE, osg::Image::OSG_UINT16_IMAGEDATA, osg::Image::OSG_UINT32_IMAGEDATA, osg::Image::OSG_UINT8_IMAGEDATA, RESOLUTION_KT, SFATAL, SLICE_THICKNESS_KT, osg::ImageFileHandler::the(), and UNKNOWN_KT. 00120 { 00121 bool retCode = false; 00122 00123 std::ifstream inDat(fileName), inVolS; 00124 std::istream *inVol; 00125 std::string keyStr, objectFileName; 00126 const UInt32 lineBufferSize = 1024; 00127 Char8 *value, *keySepPos, lineBuffer[lineBufferSize]; 00128 const Char8 keySep = ':'; 00129 int fileOffset, keyL, valueL; 00130 std::map<std::string, KeyType>::iterator keyI; 00131 std::map<std::string, FormatDesc>::iterator formatI; 00132 KeyType key; 00133 Image::Type formatType; 00134 UInt32 res[3]; 00135 UInt32 bpv, dataSize = 0; 00136 Image::PixelFormat pixelFormat = OSG::Image::OSG_L_PF; 00137 char *dataBuffer = 0; 00138 bool needConversion = false; 00139 // default endian type is big endian 00140 bool big_endian = true; 00141 00142 res[0] = res[1] = res[2] = 0; 00143 fileOffset = 0; 00144 formatType = Image::OSG_INVALID_IMAGEDATATYPE; 00145 bpv = 0; 00146 dataSize = 0; 00147 dataBuffer = 0; 00148 00149 initTypeMap(); 00150 00151 beginEditCP(image); 00152 00153 // read the data file 00154 for ( lineBuffer[0] = 0; 00155 inDat.getline ( lineBuffer, lineBufferSize); 00156 lineBuffer[0] = 0 ) 00157 { 00158 if ((keySepPos = strchr(lineBuffer,keySep))) 00159 { 00160 keyL = keySepPos - lineBuffer; 00161 keyStr.assign( lineBuffer, keyL ); 00162 keyI = _keyStrMap.find(keyStr); 00163 key = ((keyI == _keyStrMap.end()) ? UNKNOWN_KT : keyI->second); 00164 value = keySepPos + 1; 00165 while (value && isspace(*value)) 00166 value++; 00167 valueL = strlen(value); 00168 while (isspace(value[valueL-1])) 00169 value[--valueL] = 0; 00170 switch (key) 00171 { 00172 case OBJECT_FILE_NAME_KT: 00173 objectFileName = value; 00174 image->setAttachmentField ( keyStr, value ); 00175 break; 00176 case RESOLUTION_KT: 00177 sscanf ( value, "%d %d %d", 00178 &(res[0]), &(res[1]), &(res[2])); 00179 image->setAttachmentField ( keyStr, value ); 00180 break; 00181 case FORMAT_KT: 00182 formatI = _formatStrMap.find(value); 00183 if (formatI != _formatStrMap.end()) 00184 { 00185 formatType = formatI->second.type; 00186 } 00187 else 00188 { 00189 formatType = Image::OSG_INVALID_IMAGEDATATYPE; 00190 } 00191 image->setAttachmentField ( keyStr, value ); 00192 break; 00193 case ENDIAN_KT: 00194 if(!strcmp(value, "LITTLE")) 00195 big_endian = false; 00196 image->setAttachmentField ( keyStr, value ); 00197 break; 00198 case FILE_OFFSET_KT: 00199 sscanf ( value, "%d", &fileOffset ); 00200 image->setAttachmentField ( keyStr, value ); 00201 break; 00202 case UNKNOWN_KT: 00203 FNOTICE (( "Uknown DAT file key: >%s<\n", 00204 keyStr.c_str() )); 00205 image->setAttachmentField ( keyStr, value ); 00206 break; 00207 case SLICE_THICKNESS_KT: 00208 default: 00209 image->setAttachmentField ( keyStr, value ); 00210 break; 00211 } 00212 } 00213 else 00214 { 00215 FINFO (("Skip DAT line\n")); 00216 } 00217 } 00218 00219 // check the setting and read the raw vol data 00220 if (objectFileName.empty() == false) 00221 { 00222 if ( (res[0] > 0) && (res[1] > 0) && (res[2] > 0) ) 00223 { 00224 if (formatType != Image::OSG_INVALID_IMAGEDATATYPE) 00225 { 00226 inVolS.open(objectFileName.c_str(), 00227 std::ios::in | std::ios::binary ); 00228 if (inVolS.fail() && ImageFileHandler::the().getPathHandler()) 00229 { 00230 // Try to find the file in the search path 00231 inVolS.clear(); // reset the error state 00232 PathHandler * ph = ImageFileHandler::the().getPathHandler(); 00233 inVolS.open(ph->findFile(objectFileName.c_str()).c_str(), 00234 std::ios::in | std::ios::binary ); 00235 } 00236 if (inVolS.fail()) 00237 { 00238 // Maybe compressed and name not changed? 00239 std::string gzname = objectFileName + ".gz"; 00240 inVolS.clear(); // reset the error state 00241 inVolS.open(gzname.c_str(), 00242 std::ios::in | std::ios::binary ); 00243 if (inVolS.fail() && 00244 ImageFileHandler::the().getPathHandler()) 00245 { 00246 // Try to find the file in the search path 00247 inVolS.clear(); // reset the error state 00248 PathHandler * ph = ImageFileHandler::the().getPathHandler(); 00249 inVolS.open(ph->findFile(gzname.c_str()).c_str(), 00250 std::ios::in | std::ios::binary ); 00251 } 00252 } 00253 if (inVolS.good()) 00254 { 00255 #ifdef OSG_ZSTREAM_SUPPORTED 00256 zip_istream *unzipper = NULL; 00257 #endif 00258 00259 image->set ( pixelFormat, res[0], res[1], res[2], 1, 1, 0.0, 0, formatType); 00260 image->clear(); 00261 00262 dataSize = image->getSize(); 00263 00264 UInt32 fileDataSize = dataSize; 00265 00266 if(isGZip(inVolS)) 00267 { 00268 #ifdef OSG_ZSTREAM_SUPPORTED 00269 unzipper = new zip_istream(inVolS); 00270 inVol = unzipper; 00271 #else 00272 SFATAL << "Compressed streams are not supported! Configure with --enable-png --with-png=DIR options." << std::endl; 00273 #endif 00274 } 00275 else 00276 { 00277 inVol = &inVolS; 00278 00279 // get length of the stream. 00280 inVol->seekg(0, std::ios::end); 00281 UInt64 length = inVol->tellg(); 00282 inVol->seekg(0, std::ios::beg); 00283 00284 if(length < dataSize - fileOffset) 00285 { 00286 // correct dataSize. 00287 fileDataSize = length; 00288 FWARNING (( "RAW file length to small!\n" )); 00289 } 00290 else if(length > dataSize - fileOffset) 00291 { 00292 FWARNING (( "RAW file length to big!\n" )); 00293 } 00294 } 00295 00296 if (needConversion) 00297 dataBuffer = new char [ dataSize ]; 00298 else 00299 dataBuffer = ((char *)(image->getData())); 00300 00301 if(fileOffset != 0) 00302 inVol->ignore ( fileOffset ); 00303 inVol->read ( dataBuffer, fileDataSize ); 00304 00305 #ifdef OSG_ZSTREAM_SUPPORTED 00306 if(unzipper != NULL) 00307 delete unzipper; 00308 #endif 00309 } 00310 else 00311 { 00312 FWARNING (( "Can not open %s image data\n", 00313 objectFileName.c_str() )); 00314 } 00315 } 00316 else 00317 { 00318 FWARNING (( "Invalid/Missing DAT Format\n" )); 00319 } 00320 } 00321 else 00322 { 00323 FWARNING (( "Invalid/Missing DAT Resolution\n" )); 00324 } 00325 } 00326 else 00327 { 00328 FWARNING (( "Invalid/Missing DAT ObjectFileName\n" )); 00329 } 00330 00331 // check/reformat vol data 00332 if (dataSize && dataBuffer) 00333 { 00334 // check host endian type 00335 UInt16 word = 0x0001; 00336 UInt8 *byte = (UInt8 *) &word; 00337 bool host_big_endian = byte[0] ? false : true; 00338 00339 if(big_endian != host_big_endian) 00340 image->swapDataEndian(); 00341 00342 if (needConversion) 00343 { 00344 FLOG (("DAT-Data convert not impl. yet !\n")); 00345 { 00346 switch (formatType) 00347 { 00348 case Image::OSG_UINT8_IMAGEDATA: 00349 break; 00350 case Image::OSG_UINT16_IMAGEDATA: 00351 break; 00352 case Image::OSG_UINT32_IMAGEDATA: 00353 break; 00354 case Image::OSG_FLOAT32_IMAGEDATA: 00355 break; 00356 default: 00357 ; 00358 } 00359 } 00360 } 00361 else 00362 { 00363 retCode = true; 00364 } 00365 } 00366 00367 00368 /* TODO 00369 std::ifstream in(fileName); 00370 Head head; 00371 void *headData = (void*)(&head); 00372 unsigned dataSize, headSize = sizeof(Head); 00373 00374 if ( in && 00375 in.read(static_cast<char *>(headData), 00376 headSize) && head.netToHost() && 00377 image.set ( Image::PixelFormat(head.pixelFormat), 00378 head.width, head.height, head.depth, head.mipmapCount, 00379 head.frameCount, float(head.frameDelay) / 1000.0) && 00380 (dataSize = image.getSize()) && 00381 in.read((char *)(image.getData()), dataSize )) 00382 retCode = true; 00383 else 00384 retCode = false; 00385 */ 00386 00387 endEditCP(image); 00388 00389 return retCode; 00390 }
|
|
||||||||||||
|
Tries to write the image object to the given fileName. Returns true on success. Implements osg::ImageFileType. Definition at line 397 of file OSGDATImageFileType.cpp. References _formatStrMap, initTypeMap(), and SWARNING. 00399 { 00400 initTypeMap(); 00401 00402 // ok we write always in big endian. 00403 #if BYTE_ORDER == LITTLE_ENDIAN 00404 image->swapDataEndian(); 00405 #endif 00406 00407 std::ofstream dat(fileName, std::ios::binary); 00408 if(!dat) 00409 { 00410 SWARNING << "DATImageFileType::write : Can not open output stream for file '" << fileName << "'!" << std::endl; 00411 return false; 00412 } 00413 00414 Real64 sT[3]; 00415 sT[0] = sT[1] = sT[2] = 1.0; 00416 const std::string *attr = image->findAttachmentField("SliceThickness"); 00417 if(attr != NULL) 00418 sscanf(attr->c_str(), "%lf %lf %lf", &sT[0], &sT[1], &sT[2]); 00419 00420 std::string format = "UCHAR"; 00421 for(std::map<std::string, FormatDesc>::iterator it = _formatStrMap.begin(); 00422 it != _formatStrMap.end();++it) 00423 { 00424 if((*it).second.type == image->getDataType()) 00425 { 00426 format = (*it).first; 00427 break; 00428 } 00429 } 00430 00431 std::string basename = fileName; 00432 std::string::size_type i = basename.rfind("."); 00433 if(i != std::string::npos) 00434 basename = basename.substr(0, i); 00435 basename += ".raw"; 00436 00437 std::string name = basename; 00438 i = name.rfind("/"); 00439 // on windows also a / is possible! 00440 #if defined(WIN32) 00441 if(i == std::string::npos) 00442 i = name.rfind("\\"); 00443 #endif 00444 if(i != std::string::npos) 00445 name = name.substr(i+1); 00446 00447 dat << "ObjectFileName: " << name << "\n"; 00448 dat << "TaggedFileName: ---\n"; 00449 dat << "Resolution: " << image->getWidth() << " " << image->getHeight() 00450 << " " << image->getDepth() << "\n"; 00451 dat << "SliceThickness: " << sT[0] << " " << sT[1] << " " << sT[2] << "\n"; 00452 dat << "Format: " << format << "\n"; 00453 dat << "NbrTags: 0\n"; 00454 dat << "ObjectType: TEXTURE_VOLUME_OBJECT\n"; 00455 dat << "ObjectModel: DENSITY\n"; 00456 dat << "GridType: EQUIDISTANT\n"; 00457 00458 dat.close(); 00459 00460 std::ofstream raw(basename.c_str(), std::ios::binary); 00461 if(!raw) 00462 { 00463 SWARNING << "DATImageFileType::write : Can not open output stream for file '" << basename << "'!" << std::endl; 00464 return false; 00465 } 00466 00467 raw.write ((const char *) image->getData(), image->getSize()); 00468 raw.close(); 00469 00470 // restore to original endian 00471 #if BYTE_ORDER == LITTLE_ENDIAN 00472 image->swapDataEndian(); 00473 #endif 00474 00475 /* 00476 ofstream out(fileName); 00477 Head head; 00478 const void *headData = (void*)(&head); 00479 unsigned dataSize = image.getSize(), headSize = sizeof(Head); 00480 00481 head.pixelFormat = image.getPixelFormat(); 00482 head.width = image.getWidth(); 00483 head.height = image.getHeight(); 00484 head.depth = image.getDepth(); 00485 head.mipmapCount = image.getMipMapCount(); 00486 head.frameCount = image.getFrameCount(); 00487 head.frameDelay = short(image.getFrameDelay() * 1000.0); 00488 head.hostToNet(); 00489 00490 if ( out && out.write(static_cast<const char *>(headData), headSize) && 00491 dataSize && 00492 out.write((char *)(image.getData()), dataSize) ) 00493 retCode = true; 00494 else 00495 retCode = false; 00496 */ 00497 00498 return true; 00499 }
|
|
||||||||||||||||
|
Tries to restore the image data from the given memblock. Returns the amount of data read. Reimplemented from osg::ImageFileType. Definition at line 507 of file OSGDATImageFileType.cpp.
|
|
||||||||||||||||
|
Tries to store the image data to the given memblock. Returns the amount of data written. Reimplemented from osg::ImageFileType. Definition at line 521 of file OSGDATImageFileType.cpp. 00524 { 00525 UInt32 dataSize = image->getSize(); 00526 const UChar8 *src = image->getData(); 00527 00528 if ( dataSize && src && buffer ) 00529 memcpy( buffer, src, dataSize); 00530 00531 return dataSize; 00532 }
|
|
|
Helper to initialize the type map; Definition at line 570 of file OSGDATImageFileType.cpp. References _formatStrMap, _keyStrMap, osg::DATImageFileType::FormatDesc::bpv, ENDIAN_KT, FILE_OFFSET_KT, FORMAT_KT, osg::DATImageFileType::FormatDesc::needConversion, OBJECT_FILE_NAME_KT, osg::Image::OSG_FLOAT32_IMAGEDATA, osg::Image::OSG_L_PF, osg::Image::OSG_UINT16_IMAGEDATA, osg::Image::OSG_UINT32_IMAGEDATA, osg::Image::OSG_UINT8_IMAGEDATA, osg::DATImageFileType::FormatDesc::pixelFormat, RESOLUTION_KT, SLICE_THICKNESS_KT, and osg::DATImageFileType::FormatDesc::type. Referenced by read(), and write(). 00571 { 00572 FormatDesc *desc; 00573 00574 if (_keyStrMap.empty()) 00575 { 00576 _keyStrMap["ObjectFileName"] = OBJECT_FILE_NAME_KT; 00577 _keyStrMap["Resolution"] = RESOLUTION_KT; 00578 _keyStrMap["SliceThickness"] = SLICE_THICKNESS_KT; 00579 _keyStrMap["Format"] = FORMAT_KT; 00580 _keyStrMap["Endian"] = ENDIAN_KT; 00581 _keyStrMap["FileOffset"] = FILE_OFFSET_KT; 00582 } 00583 00584 if (_formatStrMap.empty()) 00585 { 00586 desc = &(_formatStrMap["UCHAR"]); 00587 desc->type = Image::OSG_UINT8_IMAGEDATA; 00588 desc->bpv = 1; 00589 desc->pixelFormat = Image::OSG_L_PF; 00590 desc->needConversion = false; 00591 00592 desc = &(_formatStrMap["USHORT"]); 00593 desc->type = Image::OSG_UINT16_IMAGEDATA; 00594 desc->bpv = 2; 00595 desc->pixelFormat = Image::OSG_L_PF; 00596 desc->needConversion = false; 00597 00598 desc = &(_formatStrMap["UINT"]); 00599 desc->type = Image::OSG_UINT32_IMAGEDATA; 00600 desc->bpv = 4; // TODO; is this right ? 00601 desc->pixelFormat = Image::OSG_L_PF; 00602 desc->needConversion = false; 00603 00604 desc = &(_formatStrMap["ULONG"]); 00605 desc->type = Image::OSG_UINT32_IMAGEDATA; 00606 desc->bpv = 4; 00607 desc->pixelFormat = Image::OSG_L_PF; 00608 desc->needConversion = false; 00609 00610 desc = &(_formatStrMap["FLOAT"]); 00611 desc->type = Image::OSG_FLOAT32_IMAGEDATA; 00612 desc->bpv = 4; 00613 desc->pixelFormat = Image::OSG_L_PF; 00614 desc->needConversion = false; 00615 00616 desc = &(_formatStrMap["DOUBLE"]); 00617 desc->type = Image::OSG_FLOAT32_IMAGEDATA; // we have no OSG_FLOAT64_IMAGEDATA 00618 desc->bpv = 8; 00619 desc->pixelFormat = Image::OSG_L_PF; 00620 desc->needConversion = false; 00621 } 00622 00623 }
|
|
|
|
Get method for the suffix list container Definition at line 125 of file OSGImageFileType.cpp. References osg::ImageFileType::_suffixList. Referenced by osg::ImageFileHandler::addImageFileType(). 00126 { 00127 return _suffixList; 00128 }
|
|
|
Get method for the flags indicating read/write support. Most image types only support reading. Definition at line 116 of file OSGImageFileType.cpp. References osg::ImageFileType::_flags. Referenced by osg::ImageFileHandler::getSuffixList(). 00117 { 00118 return _flags; 00119 }
|
|
||||||||||||
|
Reimplemented in osg::GIFImageFileType, osg::JPGImageFileType, osg::PNGImageFileType, osg::SGIImageFileType, and osg::TIFImageFileType. Definition at line 132 of file OSGImageFileType.cpp. Referenced by osg::ImageFileHandler::getFileType().
|
|
||||||||||||||||
|
Tries to restore the Imagedata from the given memblock. The buffer must include a ImageFileType::Head data block. Definition at line 223 of file OSGImageFileType.cpp. References FDEBUG, FWARNING, osg::ImageFileHandler::getFileType(), osg::NullFC, osg::Image::OSG_UINT8_IMAGEDATA, osg::ImageFileType::restoreData(), and osg::ImageFileHandler::the(). Referenced by osg::ClusterViewBuffer::recv(), osg::ImageFileHandler::restore(), and osg::SimpleSceneManager::useOpenSGLogo(). 00225 { 00226 unsigned long imageSize, headSize = sizeof(Head); 00227 unsigned long size = 0, attachmentSize; 00228 Head head; 00229 const UChar8 *data = buffer ? (buffer + headSize) : 0; 00230 ImageFileType *type; 00231 const char *mimeType; 00232 Image::Type dataType; 00233 00234 if ((image != osg::NullFC) && buffer && (memSize >= headSize)) { 00235 00236 // Copy header. Otherwise netToHost would change the original 00237 // data structur. 00238 memcpy(&head,buffer,sizeof(Head)); 00239 head.netToHost(); 00240 mimeType = head.mimeType; 00241 00242 if((type = ImageFileHandler::the().getFileType(mimeType, 0))) 00243 { 00244 if (head.dataType) 00245 dataType = Image::Type(head.dataType); 00246 else 00247 dataType = Image::OSG_UINT8_IMAGEDATA; 00248 00249 image->set(Image::PixelFormat(head.pixelFormat), head.width, 00250 head.height, head.depth, head.mipmapCount, 00251 head.frameCount, float(head.frameDelay) / 1000.0, 0, 00252 dataType,true,head.sideCount ); 00253 imageSize = static_cast<unsigned long>( 00254 type->restoreData(image, data, memSize - headSize)); 00255 attachmentSize = 0; // head->attachmentSize; 00256 00257 /* 00258 if ((attachmentSize = head->attachmentSize)) 00259 { 00260 attData = (char*)(buffer + headSize + imageSize); 00261 attKey = attData; 00262 attValue = 0; 00263 for (i = 0; i < (attachmentSize-1); i++) { 00264 if (attData[i] == 0) 00265 if (attKey) { 00266 attValue = &(attData[i+1]); 00267 image->setAttachmentField (attKey,attValue); 00268 attKey = attValue = 0; 00269 } 00270 else 00271 attKey = &(attData[i+1]); 00272 } 00273 if (attKey || attValue) { 00274 FFATAL (("Attachment restore error\n")); 00275 } 00276 } 00277 */ 00278 00279 size = headSize + imageSize + attachmentSize; 00280 00281 FDEBUG (( "Restore image data: %lu (%lu/%lu/%lu)\n", 00282 size, headSize, imageSize, attachmentSize )); 00283 00284 } 00285 else 00286 { 00287 imageSize = 0; 00288 FWARNING(("Can not restore image data, invalid mimeType: %s\n", 00289 mimeType ? mimeType : "Unknown")); 00290 } 00291 00292 00293 } 00294 00295 return size; 00296 }
|
|
||||||||||||||||||||
|
Tries to store the raster data to the given mem block. Will include a ImageFileType::Head description and the data encoded as 'mimeType' Definition at line 304 of file OSGImageFileType.cpp. References osg::ImageFileHandler::getFileType(), osg::ImageFileType::store(), and osg::ImageFileHandler::the(). Referenced by osg::ClusterViewBuffer::send(), osg::ImageFileType::store(), and osg::ImageFileHandler::store(). 00306 { 00307 ImageFileType *type = ImageFileHandler::the().getFileType(mimeType); 00308 00309 return type ? type->store(image, buffer, memSize) : 0; 00310 }
|
|
||||||||||||||||
|
Tries to store the raster data to the given mem block. Will include a ImageFileType::Head description for the derived concreate mimeType. Definition at line 318 of file OSGImageFileType.cpp. References osg::ImageFileType::Head::attachmentSize, osg::ImageFileType::Head::dataType, osg::ImageFileType::Head::depth, FDEBUG, FFATAL, osg::ImageFileType::Head::frameCount, osg::ImageFileType::Head::frameDelay, osg::ImageFileType::getMimeType(), osg::ImageFileType::Head::height, osg::ImageFileType::Head::hostToNet(), osg::ImageFileType::Head::mimeType, osg::ImageFileType::Head::mipmapCount, osg::ImageFileType::Head::pixelFormat, osg::ImageFileType::Head::sideCount, osg::ImageFileType::storeData(), and osg::ImageFileType::Head::width. 00320 { 00321 Head *head; 00322 unsigned long dataSize = 0, headSize = sizeof(Head); 00323 unsigned long attachmentSize; 00324 UChar8 *dest; 00325 const UChar8 *src = image->getData(); 00326 std::map<std::string, std::string>::const_iterator aI; 00327 std::string value; 00328 00329 attachmentSize = 0; 00330 00331 // get attachment size 00332 /* 00333 ImageGenericAttPtr att=ImageGenericAttPtr::dcast( 00334 const_cast<Image*>(image.getCPtr())->findAttachment( 00335 ImageGenericAtt::getClassType().getGroupId())); 00336 if(att != NullFC) 00337 { 00338 for(i = 0; i < (att->getType().getNumFieldDescs()-1); ++i) 00339 { 00340 FieldDescription *fieldDesc=att->getType().getFieldDescription(i); 00341 Field *field=att->getField(i); 00342 if (fieldDesc && field) 00343 { 00344 field->getValueByStr(value); 00345 attachmentSize += strlen( fieldDesc->getName().str() ) + 1; 00346 attachmentSize += value.length() + 1; 00347 00348 std::cout << fieldDesc->getName().str() << std::endl; 00349 std::cout << value << std::endl; 00350 } 00351 else 00352 { 00353 FFATAL (("Invalid Attachment in ImageFileType::store()\n")); 00354 } 00355 } 00356 } 00357 */ 00358 00359 if (buffer) 00360 { 00361 head = (Head *)buffer; 00362 00363 head->pixelFormat = image->getPixelFormat(); 00364 head->width = image->getWidth(); 00365 head->height = image->getHeight(); 00366 head->depth = image->getDepth(); 00367 head->mipmapCount = image->getMipMapCount(); 00368 head->frameCount = image->getFrameCount(); 00369 head->frameDelay = short(image->getFrameDelay() * 1000.0); 00370 head->sideCount = image->getSideCount(); 00371 head->dataType = image->getDataType(); 00372 head->attachmentSize = static_cast<unsigned short>(attachmentSize); 00373 head->hostToNet(); 00374 00375 strcpy(head->mimeType, getMimeType()); 00376 00377 dest = (UChar8 *) (buffer + headSize); 00378 00379 if (src) 00380 dataSize = static_cast<unsigned long>( 00381 storeData(image, dest, memSize - headSize)); 00382 00383 dest = (UChar8 *) (buffer + headSize + dataSize); 00384 00385 /* 00386 if(att != NullFC) 00387 { 00388 for(i = 0; i < (att->getType().getNumFieldDescs()-1); ++i) 00389 { 00390 FieldDescription *fieldDesc=att->getType().getFieldDescription(i); 00391 Field *field=att->getField(i); 00392 if (field && fieldDesc) 00393 { 00394 field->getValueByStr(value); 00395 00396 l = strlen( fieldDesc->getName().str() ); 00397 for (i = 0; i < l; i++) 00398 *dest++ = fieldDesc->getName().str()[i]; 00399 *dest++ = 0; 00400 l = value.length(); 00401 for (i = 0; i < l; i++) 00402 *dest++ = value[i]; 00403 *dest++ = 0; 00404 } 00405 else 00406 { 00407 FFATAL (("Invalid Attachment in ImageFileType::store()\n")); 00408 } 00409 } 00410 } 00411 */ 00412 00413 FDEBUG (( "Store image data: %lu (%lu/%lu/%lu)\n", 00414 headSize + dataSize + attachmentSize, headSize, dataSize, 00415 attachmentSize )); 00416 } 00417 else { 00418 FFATAL (("Invalid buffer in ImageFileType::store()\n")); 00419 } 00420 00421 return (headSize + dataSize + attachmentSize); 00422 00423 }
|
|
|
Returns the max buffer size needed to store the Image (Head + mimeType specific data block) Definition at line 430 of file OSGImageFileType.cpp. References FINFO. Referenced by osg::ClusterViewBuffer::send(), and osg::ImageFileHandler::store(). 00431 { 00432 std::string value; 00433 unsigned long size, attachmentSize; 00434 unsigned long imageSize = image->getSize(), headSize = sizeof(Head); 00435 00436 std::map<std::string, std::string>::const_iterator aI; 00437 00438 attachmentSize = 0; 00439 00440 // get attachment size 00441 /* 00442 ImageGenericAttPtr att=ImageGenericAttPtr::dcast( 00443 const_cast<Image*>(image.getCPtr())->findAttachment( 00444 ImageGenericAtt::getClassType().getGroupId())); 00445 if(att != NullFC) 00446 { 00447 for(i = 0; i < (att->getType().getNumFieldDescs()-1); ++i) 00448 { 00449 FieldDescription *fieldDesc=att->getType().getFieldDescription(i); 00450 Field *field=att->getField(i); 00451 if (field && fieldDesc) 00452 { 00453 field->getValueByStr(value); 00454 attachmentSize += strlen( fieldDesc->getName().str() ) + 1; 00455 attachmentSize += value.length() + 1; 00456 } 00457 else 00458 { 00459 FFATAL (("Invalid Attachment in ImageFileType::maxBufferSize()\n")); 00460 } 00461 } 00462 } 00463 */ 00464 00465 size = headSize + imageSize + attachmentSize; 00466 00467 FINFO (( "ImageFileType::maxBufferSize(): %lu (%lu/%lu/%lu)\n", 00468 size, headSize, imageSize, attachmentSize )); 00469 00470 return size; 00471 }
|
|
|
The dump method just writes some object debugging info to the LOG stream Definition at line 477 of file OSGImageFileType.cpp. References osg::ImageFileType::_suffixList, osg::ImageFileType::getMimeType(), osg::LOG_DEBUG, and SLOG. 00478 { 00479 std::list<IDString>::iterator sI; 00480 00481 SLOG << getMimeType(); 00482 00483 if(_suffixList.empty()) 00484 { 00485 SLOG << ": Suffix: "; 00486 for(sI = _suffixList.begin(); sI != _suffixList.end(); sI++) 00487 { 00488 Log().stream(OSG::LOG_DEBUG) << sI->str() << " "; 00489 } 00490 } 00491 00492 std::cerr << std::endl; 00493 }
|
|
|
Referenced by the(). |
|
|
Definition at line 86 of file OSGDATImageFileType.cpp. Referenced by initTypeMap(), and read(). |
|
|
Definition at line 89 of file OSGDATImageFileType.cpp. Referenced by initTypeMap(), read(), and |