Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::TIFImageFileType Class Reference
[Image]

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

#include <OSGTIFImageFileType.h>

Inheritance diagram for osg::TIFImageFileType:

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 }
Flags
enum  { OSG_READ_SUPPORTED = 1, OSG_WRITE_SUPPORTED = 2 }
Flags
enum  { OSG_READ_SUPPORTED = 1, OSG_WRITE_SUPPORTED = 2 }
Flags
enum  { OSG_READ_SUPPORTED = 1, OSG_WRITE_SUPPORTED = 2 }
Flags
enum  { OSG_READ_SUPPORTED = 1, OSG_WRITE_SUPPORTED = 2 }
Flags
enum  { OSG_READ_SUPPORTED = 1, OSG_WRITE_SUPPORTED = 2 }
Flags
enum  { OSG_READ_SUPPORTED = 1, OSG_WRITE_SUPPORTED = 2 }
Flags
enum  { OSG_READ_SUPPORTED = 1, OSG_WRITE_SUPPORTED = 2 }
Flags
enum  { OSG_READ_SUPPORTED = 1, OSG_WRITE_SUPPORTED = 2 }

Public Member Functions

Get Methods
*const Char8getMimeType (void) const
const std::list< IDString > & getSuffixList (void) const
virtual UInt32 getFlags (void) const
dump
*void dump (void)
Get Methods
*const Char8getMimeType (void) const
const std::list< IDString > & getSuffixList (void) const
virtual UInt32 getFlags (void) const
Raw Store/Restore
*virtual UInt64 restoreData (ImagePtr &image, const UChar8 *buffer, Int32 memSize=-1)
virtual UInt64 storeData (const ImagePtr &image, UChar8 *buffer, Int32 memSize=-1)
dump
*void dump (void)
Get Methods
*const Char8getMimeType (void) const
const std::list< IDString > & getSuffixList (void) const
virtual UInt32 getFlags (void) const
Raw Store/Restore
*virtual UInt64 restoreData (ImagePtr &image, const UChar8 *buffer, Int32 memSize=-1)
virtual UInt64 storeData (const ImagePtr &image, UChar8 *buffer, Int32 memSize=-1)
dump
*void dump (void)
Get Methods
*const Char8getMimeType (void) const
const std::list< IDString > & getSuffixList (void) const
virtual UInt32 getFlags (void) const
dump
*void dump (void)
Get Methods
*const Char8getMimeType (void) const
const std::list< IDString > & getSuffixList (void) const
virtual UInt32 getFlags (void) const
dump
*void dump (void)
Get Methods
*const Char8getMimeType (void) const
const std::list< IDString > & getSuffixList (void) const
virtual UInt32 getFlags (void) const
Raw Store/Restore
*virtual UInt64 restoreData (ImagePtr &image, const UChar8 *buffer, Int32 memSize=-1)
virtual UInt64 storeData (const ImagePtr &image, UChar8 *buffer, Int32 memSize=-1)
dump
*void dump (void)
Get Methods
*const Char8getMimeType (void) const
const std::list< IDString > & getSuffixList (void) const
virtual UInt32 getFlags (void) const
Raw Store/Restore
*virtual UInt64 restoreData (ImagePtr &image, const UChar8 *buffer, Int32 memSize=-1)
virtual UInt64 storeData (const ImagePtr &image, UChar8 *buffer, Int32 memSize=-1)
dump
*void dump (void)
Get Methods
*const Char8getMimeType (void) const
const std::list< IDString > & getSuffixList (void) const
virtual UInt32 getFlags (void) const
Raw Store/Restore
*virtual UInt64 restoreData (ImagePtr &image, const UChar8 *buffer, Int32 memSize=-1)
virtual UInt64 storeData (const ImagePtr &image, UChar8 *buffer, Int32 memSize=-1)
dump
*void dump (void)
Destructor
*virtual ~TIFImageFileType (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)
Get Methods
*const Char8getMimeType (void) const
const std::list< IDString > & getSuffixList (void) const
virtual UInt32 getFlags (void) const
Raw Store/Restore
*virtual UInt64 restoreData (ImagePtr &image, const UChar8 *buffer, Int32 memSize=-1)
virtual UInt64 storeData (const ImagePtr &image, UChar8 *buffer, Int32 memSize=-1)
dump
*void dump (void)

Static Public Member Functions

Get Method
*static TIFImageFileTypethe (void)

Protected Member Functions

Default Constructor
TIFImageFileType (const Char8 *mimeType, const Char8 *suffixArray[], UInt16 suffixByteCount, UInt32 flags)
Copy Constructor
TIFImageFileType (const TIFImageFileType &obj)

Private Types

typedef ImageFileType Inherited

Static Private Attributes

static TIFImageFileType _the

Detailed Description

Image File Type to read/write and store/restore Image objects as TIF (tif/tiff suffix) data.

To be able to load TIFF images you need the IJG TIFF library, (check the Prerequisites page on www.opensg.org). The lib comes with all Linux distributions.

You have to --enable-tif in the configure line to enable the singleton object.

Definition at line 55 of file OSGTIFImageFileType.h.


Member Typedef Documentation

typedef ImageFileType osg::TIFImageFileType::Inherited [private]
 

Definition at line 109 of file OSGTIFImageFileType.h.


Member Enumeration Documentation

anonymous enum [inherited]
 

Enumerator:
OSG_READ_SUPPORTED 
OSG_WRITE_SUPPORTED 

Definition at line 65 of file OSGImageFileType.h.

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


Constructor & Destructor Documentation

TIFImageFileType::~TIFImageFileType void   )  [virtual]
 

Destructor

Definition at line 461 of file OSGTIFImageFileType.cpp.

00462 {
00463     return;
00464 }

TIFImageFileType::TIFImageFileType const Char8 mimeType,
const Char8 suffixArray[],
UInt16  suffixByteCount,
UInt32  flags
[protected]
 

Constructor used for the singleton object

Definition at line 438 of file OSGTIFImageFileType.cpp.

References the().

00441                                                  :
00442     ImageFileType(mimeType,suffixArray, suffixByteCount, flags)
00443 {
00444     the();
00445 }

TIFImageFileType::TIFImageFileType const TIFImageFileType obj  )  [protected]
 

Dummy Copy Constructor

Definition at line 451 of file OSGTIFImageFileType.cpp.

References the().

00451                                                               :
00452     ImageFileType(obj)
00453 {
00454     the();
00455 }


Member Function Documentation

TIFImageFileType & TIFImageFileType::the void   )  [static]
 

Class method to get the singleton Object

Definition at line 156 of file OSGTIFImageFileType.cpp.

References _the, errorHandler(), and warningHandler().

Referenced by TIFImageFileType().

00157 {
00158   static bool initTIFFLib = true;
00159 
00160 #ifdef OSG_WITH_TIF
00161 
00162   if (initTIFFLib) 
00163   {
00164     initTIFFLib = false;
00165 
00166     TIFFSetWarningHandler(&warningHandler);
00167     TIFFSetErrorHandler(&errorHandler);
00168   }
00169 
00170 #endif
00171 
00172   return _the;
00173 }

bool TIFImageFileType::read ImagePtr image,
const Char8 fileName
[virtual]
 

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

Implements osg::ImageFileType.

Definition at line 185 of file OSGTIFImageFileType.cpp.

References osg::ImageFileType::getMimeType(), osg::Image::OSG_INVALID_PF, osg::Image::OSG_L_PF, osg::Image::OSG_LA_PF, osg::Image::OSG_RGB_PF, osg::Image::OSG_RGBA_PF, and SWARNING.

00187 {
00188     bool    valid = false;
00189 
00190 #ifdef OSG_WITH_TIF
00191     TIFF    *in = TIFFOpen(fileName, "r");
00192     UChar8  *data = 0, *line = 0, *dest;
00193     UInt32  w, h, u, v;
00194     UInt16  bpp;
00195     Char8   errorMessage[1024];
00196     UInt16  *sampleinfo;
00197     UInt16  extrasamples;
00198     UInt16  si;
00199     UInt16  red, green, blue, alpha;
00200 
00201     if(in)
00202     {
00203         TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w);
00204 
00205         TIFFGetField(in, TIFFTAG_IMAGELENGTH, &h);
00206 
00207         TIFFGetFieldDefaulted(in, TIFFTAG_SAMPLESPERPIXEL, &bpp);
00208 
00209         if(bpp == 4)
00210         {   // accept unspecified extra samples as associated alpha
00211             TIFFGetFieldDefaulted(in, TIFFTAG_EXTRASAMPLES, &extrasamples,
00212                                   &sampleinfo);
00213 
00214             if(sampleinfo && sampleinfo[0] == EXTRASAMPLE_UNSPECIFIED)
00215             {
00216                 si = EXTRASAMPLE_ASSOCALPHA;
00217                 TIFFSetField(in, TIFFTAG_EXTRASAMPLES, 1, &si);
00218             }
00219         }
00220 
00221         data = new UChar8[w * h * 4];
00222         if(TIFFRGBAImageOK(in, errorMessage) &&
00223            TIFFReadRGBAImage(in, w, h, (uint32 *) data, 1))
00224             valid = true;
00225         else
00226         {
00227             SWARNING << "Tiff reader failed: " << errorMessage << std::endl;
00228             valid = false;
00229         }
00230 
00231         if(valid)
00232         {
00233             Image::PixelFormat  type = osg::Image::OSG_INVALID_PF;
00234             switch(bpp)
00235             {
00236             case 1:
00237                 type = Image::OSG_L_PF;
00238                 break;
00239             case 2:
00240                 type = Image::OSG_LA_PF;
00241                 break;
00242             case 3:
00243                 type = Image::OSG_RGB_PF;
00244                 break;
00245             case 4:
00246                 type = Image::OSG_RGBA_PF;
00247                 break;
00248             }
00249 
00250             image->set(type, w, h);
00251             dest = image->getData();
00252 
00253 #if defined(__linux) || defined(_WIN32)
00254             red = 0;
00255             green = 1;
00256             blue = 2;
00257             alpha = 3;
00258 
00259 #else
00260             red = 3;
00261             green = 2;
00262             blue = 1;
00263             alpha = 0;
00264 #endif
00265             for(v = 0; v < h; v++)
00266             {
00267                 line = data + ((v) * (w * 4));
00268                 for(u = 0; u < w; u++)
00269                 {
00270                     switch(bpp)
00271                     {
00272                     case 4:
00273                         *dest++ = line[red];
00274                         *dest++ = line[green];
00275                         *dest++ = line[blue];
00276                         *dest++ = line[alpha];
00277                         break;
00278                     case 3:
00279                         *dest++ = line[red];
00280                         *dest++ = line[green];
00281                         *dest++ = line[blue];
00282                         break;
00283                     case 2:
00284                         *dest++ = line[red];
00285                         *dest++ = line[green];
00286                         break;
00287                     case 1:
00288                         *dest++ = line[red];
00289                         break;
00290                     }
00291 
00292                     line += 4;
00293                 }
00294             }
00295 
00296             TIFFClose(in);
00297             delete[] data;
00298             data = 0;
00299         }
00300     }
00301 
00302 #else
00303     SWARNING <<
00304         getMimeType() <<
00305         " read is not compiled into the current binary " <<
00306         std::endl;
00307 #endif
00308     return valid;
00309 }

bool TIFImageFileType::write const ImagePtr image,
const Char8 fileName
[virtual]
 

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

Implements osg::ImageFileType.

Definition at line 316 of file OSGTIFImageFileType.cpp.

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

00318 {
00319     bool                retCode = false;
00320 
00321 #ifdef OSG_WITH_TIF
00322     
00323     if(image->getDimension() < 1 || image->getDimension() > 2)
00324     {
00325         FWARNING(("TIFImageFileType::write: invalid dimension %d!\n",
00326             image->getDimension()));
00327         return false;
00328     }
00329 
00330     TIFF                *out = TIFFOpen(fileName, "w");
00331     int                 lineSize = image->getWidth() * image->getBpp();
00332     int                 photometric = 0, samplesPerPixel = 0;
00333     const UChar8       *data;
00334     int                 row;
00335 
00336     // TODO: implemet all cases correct
00337     switch(image->getBpp())
00338     {
00339     case 1:
00340         samplesPerPixel = 1;
00341         photometric = PHOTOMETRIC_MINISBLACK;
00342         break;
00343     case 2:
00344         samplesPerPixel = 2;
00345         photometric = PHOTOMETRIC_MINISBLACK;
00346         break;
00347     case 3:
00348         samplesPerPixel = 3;
00349         photometric = PHOTOMETRIC_RGB;
00350         break;
00351     case 4:
00352         samplesPerPixel = 4;
00353         photometric = PHOTOMETRIC_RGB;
00354         break;
00355     }
00356 
00357     if(out)
00358     {
00359         TIFFSetField(out, TIFFTAG_IMAGEWIDTH, image->getWidth());
00360         TIFFSetField(out, TIFFTAG_IMAGELENGTH, image->getHeight());
00361         TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
00362         TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, samplesPerPixel);
00363         TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);
00364         TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
00365         TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);
00366         TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
00367         TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, 0));
00368 
00369         for(row = 0; row < image->getHeight(); row++)
00370         {
00371             data = image->getData() + ((image->getHeight() - row - 1) * lineSize);
00372             if(TIFFWriteScanline(out, 
00373                                  (tdata_t) const_cast<UChar8 *>(data), 
00374                                  row, 
00375                                  0) < 0)
00376                 break;
00377         }
00378 
00379         TIFFClose(out);
00380         retCode = true;
00381     }
00382 
00383 #else
00384     SWARNING <<
00385         getMimeType() <<
00386         " write is not compiled into the current binary " <<
00387         std::endl;
00388 #endif
00389     return retCode;
00390 }

bool TIFImageFileType::validateHeader const Char8 fileName,
bool &  implemented
[virtual]
 

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

Reimplemented from osg::ImageFileType.

Definition at line 392 of file OSGTIFImageFileType.cpp.

00393 {
00394     implemented = true;
00395 
00396     if(fileName == NULL)
00397         return false;
00398 
00399     FILE *file = fopen(fileName, "rb");
00400     if(file == NULL)
00401         return false;
00402 
00403     std::string magic;
00404     magic.resize(2);
00405     fread((void *) &magic[0], 2, 1, file);
00406     fclose(file);
00407 
00408     if(magic == "MM" || magic == "II")
00409     {
00410         return true;
00411     }
00412 
00413     return false;
00414 }

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

Get method for the mime type

Definition at line 106 of file OSGImageFileType.cpp.

References osg::ImageFileType::_mimeType, and osg::IDString::str().

Referenced by osg::ImageFileType::dump(), read(), osg::PNGImageFileType::read(), osg::MNGImageFileType::read(), osg::JPGImageFileType::read(), osg::ImageFileHandler::read(), osg::PNGImageFileType::restoreData(), osg::JPGImageFileType::restoreData(), osg::ImageFileType::restoreData(), osg::ImageFileType::store(), osg::ImageFileHandler::store(), osg::PNGImageFileType::storeData(), osg::JPGImageFileType::storeData(), osg::ImageFileType::storeData(), write(), osg::TGAImageFileType::write(), osg::PNGImageFileType::write(), osg::MNGImageFileType::write(), osg::JPGImageFileType::write(), osg::ImageFileHandler::write(), osg::GIFImageFileType::write(), and osg::DDSImageFileType::write().

00107 {
00108     return _mimeType.str();
00109 }

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

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 }

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

References osg::ImageFileType::_flags.

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

00117 {
00118     return _flags;
00119 }

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 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 }

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 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 }

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 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 }

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 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 }

UInt64 ImageFileType::restoreData ImagePtr image,
const UChar8 buffer,
Int32  memSize = -1
[virtual, inherited]
 

Abstract restore method. Should be overwriten by a concrete derived class. Tries to restore the image data from the given memblock.

Reimplemented in osg::DATImageFileType, osg::JPGImageFileType, osg::MTDImageFileType, and osg::PNGImageFileType.

Definition at line 193 of file OSGImageFileType.cpp.

References FWARNING, and osg::ImageFileType::getMimeType().

Referenced by osg::ImageFileType::restore().

00196 {
00197   FWARNING(("ImageXFileType::restoreData() not impl. for mimeType %s\n",
00198             getMimeType()));
00199 
00200   return 0;
00201 }

UInt64 ImageFileType::storeData const ImagePtr image,
UChar8 buffer,
Int32  memSize = -1
[virtual, inherited]
 

Abstract restore method. Should be overwriten by a concrete derived class. Tries to store the given image data to the given memblock

Reimplemented in osg::DATImageFileType, osg::JPGImageFileType, osg::MTDImageFileType, and osg::PNGImageFileType.

Definition at line 208 of file OSGImageFileType.cpp.

References FWARNING, and osg::ImageFileType::getMimeType().

Referenced by osg::ImageFileType::store().

00211 {
00212   FWARNING(("ImageXFileType::storeData() not impl. for mimeType %s\n",
00213             getMimeType()));
00214   
00215   return 0;
00216 }

void ImageFileType::dump void   )  [inherited]
 

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 }


Member Data Documentation

TIFImageFileType TIFImageFileType::_the [static, private]
 

Referenced by the().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:14:25 2005 for OpenSG by  doxygen 1.4.3