#include <OSGTGAImageFileType.h>

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 | ~TGAImageFileType (void) |
Read/Write | |
| virtual bool | read (ImagePtr &image, std::istream &is, const std::string &mimetype) |
Set | |
| void | setOptions (const Char8 *options) |
Get Methods | |
| const Char8 * | getMimeType (void) const |
| const std::list< IDString > & | getSuffixList (void) const |
| virtual UInt32 | getFlags (void) const |
| const Char8 * | getOptions (void) |
Read/Write | |
| virtual bool | read (ImagePtr &image, const Char8 *fileName) |
| virtual bool | write (const ImagePtr &image, const Char8 *fileName) |
| virtual bool | write (const ImagePtr &image, std::ostream &os, const std::string &mimetype) |
| virtual bool | validateHeader (const Char8 *fileName, bool &implemented) |
| virtual std::string | determineMimetypeFromStream (std::istream &is) |
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 TGAImageFileType & | the (void) |
Protected Member Functions | |
Default Constructor | |
| TGAImageFileType (const Char8 *mimeType, const Char8 *suffixArray[], UInt16 suffixByteCount) | |
Protected Attributes | |
MTD Header | |
| std::string | _options |
Private Member Functions | |
| bool | readHeader (std::istream &in, TGAHeader &header) |
| bool | readCompressedImageData (std::istream &in, ImagePtr &image) |
Copy Constructor | |
| TGAImageFileType (const TGAImageFileType &obj) | |
Copy Operator | |
| const TGAImageFileType & | operator= (const TGAImageFileType &obj) |
Static Private Attributes | |
| static TGAImageFileType | _the |
Classes | |
| struct | TGAHeader |
All the type specific code is included in the class. Does not depend on external libs.
Definition at line 56 of file OSGTGAImageFileType.h.
anonymous enum [inherited] |
Definition at line 66 of file OSGImageFileType.h.
00067 { 00068 OSG_READ_SUPPORTED = 1, 00069 OSG_WRITE_SUPPORTED = 2 00070 };
| TGAImageFileType::~TGAImageFileType | ( | void | ) | [virtual] |
| TGAImageFileType::TGAImageFileType | ( | const Char8 * | mimeType, | |
| const Char8 * | suffixArray[], | |||
| UInt16 | suffixByteCount | |||
| ) | [protected] |
Constructor used for the singleton object
Definition at line 326 of file OSGTGAImageFileType.cpp.
00328 : 00329 ImageFileType(mimeType, suffixArray, suffixByteCount) 00330 {}
| osg::TGAImageFileType::TGAImageFileType | ( | const TGAImageFileType & | obj | ) | [private] |
| TGAImageFileType & TGAImageFileType::the | ( | void | ) | [static] |
Class method to get the singleton Object
Definition at line 86 of file OSGTGAImageFileType.cpp.
References _the.
00087 { 00088 return _the; 00089 }
| bool TGAImageFileType::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 196 of file OSGTGAImageFileType.cpp.
References osg::TGAImageFileType::TGAHeader::cmapEntrySize, osg::TGAImageFileType::TGAHeader::cmapLength, osg::TGAImageFileType::TGAHeader::colorMapType, osg::TGAImageFileType::TGAHeader::depth, osg::TGAImageFileType::TGAHeader::descriptor, FDEBUG, FWARNING, osg::TGAImageFileType::TGAHeader::height, osg::TGAImageFileType::TGAHeader::idLength, osg::TGAImageFileType::TGAHeader::imageType, osg::Image::OSG_INVALID_PF, osg::Image::OSG_L_PF, osg::Image::OSG_RGB_PF, osg::Image::OSG_RGBA_PF, osg::osgMin(), readCompressedImageData(), readHeader(), and osg::TGAImageFileType::TGAHeader::width.
00197 { 00198 // read the header 00199 TGAHeader header; 00200 if (readHeader(is, header) == false) 00201 return false; 00202 00203 // determine format 00204 Image::PixelFormat format = Image::OSG_INVALID_PF; 00205 switch (header.imageType & ~0x8) 00206 { 00207 case 1: FWARNING(("TGA: 8-bit image not supported!\n")); 00208 break; 00209 00210 case 2: switch (header.depth) 00211 { 00212 case 24: format = Image::OSG_RGB_PF; 00213 break; 00214 case 32: format = Image::OSG_RGBA_PF; 00215 break; 00216 default: FWARNING(("TGA: Unknown pixel depth %d!\n", 00217 header.depth)); 00218 break; 00219 } 00220 break; 00221 00222 case 3: format = Image::OSG_L_PF; 00223 break; 00224 } 00225 if (format == Image::OSG_INVALID_PF) 00226 { 00227 FWARNING(("Unsupported image type for TGA file!\n")); 00228 return false; 00229 } 00230 00231 // read the image ID 00232 UInt8 imageid[256]; 00233 is.read(reinterpret_cast<char *>(imageid), header.idLength); 00234 if (is.gcount() != header.idLength) 00235 return false; 00236 imageid[header.idLength] = 0; 00237 FDEBUG(("TGA: Image ID '%s'\n", imageid)); 00238 00239 // read color map data 00240 if (header.colorMapType == 1) 00241 { 00242 Int32 len = osgMin(header.cmapEntrySize / 3, 8) * header.cmapLength; 00243 00244 //UInt8 * dum = new UInt8 [len]; 00245 //in.read(reinterpret_cast<char *>(dum), len); 00246 //delete [] dum; 00247 is.ignore(len); 00248 if (is.gcount() != len) 00249 return false; 00250 } 00251 00252 // read image data 00253 image->set(format, header.width, header.height); 00254 if ((header.imageType & 0x8) != 0) 00255 { 00256 if (readCompressedImageData(is, image) == false) 00257 { 00258 FWARNING(("Unsupported image type for TGA file!\n")); 00259 return false; 00260 } 00261 } 00262 else 00263 { 00264 Int32 len = image->getSize(); 00265 is.read(reinterpret_cast<char *>(image->getData()), len); 00266 if (is.gcount() != len) 00267 return false; 00268 } 00269 00270 // check origin 00271 switch (header.descriptor & 0x30) 00272 { 00273 case 0x00: // bottom left, ok! 00274 break; 00275 case 0x20: // top left 00276 // do top-bottom swap 00277 { 00278 UInt32 bpl = image->getBpp() * image->getWidth(); 00279 UChar8 *t = image->getData(), 00280 *b = t + (image->getHeight() - 1) * bpl, 00281 dum; 00282 00283 for(UInt32 y = image->getHeight() / 2; y > 0; --y) 00284 { 00285 for(UInt32 x = bpl; x > 0; --x, ++t, ++b) 00286 { 00287 dum = *t; 00288 *t = *b; 00289 *b = dum; 00290 } 00291 b -= bpl * 2; 00292 } 00293 } 00294 break; 00295 case 0x10: // bottom right 00296 case 0x30: // top right 00297 FWARNING(("TGA: origin 0x%d not supported!\n", 00298 header.descriptor & 0x30)); 00299 return false; 00300 } 00301 00302 // do BGR -> RGB swap, as GL_BGR_EXT is not supported everywhere 00303 if (image->getPixelFormat() == Image::OSG_RGB_PF || 00304 image->getPixelFormat() == Image::OSG_RGBA_PF) 00305 { 00306 UChar8 *d = image->getData(), dum; 00307 UInt32 npix = image->getWidth() * image->getHeight(); 00308 UInt8 bpp = image->getBpp(); 00309 00310 while (npix--) 00311 { 00312 dum = d[2]; 00313 d[2] = d[0]; 00314 d[0] = dum; 00315 d += bpp; 00316 } 00317 } 00318 00319 return true; 00320 }
| const TGAImageFileType& osg::TGAImageFileType::operator= | ( | const TGAImageFileType & | obj | ) | [private] |
| bool TGAImageFileType::readHeader | ( | std::istream & | in, | |
| TGAHeader & | header | |||
| ) | [private] |
Definition at line 91 of file OSGTGAImageFileType.cpp.
References osg::TGAImageFileType::TGAHeader::cmapEntrySize, osg::TGAImageFileType::TGAHeader::cmapFirst, osg::TGAImageFileType::TGAHeader::cmapLength, osg::TGAImageFileType::TGAHeader::colorMapType, osg::TGAImageFileType::TGAHeader::depth, osg::TGAImageFileType::TGAHeader::descriptor, osg::TGAImageFileType::TGAHeader::height, osg::TGAImageFileType::TGAHeader::idLength, osg::TGAImageFileType::TGAHeader::imageType, osg::TGAImageFileType::TGAHeader::width, osg::TGAImageFileType::TGAHeader::xOrigin, and osg::TGAImageFileType::TGAHeader::yOrigin.
Referenced by read().
00092 { 00093 UInt8 dum[18]; 00094 is.read(reinterpret_cast<char *>(dum), 18); 00095 if (is.gcount() != 18) 00096 return false; 00097 00098 header.idLength = dum[ 0]; 00099 header.colorMapType = dum[ 1]; 00100 header.imageType = dum[ 2]; 00101 header.cmapFirst = dum[ 3] | (dum[ 4] << 8); 00102 header.cmapLength = dum[ 5] | (dum[ 6] << 8); 00103 header.cmapEntrySize = dum[ 7]; 00104 header.xOrigin = dum[ 8] | (dum[ 9] << 8); 00105 header.yOrigin = dum[10] | (dum[11] << 8); 00106 header.width = dum[12] | (dum[13] << 8); 00107 header.height = dum[14] | (dum[15] << 8); 00108 header.depth = dum[16]; 00109 header.descriptor = dum[17]; 00110 00111 return true; 00112 }
| bool TGAImageFileType::readCompressedImageData | ( | std::istream & | in, | |
| ImagePtr & | image | |||
| ) | [private] |
Definition at line 114 of file OSGTGAImageFileType.cpp.
References FWARNING, osg::Image::OSG_L_PF, osg::Image::OSG_RGB_PF, and osg::Image::OSG_RGBA_PF.
Referenced by read().
00116 { 00117 UInt32 npix = image->getWidth() * image->getHeight(); 00118 Int32 rep, len; 00119 UChar8 *data = image->getData(); 00120 UInt16 bpp = image->getBpp(); 00121 Char8 c[4]; 00122 00123 while (npix > 0) 00124 { 00125 rep = is.get(); 00126 if (rep == EOF) 00127 return false; 00128 bool repFlag = (rep & 0x80) != 0; 00129 rep = (rep & 0x7f) + 1; 00130 if (static_cast<UInt32>(rep) > npix) 00131 return false; 00132 npix -= rep; 00133 00134 if (repFlag == true) 00135 { 00136 switch (image->getPixelFormat()) 00137 { 00138 case Image::OSG_L_PF: 00139 is.read(c, 1); 00140 if (is.gcount() != 1) 00141 return false; 00142 for (; rep > 0; --rep) 00143 *data++ = c[0]; 00144 break; 00145 case Image::OSG_RGB_PF: 00146 is.read(c, 3); 00147 if (is.gcount() != 3) 00148 return false; 00149 for (; rep > 0; --rep) 00150 { 00151 *data++ = c[0]; 00152 *data++ = c[1]; 00153 *data++ = c[2]; 00154 } 00155 break; 00156 case Image::OSG_RGBA_PF: 00157 is.read(c, 4); 00158 if (is.gcount() != 4) 00159 return false; 00160 for (; rep > 0; --rep) 00161 { 00162 *data++ = c[0]; 00163 *data++ = c[1]; 00164 *data++ = c[2]; 00165 *data++ = c[3]; 00166 } 00167 break; 00168 default: 00169 FWARNING(("TGA: unknown pixel " 00170 "format!?!\n")); 00171 return false; 00172 } 00173 } 00174 else // raw packet 00175 { 00176 len = bpp * rep; 00177 is.read(reinterpret_cast<char *>(data), len); 00178 if (is.gcount() != len) 00179 return false; 00180 data += len; 00181 } 00182 } 00183 return true; 00184 }
| 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] |
Get method for the mime type
Definition at line 107 of file OSGImageFileType.cpp.
References osg::ImageFileType::_mimeType, and osg::IDString::str().
Referenced by osg::ImageFileHandler::addImageFileType(), osg::TIFImageFileType::determineMimetypeFromStream(), osg::SGIImageFileType::determineMimetypeFromStream(), osg::PSDImageFileType::determineMimetypeFromStream(), osg::PNMImageFileType::determineMimetypeFromStream(), osg::PNGImageFileType::determineMimetypeFromStream(), osg::MNGImageFileType::determineMimetypeFromStream(), osg::JPGImageFileType::determineMimetypeFromStream(), osg::JP2ImageFileType::determineMimetypeFromStream(), osg::GIFImageFileType::determineMimetypeFromStream(), osg::DDSImageFileType::determineMimetypeFromStream(), osg::BMPImageFileType::determineMimetypeFromStream(), osg::ImageFileType::dump(), osg::TIFImageFileType::read(), osg::PNGImageFileType::read(), osg::JPGImageFileType::read(), osg::JP2ImageFileType::read(), osg::ImageFileType::read(), osg::ImageFileHandler::read(), osg::EXRImageFileType::read(), osg::PNGImageFileType::restoreData(), osg::JPGImageFileType::restoreData(), osg::ImageFileType::restoreData(), osg::ImageFileHandler::store(), osg::PNGImageFileType::storeData(), osg::JPGImageFileType::storeData(), osg::ImageFileType::storeData(), osg::TIFImageFileType::write(), osg::PNGImageFileType::write(), osg::JPGImageFileType::write(), osg::ImageFileType::write(), osg::ImageFileHandler::write(), and osg::EXRImageFileType::write().
| 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 }
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 }
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::write | ( | const ImagePtr & | image, | |
| std::ostream & | os, | |||
| const std::string & | mimetype | |||
| ) | [virtual, inherited] |
Tries to write the image object to the given output stream. Returns true on success.
Reimplemented in osg::BMPImageFileType, osg::EXRImageFileType, osg::HDRImageFileType, osg::JPGImageFileType, osg::MTDImageFileType, osg::PNGImageFileType, osg::PNMImageFileType, and osg::TIFImageFileType.
Definition at line 185 of file OSGImageFileType.cpp.
References osg::endLog(), osg::ImageFileType::getMimeType(), and SWARNING.
00186 { 00187 SWARNING << getMimeType() 00188 << " write to stream is not implemented" 00189 << endLog; 00190 return false; 00191 }
| 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().
| 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.
| 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 }
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 }
| 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::EXRImageFileType, osg::HDRImageFileType, osg::JPGImageFileType, osg::MTDImageFileType, and osg::PNGImageFileType.
Definition at line 253 of file OSGImageFileType.cpp.
References FWARNING, and osg::ImageFileType::getMimeType().
00256 { 00257 FWARNING(("ImageXFileType::restoreData() not impl. for mimeType %s\n", 00258 getMimeType())); 00259 00260 return 0; 00261 }
| 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::EXRImageFileType, osg::HDRImageFileType, osg::JPGImageFileType, osg::MTDImageFileType, and osg::PNGImageFileType.
Definition at line 268 of file OSGImageFileType.cpp.
References FWARNING, and osg::ImageFileType::getMimeType().
Referenced by osg::ImageFileType::store().
00271 { 00272 FWARNING(("ImageXFileType::storeData() not impl. for mimeType %s\n", 00273 getMimeType())); 00274 00275 return 0; 00276 }
| 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 }
TGAImageFileType TGAImageFileType::_the [static, private] |
std::string osg::ImageFileType::_options [protected, inherited] |
Definition at line 182 of file OSGImageFileType.h.
Referenced by osg::ImageFileType::getOptions(), osg::ImageFileType::setOptions(), and osg::TIFImageFileType::write().
1.5.5