From Sebastian Messerschmidt,"Attached you find a version of the ReaderWriterDDS with info outputs set to OSG_INFO instead of OSG_NOTICE. The old version spams the console for each loaded DDS file."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14702 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -982,6 +982,8 @@ osg::Image* ReadDDSFile(std::istream& _istream, bool flipDDSRead)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSG_INFO<<"ReadDDS, dataType = 0x"<<std::hex<<dataType<<std::endl;
|
||||||
|
|
||||||
unsigned char* imageData = new unsigned char [sizeWithMipmaps];
|
unsigned char* imageData = new unsigned char [sizeWithMipmaps];
|
||||||
if(!imageData)
|
if(!imageData)
|
||||||
{
|
{
|
||||||
@@ -1016,6 +1018,7 @@ osg::Image* ReadDDSFile(std::istream& _istream, bool flipDDSRead)
|
|||||||
osgImage->setOrigin(osg::Image::BOTTOM_LEFT);
|
osgImage->setOrigin(osg::Image::BOTTOM_LEFT);
|
||||||
if (!isDXTC || ((s>4 && s%4==0 && t>4 && t%4==0) || s<4)) // Flip may crash (access violation) or fail for non %4 dimensions (except for s<4). Tested with revision trunk 2013-02-22.
|
if (!isDXTC || ((s>4 && s%4==0 && t>4 && t%4==0) || s<4)) // Flip may crash (access violation) or fail for non %4 dimensions (except for s<4). Tested with revision trunk 2013-02-22.
|
||||||
{
|
{
|
||||||
|
OSG_INFO<<"Flipping dds on load"<<std::endl;
|
||||||
osgImage->flipVertical();
|
osgImage->flipVertical();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1061,7 +1064,9 @@ bool WriteDDSFile(const osg::Image *img, std::ostream& fout, bool autoFlipDDSWri
|
|||||||
unsigned int pixelSize = osg::Image::computePixelSizeInBits(pixelFormat, dataType);
|
unsigned int pixelSize = osg::Image::computePixelSizeInBits(pixelFormat, dataType);
|
||||||
unsigned int imageSize = img->getTotalSizeInBytes();
|
unsigned int imageSize = img->getTotalSizeInBytes();
|
||||||
|
|
||||||
// Check that theorical image size (computation taking into account DXTC blocks) is not bigger than actual image size.
|
OSG_INFO<<"WriteDDS, dataType = 0x"<<std::hex<<dataType<<std::endl;
|
||||||
|
|
||||||
|
// Check that theorical image size (computation taking into account DXTC blocks) is not bigger than actual image size.
|
||||||
// This may happen, for instance, if some operation tuncated the data buffer non block-aligned. Example:
|
// This may happen, for instance, if some operation tuncated the data buffer non block-aligned. Example:
|
||||||
// - Read DXT1 image, size = 8x7. Actually, image data is 8x8 because it stores 4x4 blocks.
|
// - Read DXT1 image, size = 8x7. Actually, image data is 8x8 because it stores 4x4 blocks.
|
||||||
// - Some hypothetical operation wrongly assumes the data buffer is 8x7 and truncates the buffer. This may even lead to access violations.
|
// - Some hypothetical operation wrongly assumes the data buffer is 8x7 and truncates the buffer. This may even lead to access violations.
|
||||||
@@ -1271,6 +1276,8 @@ bool WriteDDSFile(const osg::Image *img, std::ostream& fout, bool autoFlipDDSWri
|
|||||||
osg::ref_ptr<const osg::Image> source;
|
osg::ref_ptr<const osg::Image> source;
|
||||||
if (autoFlipDDSWrite && img->getOrigin() == osg::Image::BOTTOM_LEFT)
|
if (autoFlipDDSWrite && img->getOrigin() == osg::Image::BOTTOM_LEFT)
|
||||||
{
|
{
|
||||||
|
OSG_INFO<<"Flipping dds image on write"<<std::endl;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Image> copy( new osg::Image(*img,osg::CopyOp::DEEP_COPY_ALL) );
|
osg::ref_ptr<osg::Image> copy( new osg::Image(*img,osg::CopyOp::DEEP_COPY_ALL) );
|
||||||
const int s(copy->s());
|
const int s(copy->s());
|
||||||
const int t(copy->t());
|
const int t(copy->t());
|
||||||
|
|||||||
Reference in New Issue
Block a user