#include <OSGImageFileHandler.h>
Read Callback | |
| typedef ImagePtr(* | readcbfp )(const char *fileName, const char *mimeType) |
| void | setReadCB (readcbfp fp) |
| readcbfp | getReadCB (void) |
Public Member Functions | |
Destructor | |
| virtual | ~ImageFileHandler (void) |
Read/Write | |
| virtual ImagePtr | read (const char *fileName, const char *mimeType=0) |
| virtual bool | read (ImagePtr &image, const char *fileName, const char *mimeType=0) |
| virtual bool | write (const ImagePtr &image, const char *fileName, const char *mimeType=0) |
| virtual ImagePtr | read (std::istream &is, const std::string &mimeType) |
| virtual bool | read (ImagePtr &image, std::istream &is, const std::string &mimeType) |
| virtual bool | write (const ImagePtr &image, std::ostream &os, const std::string &mimeType) |
PathHandler | |
| virtual PathHandler * | getPathHandler (void) |
| virtual void | setPathHandler (PathHandler *pPathHandler) |
Options | |
| virtual bool | setOptions (const Char8 *suffix, const Char8 *options) |
| virtual const Char8 * | getOptions (const Char8 *suffix) |
Storage | |
| virtual UInt64 | restore (ImagePtr &image, const UChar8 *buffer, Int32 memSize=-1) |
| virtual UInt64 | store (const ImagePtr &image, const char *mimeType, UChar8 *buffer, Int32 memSize=-1) |
| virtual UChar8 * | store (const ImagePtr &image, UInt64 &memSize, const char *mimeType=0) |
Get Types | |
| ImageFileType * | getFileType (const char *mimeType, const char *fileName=0, bool validateHeader=false) |
| ImageFileType * | getDefaultType (void) |
| virtual int | getSuffixList (std::list< const Char8 * > &suffixList, UInt32 flags=ImageFileType::OSG_READ_SUPPORTED|ImageFileType::OSG_WRITE_SUPPORTED) |
| std::string | determineMimetypeFromName (const std::string &fileName) |
| std::string | determineMimetypeFromSuffix (const std::string &suffix) |
| std::string | determineMimetypeFromStream (std::istream &is) |
Print | |
| void | dump (void) |
Static Public Member Functions | |
Get Method | |
| static ImageFileHandler & | the (void) |
Private Types | |
| typedef std::map< std::string, ImageFileType * > | TypeMap |
Private Member Functions | |
Constructor | |
| ImageFileHandler (void) | |
Copy Constructor | |
| ImageFileHandler (const ImageFileHandler &obj) | |
Copy Operator | |
| const ImageFileHandler & | operator= (const ImageFileHandler &obj) |
Static Private Member Functions | |
| static bool | addImageFileType (ImageFileType &fileType) |
| static void | normalizeMimetype (std::string &mimetype) |
| static void | normalizeSuffix (std::string &suffix) |
Private Attributes | |
| std::map< std::string, ImageFileType * > | _suffixTypeMap |
| TypeMap | _typeMap |
| PathHandler * | _pPathHandler |
| readcbfp | _readFP |
Static Private Attributes | |
| static ImageFileHandler * | _the = 0 |
| static const std::string | _fileNameKey |
| static const std::string | _fullFilePathKey |
Friends | |
| class | ImageFileType |
See Image for details.
Definition at line 63 of file OSGImageFileHandler.h.
| typedef ImagePtr(* osg::ImageFileHandler::readcbfp)(const char *fileName, const char *mimeType) |
typedef std::map<std::string, ImageFileType*> osg::ImageFileHandler::TypeMap [private] |
Definition at line 181 of file OSGImageFileHandler.h.
| ImageFileHandler::~ImageFileHandler | ( | void | ) | [virtual] |
| ImageFileHandler::ImageFileHandler | ( | void | ) | [private] |
Default Constructor
Definition at line 696 of file OSGImageFileHandler.cpp.
00696 : 00697 _suffixTypeMap(), 00698 _typeMap(), 00699 _pPathHandler(0), 00700 _readFP(0) 00701 {}
| osg::ImageFileHandler::ImageFileHandler | ( | const ImageFileHandler & | obj | ) | [private] |
| ImagePtr ImageFileHandler::read | ( | const char * | fileName, | |
| const char * | mimeType = 0 | |||
| ) | [virtual] |
Creates a new image and tries to read the raster data from the given fileName. If the mimeType is not Null the method will try to find the according ImageFileType. Otherwise it will try to use the fileName suffix to determine the mimeType
Definition at line 273 of file OSGImageFileHandler.cpp.
References _readFP, osg::ImageBase::create(), osg::NullFC, and osg::subRefCP().
Referenced by osg::VRMLImageTextureDesc::endNode(), read(), and osg::Image::read().
00274 { 00275 if(_readFP != NULL) 00276 return _readFP(fileName, mimeType); 00277 00278 ImagePtr image = Image::create(); 00279 00280 if(read(image, fileName, mimeType) == false) 00281 { 00282 subRefCP(image); 00283 image = NullFC; 00284 } 00285 return image; 00286 }
| bool ImageFileHandler::read | ( | ImagePtr & | image, | |
| const char * | fileName, | |||
| const char * | mimeType = 0 | |||
| ) | [virtual] |
Tries to read the raster data from the given fileName into the given Image. If the mimeType is not Null the method will try to find the according ImageFileType. Otherwise it will try to use the fileName suffix to determine the mimeType
Definition at line 296 of file OSGImageFileHandler.cpp.
References _fileNameKey, _fullFilePathKey, _pPathHandler, osg::beginEditCP(), osg::endEditCP(), FDEBUG, osg::PathHandler::findFile(), osg::PathHandler::getBaseFile(), osg::Directory::getCurrent(), getFileType(), osg::ImageFileType::getMimeType(), osg::SceneFileHandler::getPathHandler(), osg::ImageBase::NameFieldMask, osg::ImageFileType::read(), SWARNING, and osg::SceneFileHandler::the().
00298 { 00299 bool retCode = false; 00300 std::string fullFilePath; 00301 00302 if( _pPathHandler != NULL ) 00303 { 00304 fullFilePath = _pPathHandler->findFile(fileName); 00305 } 00306 else 00307 { 00308 fullFilePath = fileName; 00309 } 00310 00311 if(fullFilePath.empty()) 00312 { 00313 SWARNING << "couldn't find image file " << fileName << std::endl; 00314 return false; 00315 } 00316 00317 ImageFileType *type = getFileType(mimeType, fullFilePath.c_str(), true); 00318 00319 if(type) 00320 { 00321 FDEBUG(("try to image read %s as %s\n", 00322 fullFilePath.c_str(), 00323 type->getMimeType())); 00324 00325 retCode = type->read(image, fullFilePath.c_str()); 00326 00327 if(retCode) 00328 { 00329 FDEBUG(("image: %dx%d\n", image->getWidth(), image->getHeight())); 00330 image->setAttachmentField(_fileNameKey, fileName); 00331 image->setAttachmentField(_fullFilePathKey, fullFilePath); 00332 00333 // converting the path to a absolute path. 00334 std::string abspath; 00335 if(fullFilePath[0] != '/' && fullFilePath[0] != '\\' && fullFilePath[1] != ':') 00336 { 00337 std::string base = SceneFileHandler::the().getPathHandler()->getBaseFile(); 00338 if(base.size() < 2 || 00339 (base[0] != '/' && base[0] != '\\' && base[1] != ':')) 00340 { 00341 const char *cdir = Directory::getCurrent(); 00342 abspath = cdir; 00343 #ifdef WIN32 00344 abspath += '\\'; 00345 #else 00346 abspath += '/'; 00347 #endif 00348 delete [] cdir; 00349 } 00350 00351 abspath += base; 00352 abspath += fullFilePath; 00353 } 00354 else 00355 { 00356 abspath = fullFilePath; 00357 } 00358 00359 beginEditCP(image, Image::NameFieldMask); 00360 image->setName(abspath); 00361 endEditCP(image, Image::NameFieldMask); 00362 } 00363 else 00364 { 00365 SWARNING << "could not read " << fullFilePath << std::endl; 00366 } 00367 } 00368 else 00369 { 00370 SWARNING << "could not read " << fullFilePath 00371 << "; unknown image format" << std::endl; 00372 } 00373 00374 return retCode; 00375 }
| bool ImageFileHandler::write | ( | const ImagePtr & | image, | |
| const char * | fileName, | |||
| const char * | mimeType = 0 | |||
| ) | [virtual] |
Tries to write the raster data (from the given Image) to the given fileName. If the mimeType is not Null the method will try to find the according ImageFileType. Otherwise it will try to use the fileName suffix to determine the mimeType
Definition at line 396 of file OSGImageFileHandler.cpp.
References _fileNameKey, getFileType(), osg::ImageFileType::getMimeType(), SINFO, SWARNING, and osg::ImageFileType::write().
Referenced by osg::Image::write().
00398 { 00399 bool retCode = false; 00400 ImageFileType *type; 00401 const std::string *fNAttachment; 00402 00403 if (!fileName && (fNAttachment = image->findAttachmentField(_fileNameKey))) 00404 fileName = fNAttachment->c_str(); 00405 00406 if ((type = getFileType(mimeType, fileName))) 00407 { 00408 SINFO << "try to write " << fileName << " as " 00409 << type->getMimeType() << std::endl; 00410 retCode = type->write(image, fileName); 00411 } 00412 else 00413 { 00414 SWARNING << "can't write " << fileName 00415 << "; unknown image format" << std::endl; 00416 } 00417 00418 return retCode; 00419 }
| ImagePtr ImageFileHandler::read | ( | std::istream & | is, | |
| const std::string & | mimeType | |||
| ) | [virtual] |
Creates a new image and tries to read the raster data from the given fileName. If the mimeType is not Null the method will try to find the according ImageFileType. Otherwise it will try to use the fileName suffix to determine the mimeType
Definition at line 423 of file OSGImageFileHandler.cpp.
References osg::ImageBase::create(), osg::NullFC, read(), and osg::subRefCP().
00424 { 00425 ImagePtr image = Image::create(); 00426 00427 if (read(image, is, mimeType) == false) 00428 { 00429 subRefCP(image); 00430 image = NullFC; 00431 } 00432 00433 return image; 00434 }
| bool ImageFileHandler::read | ( | ImagePtr & | image, | |
| std::istream & | is, | |||
| const std::string & | mimeType | |||
| ) | [virtual] |
Creates a new image and tries to read the raster data from the given fileName. If the mimeType is not Null the method will try to find the according ImageFileType. Otherwise it will try to use the fileName suffix to determine the mimeType
Definition at line 438 of file OSGImageFileHandler.cpp.
References getFileType(), and osg::ImageFileType::read().
00440 { 00441 ImageFileType *type = getFileType(mimeType.c_str()); 00442 return type == 0 ? false : type->read(image, is, mimeType); 00443 }
| bool ImageFileHandler::write | ( | const ImagePtr & | image, | |
| std::ostream & | os, | |||
| const std::string & | mimeType | |||
| ) | [virtual] |
Creates a new image and tries to read the raster data from the given fileName. If the mimeType is not Null the method will try to find the according ImageFileType. Otherwise it will try to use the fileName suffix to determine the mimeType
Definition at line 447 of file OSGImageFileHandler.cpp.
References getFileType(), and osg::ImageFileType::write().
00449 { 00450 ImageFileType *type = getFileType(mimeType.c_str()); 00451 return type == 0 ? false : type->write(image, os, mimeType); 00452 }
| void ImageFileHandler::setReadCB | ( | readcbfp | fp | ) |
Definition at line 378 of file OSGImageFileHandler.cpp.
References _readFP.
00379 { 00380 _readFP = fp; 00381 }
| ImageFileHandler::readcbfp ImageFileHandler::getReadCB | ( | void | ) |
Definition at line 383 of file OSGImageFileHandler.cpp.
References _readFP.
00384 { 00385 return _readFP; 00386 }
| PathHandler * ImageFileHandler::getPathHandler | ( | void | ) | [virtual] |
Returns the path handler used
Definition at line 458 of file OSGImageFileHandler.cpp.
References _pPathHandler.
Referenced by osg::VRMLInlineDesc::endNode(), osg::HDRImageFileType::read(), and osg::DATImageFileType::read().
00459 { 00460 return _pPathHandler; 00461 }
| void ImageFileHandler::setPathHandler | ( | PathHandler * | pPathHandler | ) | [virtual] |
Method to set the path handler.
Definition at line 467 of file OSGImageFileHandler.cpp.
References _pPathHandler.
Referenced by osg::SceneFileHandler::initPathHandler().
00468 { 00469 _pPathHandler = pPathHandler; 00470 }
Definition at line 665 of file OSGImageFileHandler.cpp.
References getFileType(), and osg::ImageFileType::setOptions().
00666 { 00667 if(suffix == NULL) 00668 return false; 00669 00670 ImageFileType *type = getFileType(suffix); 00671 if(type == NULL) 00672 return false; 00673 00674 type->setOptions(options); 00675 00676 return true; 00677 }
Definition at line 679 of file OSGImageFileHandler.cpp.
References getFileType(), and osg::ImageFileType::getOptions().
00680 { 00681 if(suffix == NULL) 00682 return NULL; 00683 00684 ImageFileType *type = getFileType(suffix); 00685 00686 if(type == NULL) 00687 return NULL; 00688 00689 return type->getOptions(); 00690 }
| UInt64 ImageFileHandler::restore | ( | ImagePtr & | image, | |
| const UChar8 * | buffer, | |||
| Int32 | memSize = -1 | |||
| ) | [virtual] |
Tries to restore the raster data from the given memblock into the given Image. If the mimeType is not Null the method will try to find the according ImageFileType. Otherwise it will try to use the fileName suffix to determine the mimeType
Definition at line 480 of file OSGImageFileHandler.cpp.
References osg::ImageFileType::restore().
00482 { 00483 return ImageFileType::restore(image, buffer, memSize); 00484 }
| UInt64 ImageFileHandler::store | ( | const ImagePtr & | image, | |
| const char * | mimeType, | |||
| UChar8 * | buffer, | |||
| Int32 | memSize = -1 | |||
| ) | [virtual] |
Tries to store the raster data (from the given Image) to the given memBlock. If the mimeType is not Null the method will try to find the according ImageFileType. Otherwise it will try to use the fileName suffix to determine the mimeType
Definition at line 494 of file OSGImageFileHandler.cpp.
References getDefaultType(), getFileType(), and osg::ImageFileType::store().
00496 { 00497 ImageFileType *type; 00498 00499 type = mimeType ? getFileType(mimeType) : getDefaultType(); 00500 00501 return type->store(image, buffer, memSize); 00502 }
| UChar8 * ImageFileHandler::store | ( | const ImagePtr & | image, | |
| UInt64 & | memSize, | |||
| const char * | mimeType = 0 | |||
| ) | [virtual] |
Tries to store the raster data (from the given Image) to a new memBlock. The method will automatically allocate and return a sufficient amount of memory with new. The application has to free the memory with 'delete [] mem' If the mimeType is not Null the method will try to find the according ImageFileType. Otherwise it will try to use the fileName suffix to determine the mimeType
Definition at line 514 of file OSGImageFileHandler.cpp.
References FFATAL, getDefaultType(), getFileType(), osg::ImageFileType::getMimeType(), osg::ImageFileType::maxBufferSize(), and osg::ImageFileType::store().
00516 { 00517 ImageFileType *type = 0; 00518 UChar8 *mem = 0; 00519 00520 type = mimeType ? getFileType(mimeType) : getDefaultType(); 00521 memSize = type->maxBufferSize(image); 00522 00523 if(memSize) 00524 { 00525 mem = new UChar8[size_t(memSize)]; 00526 memSize = type->store(image, mem, Int32(memSize)); 00527 } 00528 else 00529 { 00530 FFATAL(("Can not store the image as %s\n", type->getMimeType())); 00531 } 00532 00533 return mem; 00534 }
| ImageFileType * ImageFileHandler::getFileType | ( | const char * | mimeType, | |
| const char * | fileName = 0, |
|||
| bool | validateHeader = false | |||
| ) |
Method to find a ImageFileHandler for the given mimeType for fileName suffix. Returns the ImageFileHandler object or Null.
Definition at line 94 of file OSGImageFileHandler.cpp.
References _suffixTypeMap, _the, _typeMap, FWARNING, normalizeMimetype(), normalizeSuffix(), and osg::ImageFileType::validateHeader().
Referenced by getOptions(), read(), osg::ClusterViewBuffer::setImgTransType(), setOptions(), osg::ImageFileType::store(), store(), and write().
00097 { 00098 std::string suffix; 00099 ImageFileType *type = 0; 00100 std::map<std::string, ImageFileType *>::iterator sI; 00101 const char separator = '.'; 00102 int i, l; 00103 00104 if(mimeType && *mimeType) 00105 { 00106 std::string mt = mimeType; 00107 normalizeMimetype(mt); 00108 if (mt.find('/') == std::string::npos) 00109 mt.insert(0, "image/"); 00110 TypeMap::iterator tIt = _the->_typeMap.find(mt); 00111 if (tIt != _the->_typeMap.end()) 00112 type = tIt->second; 00113 if (!type) { 00114 FWARNING (("Invalid mimeType %s in getFileType()\n", mimeType)); 00115 } 00116 } 00117 00118 if(!type && fileName && *fileName) 00119 { 00120 // check file suffix 00121 if(!type) 00122 { 00123 l = strlen(fileName); 00124 for(i = l - 1; i >= 0; i--) 00125 { 00126 if(fileName[i] == separator) 00127 break; 00128 } 00129 00130 if(i >= 0) 00131 { 00132 suffix.assign(&(fileName[i + 1])); 00133 normalizeSuffix(suffix); 00134 sI = _suffixTypeMap.find(suffix); 00135 type = (sI == _suffixTypeMap.end()) ? 0 : sI->second; 00136 } 00137 } 00138 } 00139 00140 if(validateHeader) 00141 { 00142 // now validate the header of the file 00143 bool implemented = false; 00144 if(fileName && *fileName && 00145 type != NULL && !type->validateHeader(fileName, implemented)) 00146 { 00147 FWARNING (("Found wrong image header trying to autodetect image type!\n")); 00148 for(sI = _suffixTypeMap.begin(); sI != _suffixTypeMap.end(); ++sI) 00149 { 00150 type = sI->second; 00151 if(type != NULL && type->validateHeader(fileName, implemented)) 00152 { 00153 if(implemented) 00154 { 00155 FWARNING (("Autodetected '%s' image type!\n", sI->first.c_str())); 00156 return type; 00157 } 00158 } 00159 } 00160 FWARNING (("Couldn't autodetect image type!\n")); 00161 return NULL; 00162 } 00163 } 00164 00165 return type; 00166 }
| ImageFileType * ImageFileHandler::getDefaultType | ( | void | ) |
Returns the default OpenSG ImageFileType
Definition at line 172 of file OSGImageFileHandler.cpp.
References _suffixTypeMap, and FFATAL.
Referenced by store().
00173 { 00174 std::string dSuffix("opensg"); 00175 00176 std::map<std::string, 00177 ImageFileType *>::iterator sI = _suffixTypeMap.find(dSuffix); 00178 00179 00180 ImageFileType *type = (sI == _suffixTypeMap.end()) ? 0 : sI->second; 00181 00182 if(!type) 00183 { 00184 FFATAL(("Can not find any default (suffix:%s) image handler\n", 00185 dSuffix.c_str())); 00186 } 00187 00188 return type; 00189 }
| Int32 ImageFileHandler::getSuffixList | ( | std::list< const Char8 * > & | suffixList, | |
| UInt32 | flags = ImageFileType::OSG_READ_SUPPORTED | ImageFileType::OSG_WRITE_SUPPORTED | |||
| ) | [virtual] |
Returns the list of supported image suffixes
Definition at line 196 of file OSGImageFileHandler.cpp.
References _suffixTypeMap, and osg::ImageFileType::getFlags().
00198 { 00199 Int32 count = 0; 00200 std::map<std::string, ImageFileType *>::iterator sI; 00201 00202 suffixList.clear(); 00203 00204 for ( sI = _suffixTypeMap.begin(); sI != _suffixTypeMap.end(); ++sI) 00205 { 00206 ImageFileType *type = sI->second; 00207 if(type->getFlags() & flags) 00208 { 00209 suffixList.push_back(sI->first.c_str()); 00210 count++; 00211 } 00212 } 00213 00214 return count; 00215 }
| std::string ImageFileHandler::determineMimetypeFromName | ( | const std::string & | fileName | ) |
Tries to determine the mime type from the file name.
Definition at line 221 of file OSGImageFileHandler.cpp.
References _suffixTypeMap, and normalizeSuffix().
00222 { 00223 // Determine the suffix of the filename 00224 std::string::size_type pos = fileName.rfind('.'); 00225 if (pos == std::string::npos) 00226 return std::string(); 00227 std::string suffix = fileName.substr(pos + 1); 00228 normalizeSuffix(suffix); 00229 00230 // Try to find the suffix in the map of extensions 00231 std::map<std::string, ImageFileType *>::iterator it = _suffixTypeMap.find(suffix); 00232 return it != _suffixTypeMap.end() ? std::string(it->second->getMimeType()) : std::string(); 00233 }
| std::string ImageFileHandler::determineMimetypeFromSuffix | ( | const std::string & | suffix | ) |
Tries to determine the mime type from the suffix.
Definition at line 239 of file OSGImageFileHandler.cpp.
References _suffixTypeMap, and normalizeSuffix().
Referenced by osg::ImageFileType::restore().
00240 { 00241 std::string s = suffix; 00242 normalizeSuffix(s); 00243 00244 // Try to find the suffix in the map of extensions 00245 std::map<std::string, ImageFileType *>::iterator it = _suffixTypeMap.find(s); 00246 return it != _suffixTypeMap.end() ? std::string(it->second->getMimeType()) : std::string(); 00247 }
| std::string ImageFileHandler::determineMimetypeFromStream | ( | std::istream & | is | ) |
tries to determine the mimetype of a stream.
Definition at line 253 of file OSGImageFileHandler.cpp.
References _typeMap.
00254 { 00255 std::string mimetype; 00256 TypeMap::iterator it; 00257 for (it = _typeMap.begin(); it != _typeMap.end(); ++it) 00258 { 00259 mimetype = it->second->determineMimetypeFromStream(is); 00260 if (mimetype.empty() == false) 00261 break; 00262 } 00263 return mimetype; 00264 }
| void ImageFileHandler::dump | ( | void | ) |
The dump method just writes some object debugging info to the LOG stream
Definition at line 540 of file OSGImageFileHandler.cpp.
References _suffixTypeMap, and FLOG.
00541 { 00542 std::map<std::string, ImageFileType *>::iterator sI; 00543 00544 for(sI = _suffixTypeMap.begin(); sI != _suffixTypeMap.end(); sI++) 00545 { 00546 FLOG (( "Image suffix: %s, mimeType: %s\n", 00547 sI->first.c_str(), sI->second->getMimeType() )); 00548 } 00549 }
| ImageFileHandler & ImageFileHandler::the | ( | void | ) | [static] |
Static method the get the Singleton Object
Definition at line 713 of file OSGImageFileHandler.cpp.
References _the.
Referenced by osg::VRMLInlineDesc::endNode(), osg::VRMLImageTextureDesc::endNode(), osg::SceneFileHandler::initPathHandler(), osg::Image::read(), osg::HDRImageFileType::read(), osg::DATImageFileType::read(), osg::ImageFileType::restore(), osg::ClusterViewBuffer::setImgTransType(), osg::ImageFileType::store(), and osg::Image::write().
00714 { 00715 if(_the == NULL) 00716 _the = new ImageFileHandler; 00717 return *_the; 00718 }
| bool ImageFileHandler::addImageFileType | ( | ImageFileType & | fileType | ) | [static, private] |
Internal Method to add a new ImageFileType
Definition at line 555 of file OSGImageFileHandler.cpp.
References _suffixTypeMap, _the, _typeMap, osg::ImageFileType::getMimeType(), osg::ImageFileType::getSuffixList(), normalizeMimetype(), normalizeSuffix(), and SWARNING.
Referenced by osg::ImageFileType::ImageFileType().
00556 { 00557 bool retCode = false; 00558 std::list<IDString >::const_iterator sI; 00559 std::map<std::string, ImageFileType *>::iterator smI; 00560 std::string suffix; 00561 00562 if(!_the) 00563 _the = new ImageFileHandler; 00564 00565 for( sI = fileType.getSuffixList().begin(); 00566 sI != fileType.getSuffixList().end(); 00567 ++sI) 00568 { 00569 suffix.assign(sI->str()); 00570 normalizeSuffix(suffix); 00571 smI = _the->_suffixTypeMap.find(suffix); 00572 if(smI != _the->_suffixTypeMap.end()) 00573 { 00574 SWARNING << "Can't add an image file type with suffix " 00575 << suffix << " a second time" << std::endl; 00576 } 00577 else 00578 { 00579 _the->_suffixTypeMap[suffix] = &fileType; 00580 retCode = true; 00581 } 00582 } 00583 00584 std::string mimetype = fileType.getMimeType(); 00585 normalizeMimetype(mimetype); 00586 TypeMap::iterator tIt = _the->_typeMap.find(mimetype); 00587 if (tIt != _the->_typeMap.end()) 00588 { 00589 SWARNING << "Can't add an image file type with mimetype " 00590 << mimetype << " a second time" << std::endl; 00591 } 00592 else 00593 _the->_typeMap[mimetype] = &fileType; 00594 00595 return retCode; 00596 }
| void ImageFileHandler::normalizeMimetype | ( | std::string & | mimetype | ) | [static, private] |
Normalizes a mime type, i.e. removes parameters and whitespaces and transforms it to lowercase
Definition at line 603 of file OSGImageFileHandler.cpp.
Referenced by addImageFileType(), and getFileType().
00604 { 00605 // Remove any parameters 00606 std::string::size_type endpos = mimetype.find(';'); 00607 if (endpos == 0) 00608 { 00609 mimetype.erase(); 00610 return; 00611 } 00612 if (endpos != std::string::npos) 00613 --endpos; 00614 00615 // Remove trailing whitespace 00616 endpos = mimetype.find_last_not_of(" \t\r\n", endpos); 00617 if (endpos == std::string::npos) 00618 { 00619 mimetype.erase(); 00620 return; 00621 } 00622 mimetype.erase(endpos + 1); 00623 00624 // Remove leading whitespace 00625 std::string::size_type startpos = mimetype.find_first_not_of(" \t\r\n"); 00626 if (startpos == std::string::npos) 00627 { 00628 mimetype.erase(); 00629 return; 00630 } 00631 mimetype.erase(0, startpos); 00632 00633 // Transform to lower case 00634 std::transform(mimetype.begin(), mimetype.end(), mimetype.begin(), ::tolower); 00635 }
| void ImageFileHandler::normalizeSuffix | ( | std::string & | suffix | ) | [static, private] |
Normalizes a suffix, i.e. removes whitespaces and transforms it to lowercase
Definition at line 641 of file OSGImageFileHandler.cpp.
Referenced by addImageFileType(), determineMimetypeFromName(), determineMimetypeFromSuffix(), and getFileType().
00642 { 00643 // Remove trailing whitespace 00644 std::string::size_type endpos = suffix.find_last_not_of(" \t\r\n"); 00645 if (endpos == std::string::npos) 00646 { 00647 suffix.erase(); 00648 return; 00649 } 00650 suffix.erase(endpos + 1); 00651 00652 // Remove leading whitespace 00653 std::string::size_type startpos = suffix.find_first_not_of(" \t\r\n"); 00654 if (startpos == std::string::npos) 00655 { 00656 suffix.erase(); 00657 return; 00658 } 00659 suffix.erase(0, startpos); 00660 00661 // Transform to lower case 00662 std::transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower); 00663 }
| const ImageFileHandler& osg::ImageFileHandler::operator= | ( | const ImageFileHandler & | obj | ) | [private] |
friend class ImageFileType [friend] |
Definition at line 65 of file OSGImageFileHandler.h.
ImageFileHandler * ImageFileHandler::_the = 0 [static, private] |
Definition at line 177 of file OSGImageFileHandler.h.
Referenced by addImageFileType(), getFileType(), and the().
std::map<std::string, ImageFileType *> osg::ImageFileHandler::_suffixTypeMap [private] |
Definition at line 179 of file OSGImageFileHandler.h.
Referenced by addImageFileType(), determineMimetypeFromName(), determineMimetypeFromSuffix(), dump(), getDefaultType(), getFileType(), and getSuffixList().
TypeMap osg::ImageFileHandler::_typeMap [private] |
Definition at line 183 of file OSGImageFileHandler.h.
Referenced by addImageFileType(), determineMimetypeFromStream(), and getFileType().
PathHandler* osg::ImageFileHandler::_pPathHandler [private] |
Definition at line 191 of file OSGImageFileHandler.h.
Referenced by getPathHandler(), read(), and setPathHandler().
readcbfp osg::ImageFileHandler::_readFP [private] |
Definition at line 192 of file OSGImageFileHandler.h.
Referenced by getReadCB(), read(), and setReadCB().
const std::string ImageFileHandler::_fileNameKey [static, private] |
const std::string ImageFileHandler::_fullFilePathKey [static, private] |
1.5.5