osg::EXRImageFileType Class Reference
[Image]

EXR File Handler. Used to read/write ILM OpenEXR files. See Image for a detailed description. More...

#include <OSGEXRImageFileType.h>

Inheritance diagram for osg::EXRImageFileType:

osg::ImageFileType

List of all members.

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 Types

Flags


enum  { OSG_READ_SUPPORTED = 1, OSG_WRITE_SUPPORTED = 2 }

Public Member Functions

Destructor


virtual ~EXRImageFileType (void)
Read/Write


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)
Set


void setOptions (const Char8 *options)
Get Methods


const Char8getMimeType (void) const
const std::list< IDString > & getSuffixList (void) const
virtual UInt32 getFlags (void) const
const Char8getOptions (void)
Read/Write


virtual bool read (ImagePtr &image, const Char8 *fileName)
virtual bool write (const ImagePtr &image, const Char8 *fileName)
virtual bool validateHeader (const Char8 *fileName, bool &implemented)
virtual std::string determineMimetypeFromStream (std::istream &is)
dump


void dump (void)

Static Public Member Functions

Get Methods


static EXRImageFileTypethe (void)

Protected Member Functions

Default Constructor


 EXRImageFileType (const Char8 *mimeType, const Char8 *suffixArray[], UInt16 suffixByteCount, UInt32 flags)
Buffer


virtual UInt64 restoreData (ImagePtr &image, const UChar8 *buffer, Int32 memSize=-1)
virtual UInt64 storeData (const ImagePtr &image, UChar8 *buffer, Int32 memSize=-1)
File I/O


bool isOpenExrFile (std::istream &is)

Protected Attributes

MTD Header


std::string _options

Private Types

typedef ImageFileType Inherited

Private Member Functions

 EXRImageFileType (const EXRImageFileType &obj)

Static Private Attributes

static EXRImageFileType _the


Detailed Description

Image File Type to read/write and store/restore Image objects as EXR data. Does depend on external libs, namely OpenEXR (by ILM).

Needs to be build with OSG_WITH_IMF

Definition at line 56 of file OSGEXRImageFileType.h.


Member Typedef Documentation

Definition at line 124 of file OSGEXRImageFileType.h.


Member Enumeration Documentation

anonymous enum [inherited]

Enumerator:
OSG_READ_SUPPORTED 
OSG_WRITE_SUPPORTED 

Definition at line 66 of file OSGImageFileType.h.

00067     {
00068         OSG_READ_SUPPORTED = 1,
00069         OSG_WRITE_SUPPORTED = 2
00070     };


Constructor & Destructor Documentation

EXRImageFileType::~EXRImageFileType ( void   )  [virtual]

Destructor

Definition at line 503 of file OSGEXRImageFileType.cpp.

00504 {
00505 }

EXRImageFileType::EXRImageFileType ( const Char8 mimeType,
const Char8 suffixArray[],
UInt16  suffixByteCount,
UInt32  flags 
) [protected]

Constructor used for the singleton object

Definition at line 487 of file OSGEXRImageFileType.cpp.

References FINFO.

00491     : ImageFileType ( mimeType, suffixArray, suffixByteCount, flags )
00492 {
00493     FINFO(( "EXRImageFileType: %s\n", mimeType));
00494 
00495     // TODO; needed for initialization of the library's global variables
00496     //Imf::staticInitialize();
00497 }

osg::EXRImageFileType::EXRImageFileType ( const EXRImageFileType obj  )  [private]


Member Function Documentation

EXRImageFileType & EXRImageFileType::the ( void   )  [static]

Class method to get the singleton Object

Definition at line 257 of file OSGEXRImageFileType.cpp.

References _the.

00258 {
00259     return _the;
00260 }

bool EXRImageFileType::read ( ImagePtr image,
std::istream &  is,
const std::string &  mimetype 
) [virtual]

Tries to fill the image object with the data read from the given input stream. Returns true on success.

Reimplemented from osg::ImageFileType.

Definition at line 271 of file OSGEXRImageFileType.cpp.

References FFATAL, osg::ImageFileType::getMimeType(), isOpenExrFile(), osg::Image::OSG_FLOAT16_IMAGEDATA, osg::Image::OSG_RGBA_PF, and SWARNING.

00272 {
00273 #ifdef OSG_WITH_IMF
00274     if (!is.good())
00275         return false;
00276 
00277     const char *dummy = "";
00278     StdIStream file(is, dummy);
00279 
00280     Imf::Int64 pos = file.tellg();
00281 
00282     bool check = isOpenExrFile(is);
00283 
00284     file.seekg(pos);
00285 
00286     if (!check)
00287     {
00288         FFATAL(( "Wrong format, no %s image given!\n",
00289                   mimetype.c_str() ));
00290         return false;
00291     }
00292 
00293     // TODO: check for mipmap levels,
00294     // look if line order is s.th. else than INCREASING_Y
00295     try
00296     {
00297         Int32 width, height, numImg = 1;
00298         Imf::RgbaInputFile stream(file);
00299 
00300         Imath::Box2i dw = stream.dataWindow();
00301         Imf::Array2D<Imf::Rgba> pixels;
00302 
00303         const Imf::Header &header = stream.header();
00304         const Imf::LineOrder &order = header.lineOrder();
00305 
00306         const Imf::EnvmapAttribute *envmap =
00307                    header.findTypedAttribute<Imf::EnvmapAttribute>("envmap");
00308 
00309         width  = dw.max.x - dw.min.x + 1;
00310         height = dw.max.y - dw.min.y + 1;
00311 
00312         pixels.resizeErase(height, width);
00313 
00314         if (envmap && envmap->value() == Imf::ENVMAP_CUBE)
00315         {
00316             numImg = 6;
00317             height /= numImg;
00318 
00319             if (width != height)
00320             {
00321                 FFATAL(( "Cubemaps must have squared size, but w=%d and h=%d!\n",
00322                           width, height ));
00323                 return false;
00324             }
00325         }
00326 
00327         stream.setFrameBuffer(&pixels[0][0] - dw.min.x - dw.min.y * width, 1, width);
00328         stream.readPixels(dw.min.y, dw.max.y);
00329 
00330         image->set( Image::OSG_RGBA_PF, width, height, 1, 1, 1, 0, 0,
00331                     Image::OSG_FLOAT16_IMAGEDATA, true, numImg );
00332         image->clearHalf();
00333 
00334         Real16 *data = (Real16*)(image->getData());
00335 
00336         for (Int32 side=numImg-1; side >=0; side--)
00337         {
00338             Int32 i, j, size = side * width * height * 4;
00339 
00340             for (Int32 y=side*height; y<(side+1)*height; y++)
00341             {
00342                 for (Int32 x=0; x<width; x++)
00343                 {
00344                     if (numImg == 1 || side == 2 || side == 3)
00345                     {
00346                         i = (2 * side + 1) * height - (y + 1); // new y
00347                         j = x;
00348                     }
00349                     else
00350                     {
00351                         i = y;
00352                         j = width - x - 1; // new x
00353                     }
00354 
00355                     *(data + size++) = (Real16)pixels[i][j].r;
00356                     *(data + size++) = (Real16)pixels[i][j].g;
00357                     *(data + size++) = (Real16)pixels[i][j].b;
00358                     *(data + size++) = (Real16)pixels[i][j].a;
00359                 }
00360             }
00361         }
00362 
00363         return true;
00364     }
00365     catch(std::exception &e)
00366     {
00367         FFATAL(( "Error while trying to read OpenEXR Image from stream: %s\n",
00368                   e.what() ));
00369         return false;
00370     }
00371 
00372 #else
00373     SWARNING << getMimeType()
00374              << " read is not compiled into the current binary "
00375              << std::endl;
00376     return false;
00377 #endif
00378 }

bool EXRImageFileType::write ( const ImagePtr image,
std::ostream &  os,
const std::string &  mimetype 
) [virtual]

Tries to write the image object to the given output stream. Returns true on success.

Reimplemented from osg::ImageFileType.

Definition at line 385 of file OSGEXRImageFileType.cpp.

References FFATAL, FWARNING, osg::ImageFileType::getMimeType(), osg::Image::OSG_FLOAT16_IMAGEDATA, and SWARNING.

00386 {
00387 #ifdef OSG_WITH_IMF
00388     if (!os.good())
00389         return false;
00390 
00391     if(image->getDataType() != Image::OSG_FLOAT16_IMAGEDATA)
00392     {
00393         FWARNING(("EXRImageFileType::write: Image has non float data type!\n"));
00394         return false;
00395     }
00396     if (image->getSideCount() == 6)
00397     {
00398         FWARNING(("EXRImageFileType::write: NYI for cubemaps\n"));  //TODO
00399         return false;
00400     }
00401 
00402     try
00403     {
00404         Int32 width  = image->getWidth();
00405         Int32 height = image->getHeight();
00406 
00407         const char *dummy = "";
00408         StdOStream file(os, dummy);
00409         Imf::Header header(width, height);
00410 
00411         Imf::RgbaOutputFile stream(file, header, Imf::WRITE_RGBA);
00412 
00413         Imf::Rgba *pixels = new Imf::Rgba[width * height];
00414 
00415         Real16 *data = ((Real16*)(image->getData()));
00416         Int32 size = width * height * 4;
00417 
00418         for (Int32 y=0; y<height; y++)
00419         {
00420             for (Int32 x=width-1; x>=0; x--)
00421             {
00422                 pixels[width * y + x].a = *(data + --size);
00423                 pixels[width * y + x].b = *(data + --size);
00424                 pixels[width * y + x].g = *(data + --size);
00425                 pixels[width * y + x].r = *(data + --size);
00426             }
00427         }
00428 
00429         stream.setFrameBuffer(pixels, 1, (int)width);
00430         stream.writePixels(height);
00431 
00432         delete [] pixels;
00433 
00434         return true;
00435     }
00436     catch(std::exception &e)
00437     {
00438         FFATAL(( "Error while trying to write OpenEXR Image from stream: %s\n",
00439                   e.what() ));
00440         return false;
00441     }
00442 
00443 #else
00444     SWARNING << getMimeType()
00445              << " write is not compiled into the current binary "
00446              << std::endl;
00447     return false;
00448 #endif
00449 }

UInt64 EXRImageFileType::restoreData ( ImagePtr image,
const UChar8 buffer,
Int32  memSize = -1 
) [protected, virtual]

Tries to restore the image data from the given memblock. Returns the amount of data read.

Reimplemented from osg::ImageFileType.

Definition at line 456 of file OSGEXRImageFileType.cpp.

00459 {
00460     image->setData(buffer);
00461 
00462     return image->getSize();
00463 }

UInt64 EXRImageFileType::storeData ( const ImagePtr image,
UChar8 buffer,
Int32  memSize = -1 
) [protected, virtual]

Tries to store the image data to the given memblock. Returns the amount of data written.

Reimplemented from osg::ImageFileType.

Definition at line 470 of file OSGEXRImageFileType.cpp.

00473 {
00474     UInt32 dataSize = image->getSize();
00475     const UChar8 *src = image->getData();
00476 
00477     if ( dataSize && src && buffer )
00478         memcpy( buffer, src, dataSize);
00479 
00480     return dataSize;
00481 }

bool EXRImageFileType::isOpenExrFile ( std::istream &  is  )  [protected]

Quick test for checking if file format is correct

Definition at line 511 of file OSGEXRImageFileType.cpp.

Referenced by read().

00512 {
00513 #ifdef OSG_WITH_IMF
00514     char bytes[4];
00515 
00516     is.read(bytes, sizeof(bytes));
00517 
00518     return !!is && Imf::isImfMagic(bytes);
00519 
00520 #else
00521     return false;
00522 #endif
00523 }

void ImageFileType::setOptions ( const Char8 options  )  [inherited]

Definition at line 243 of file OSGImageFileType.cpp.

References osg::ImageFileType::_options.

Referenced by osg::ImageFileHandler::setOptions().

00244 {
00245     _options = options;
00246 }

const Char8 * ImageFileType::getMimeType ( void   )  const [inherited]

const std::list< IDString > & ImageFileType::getSuffixList ( void   )  const [inherited]

Get method for the suffix list container

Definition at line 134 of file OSGImageFileType.cpp.

References osg::ImageFileType::_suffixList.

Referenced by osg::ImageFileHandler::addImageFileType().

00135 {
00136     return _suffixList; 
00137 }

UInt32 ImageFileType::getFlags ( void   )  const [virtual, inherited]

Get method for the flags indicating read/write support. Most image types only support reading.

Definition at line 117 of file OSGImageFileType.cpp.

References osg::ImageFileType::_flags.

Referenced by osg::ImageFileHandler::getSuffixList().

00118 {
00119     return _flags;
00120 }

const Char8 * ImageFileType::getOptions ( void   )  [inherited]

Get method for the mime type

Definition at line 124 of file OSGImageFileType.cpp.

References osg::ImageFileType::_options.

Referenced by osg::ImageFileHandler::getOptions().

00125 {
00126     return _options.c_str();
00127 }

bool ImageFileType::read ( ImagePtr image,
const Char8 fileName 
) [virtual, inherited]

Reimplemented in osg::DATImageFileType, and osg::HDRImageFileType.

Definition at line 141 of file OSGImageFileType.cpp.

Referenced by osg::ImageFileHandler::read().

00142 {
00143     std::ifstream is(fileName, std::ios::binary);
00144     if (is.good() == false)
00145         return false;
00146     return read(image, is, std::string());
00147 }

bool ImageFileType::write ( const ImagePtr image,
const Char8 fileName 
) [virtual, inherited]

Reimplemented in osg::DATImageFileType, and osg::HDRImageFileType.

Definition at line 151 of file OSGImageFileType.cpp.

Referenced by osg::ImageFileHandler::write().

00152 {
00153     std::ofstream os(fileName, std::ios::binary);
00154     if (os.good() == false)
00155         return false;
00156     return write(image, os, std::string());
00157 }

bool ImageFileType::validateHeader ( const Char8 fileName,
bool &  implemented 
) [virtual, inherited]

Reimplemented in osg::GIFImageFileType, osg::JPGImageFileType, osg::PNGImageFileType, osg::SGIImageFileType, and osg::TIFImageFileType.

Definition at line 161 of file OSGImageFileType.cpp.

Referenced by osg::ImageFileHandler::getFileType().

00162 {
00163     implemented = false;
00164     return true;
00165 }

std::string ImageFileType::determineMimetypeFromStream ( std::istream &  is  )  [virtual, inherited]

Tries to determine the mime type of the data provided by an input stream by searching for magic bytes. Returns the mime type or an empty string when the function could not determine the mime type.

Reimplemented in osg::BMPImageFileType, osg::DDSImageFileType, osg::GIFImageFileType, osg::JP2ImageFileType, osg::JPGImageFileType, osg::MNGImageFileType, osg::PNGImageFileType, osg::PNMImageFileType, osg::PSDImageFileType, osg::SGIImageFileType, and osg::TIFImageFileType.

Definition at line 199 of file OSGImageFileType.cpp.

00200 {
00201     return std::string();
00202 }

UInt64 ImageFileType::restore ( ImagePtr image,
const UChar8 buffer,
Int32  memSize = -1 
) [static, inherited]

Tries to restore the Imagedata from the given memblock. The buffer must include a ImageFileType::Head data block.

Definition at line 283 of file OSGImageFileType.cpp.

References osg::ImageFileType::Head::dataType, osg::ImageFileType::Head::depth, osg::ImageFileHandler::determineMimetypeFromSuffix(), FDEBUG, osg::ImageFileType::Head::frameCount, osg::ImageFileType::Head::frameDelay, FWARNING, osg::ImageFileType::Head::height, osg::ImageFileType::Head::mipmapCount, osg::ImageFileType::Head::netToHost(), osg::NullFC, osg::Image::OSG_UINT8_IMAGEDATA, osg::ImageFileType::Head::pixelFormat, osg::ImageFileType::Head::sideCount, osg::ImageFileType::Head::suffix, osg::ImageFileHandler::the(), and osg::ImageFileType::Head::width.

Referenced by osg::ClusterViewBuffer::recv(), osg::ImageFileHandler::restore(), and osg::SimpleSceneManager::useOpenSGLogo().

00285 {
00286     unsigned long   imageSize, headSize = sizeof(Head);
00287     unsigned long   size = 0, attachmentSize;
00288     Head            head;
00289     const UChar8    *data = buffer ? (buffer + headSize) : 0;
00290     ImageFileType   *type;
00291     std::string     mimeType;
00292     Image::Type     dataType;
00293 
00294     if ((image != osg::NullFC) && buffer && (memSize >= headSize)) {
00295 
00296         // Copy header. Otherwise netToHost would change the original
00297         // data structur.
00298         memcpy(&head,buffer,sizeof(Head));
00299         head.netToHost();
00300         mimeType = ImageFileHandler::the().determineMimetypeFromSuffix(head.suffix);
00301         
00302         if((type = ImageFileHandler::the().getFileType(mimeType.c_str(), 0)))
00303         {
00304             if (head.dataType)
00305               dataType = Image::Type(head.dataType);
00306             else
00307               dataType = Image::OSG_UINT8_IMAGEDATA;
00308 
00309             image->set(Image::PixelFormat(head.pixelFormat), head.width,
00310                        head.height, head.depth, head.mipmapCount,
00311                        head.frameCount, float(head.frameDelay) / 1000.0, 0,
00312                        dataType,true,head.sideCount );
00313             imageSize = static_cast<unsigned long>(
00314                 type->restoreData(image, data, memSize - headSize));
00315             attachmentSize = 0; // head->attachmentSize;
00316 
00317             /*
00318             if ((attachmentSize = head->attachmentSize))
00319             {
00320                 attData = (char*)(buffer + headSize + imageSize);
00321                 attKey = attData;
00322                 attValue = 0;
00323                 for (i = 0; i < (attachmentSize-1); i++) {
00324                     if (attData[i] == 0) 
00325                         if (attKey) {
00326                             attValue = &(attData[i+1]);
00327                             image->setAttachmentField (attKey,attValue);
00328                             attKey = attValue = 0;
00329                         }
00330                         else
00331                             attKey = &(attData[i+1]);
00332                 }
00333                 if (attKey || attValue) {
00334                     FFATAL (("Attachment restore error\n"));
00335                 }
00336             }
00337             */
00338 
00339             size = headSize + imageSize + attachmentSize;
00340       
00341             FDEBUG (( "Restore image data: %lu (%lu/%lu/%lu)\n",
00342                       size, headSize, imageSize, attachmentSize ));
00343 
00344         }
00345         else
00346         {
00347             imageSize = 0;
00348             FWARNING(("Can not restore image data, invalid mimeType: %s\n",
00349                       mimeType.empty() == false ? mimeType.c_str() : "Unknown"));
00350         }
00351 
00352       
00353     }
00354 
00355     return size;
00356 }

UInt64 ImageFileType::store ( const ImagePtr image,
const char *  mimeType,
UChar8 buffer,
Int32  memSize = -1 
) [static, inherited]

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 364 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().

00366 {
00367   ImageFileType   *type = ImageFileHandler::the().getFileType(mimeType);
00368   
00369   return type ? type->store(image, buffer, memSize) : 0;
00370 }

UInt64 ImageFileType::store ( const ImagePtr image,
UChar8 buffer,
Int32  memSize = -1 
) [inherited]

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 378 of file OSGImageFileType.cpp.

References osg::ImageFileType::_suffixList, osg::ImageFileType::Head::attachmentSize, osg::ImageFileType::Head::dataType, osg::ImageFileType::Head::depth, FDEBUG, FFATAL, osg::ImageFileType::Head::frameCount, osg::ImageFileType::Head::frameDelay, osg::ImageFileType::Head::height, osg::ImageFileType::Head::hostToNet(), osg::ImageFileType::Head::mipmapCount, osg::ImageFileType::Head::pixelFormat, osg::ImageFileType::Head::sideCount, osg::ImageFileType::storeData(), osg::ImageFileType::Head::suffix, and osg::ImageFileType::Head::width.

00380 {
00381     Head            *head;
00382     unsigned long   dataSize = 0, headSize = sizeof(Head);
00383     unsigned long   attachmentSize;
00384     UChar8          *dest;
00385     const UChar8    *src = image->getData();
00386     std::map<std::string, std::string>::const_iterator aI;
00387     std::string     value;
00388 
00389     attachmentSize = 0;
00390 
00391     // get attachment size
00392     /*
00393     ImageGenericAttPtr att=ImageGenericAttPtr::dcast(
00394         const_cast<Image*>(image.getCPtr())->findAttachment(
00395             ImageGenericAtt::getClassType().getGroupId()));
00396     if(att != NullFC)
00397     {
00398         for(i = 0; i < (att->getType().getNumFieldDescs()-1); ++i)
00399         {
00400             FieldDescription *fieldDesc=att->getType().getFieldDescription(i);
00401             Field *field=att->getField(i);
00402             if (fieldDesc && field) 
00403             {
00404                 field->getValueByStr(value);
00405                 attachmentSize += strlen( fieldDesc->getName().str() ) + 1;
00406                 attachmentSize += value.length() + 1;
00407               
00408                 std::cout << fieldDesc->getName().str() << std::endl; 
00409                 std::cout << value << std::endl; 
00410             }
00411             else 
00412             {
00413                 FFATAL (("Invalid Attachment in ImageFileType::store()\n"));
00414             }
00415         }
00416     }
00417     */
00418 
00419     if (buffer) 
00420     {
00421         head = (Head *)buffer;
00422 
00423         head->pixelFormat    = image->getPixelFormat();
00424         head->width          = image->getWidth();
00425         head->height         = image->getHeight();
00426         head->depth          = image->getDepth();
00427         head->mipmapCount    = image->getMipMapCount();
00428         head->frameCount     = image->getFrameCount();
00429         head->frameDelay     = short(image->getFrameDelay() * 1000.0);
00430         head->sideCount      = image->getSideCount();
00431         head->dataType       = image->getDataType();
00432         head->attachmentSize = static_cast<unsigned short>(attachmentSize);
00433         head->hostToNet();
00434       
00435         strcpy(head->suffix, _suffixList.front().str());
00436       
00437         dest = (UChar8 *) (buffer + headSize);
00438 
00439         if (src) 
00440             dataSize = static_cast<unsigned long>(
00441                 storeData(image, dest, memSize - headSize));
00442 
00443         dest = (UChar8 *) (buffer + headSize + dataSize);
00444 
00445         /*
00446         if(att != NullFC)
00447         {
00448             for(i = 0; i < (att->getType().getNumFieldDescs()-1); ++i)
00449             {
00450                 FieldDescription *fieldDesc=att->getType().getFieldDescription(i);
00451                 Field *field=att->getField(i);
00452                 if (field && fieldDesc) 
00453                 {
00454                     field->getValueByStr(value);
00455 
00456                     l = strlen( fieldDesc->getName().str() );
00457                     for (i = 0; i < l; i++)
00458                       *dest++ = fieldDesc->getName().str()[i];
00459                     *dest++ = 0;
00460                     l = value.length();
00461                     for (i = 0; i < l; i++)
00462                       *dest++ = value[i];
00463                     *dest++ = 0;
00464                 }
00465                 else
00466                 {
00467                     FFATAL (("Invalid Attachment in ImageFileType::store()\n"));
00468                 }
00469             }
00470         }
00471         */
00472 
00473         FDEBUG (( "Store image data: %lu (%lu/%lu/%lu)\n",
00474                   headSize + dataSize + attachmentSize, headSize, dataSize, 
00475                   attachmentSize ));
00476     }
00477     else {
00478         FFATAL (("Invalid buffer in ImageFileType::store()\n"));
00479     }
00480   
00481     return (headSize + dataSize + attachmentSize);
00482 
00483 }

UInt64 ImageFileType::maxBufferSize ( const ImagePtr image  )  [virtual, inherited]

Returns the max buffer size needed to store the Image (Head + mimeType specific data block)

Definition at line 490 of file OSGImageFileType.cpp.

References FINFO.

Referenced by osg::ClusterViewBuffer::send(), and osg::ImageFileHandler::store().

00491 {
00492     std::string value;
00493     unsigned long size, attachmentSize;
00494     unsigned long imageSize = image->getSize(), headSize = sizeof(Head);
00495 
00496     std::map<std::string, std::string>::const_iterator aI;
00497 
00498     attachmentSize = 0;
00499 
00500     // get attachment size
00501         /*
00502     ImageGenericAttPtr att=ImageGenericAttPtr::dcast(
00503         const_cast<Image*>(image.getCPtr())->findAttachment(
00504             ImageGenericAtt::getClassType().getGroupId()));
00505     if(att != NullFC)
00506     {
00507         for(i = 0; i < (att->getType().getNumFieldDescs()-1); ++i)
00508         {
00509             FieldDescription *fieldDesc=att->getType().getFieldDescription(i);
00510             Field *field=att->getField(i);
00511             if (field && fieldDesc) 
00512             {
00513                 field->getValueByStr(value);
00514                 attachmentSize += strlen( fieldDesc->getName().str() ) + 1;
00515                 attachmentSize += value.length() + 1;
00516             }
00517             else 
00518             {
00519                 FFATAL (("Invalid Attachment in ImageFileType::maxBufferSize()\n"));
00520             }
00521         }
00522     }
00523         */
00524 
00525     size = headSize + imageSize + attachmentSize;
00526   
00527     FINFO (( "ImageFileType::maxBufferSize(): %lu (%lu/%lu/%lu)\n", 
00528              size, headSize, imageSize, attachmentSize ));
00529   
00530     return size;
00531 }

void ImageFileType::dump ( void   )  [inherited]

The dump method just writes some object debugging info to the LOG stream

Definition at line 537 of file OSGImageFileType.cpp.

References osg::ImageFileType::_suffixList, osg::ImageFileType::getMimeType(), osg::LOG_DEBUG, and SLOG.

00538 {
00539     std::list<IDString>::iterator    sI;
00540 
00541     SLOG << getMimeType();
00542 
00543     if(_suffixList.empty())
00544     {
00545         SLOG << ": Suffix: ";
00546         for(sI = _suffixList.begin(); sI != _suffixList.end(); sI++)
00547         {
00548             Log().stream(OSG::LOG_DEBUG) << sI->str() << " ";
00549         }
00550     }
00551 
00552     std::cerr << std::endl;
00553 }


Member Data Documentation

Definition at line 126 of file OSGEXRImageFileType.h.

Referenced by the().

std::string osg::ImageFileType::_options [protected, inherited]


The documentation for this class was generated from the following files:

Generated on Mon Mar 17 11:12:34 2008 for OpenSG by  doxygen 1.5.5