Added handling of an empty filename when writing out an image file.

This commit is contained in:
Robert Osfield
2011-12-23 12:42:18 +00:00
parent 0af31eff5d
commit c9d19d7bff

View File

@@ -315,10 +315,6 @@ void OutputStream::writeImage( const osg::Image* img )
if (newID)
{
*this << PROPERTY("FileName"); writeWrappedString(img->getFileName()); *this << std::endl;
*this << PROPERTY("WriteHint") << (int)img->getWriteHint();
if ( getException() ) return;
int decision = IMAGE_EXTERNAL;
switch ( _writeImageHint )
{
@@ -334,19 +330,30 @@ void OutputStream::writeImage( const osg::Image* img )
break;
}
*this << decision << std::endl;
std::string imageFileName = img->getFileName();
if ( decision==IMAGE_WRITE_OUT || _writeImageHint==WRITE_EXTERNAL_FILE )
{
bool result = osgDB::writeImageFile( *img, img->getFileName() );
OSG_NOTICE << "OutputStream::writeImage(): Write image data to external file "
<< img->getFileName() << std::endl;
if (imageFileName.empty())
{
OSG_NOTICE<<"Empty Image::FileName resetting to image.dds"<<std::endl;
imageFileName = "image.dds";
}
bool result = osgDB::writeImageFile( *img, imageFileName );
OSG_NOTICE << "OutputStream::writeImage(): Write image data to external file " << imageFileName << std::endl;
if ( !result )
{
OSG_WARN << "OutputStream::writeImage(): Failed to write "
<< img->getFileName() << std::endl;
OSG_WARN << "OutputStream::writeImage(): Failed to write " << img->getFileName() << std::endl;
}
}
*this << PROPERTY("FileName"); writeWrappedString(imageFileName); *this << std::endl;
*this << PROPERTY("WriteHint") << (int)img->getWriteHint();
if ( getException() ) return;
*this << decision << std::endl;
switch ( decision )
{
case IMAGE_INLINE_DATA: