From 31cd80cea73e8ba241fe576c5833fec90985b6ea Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 10 Sep 2013 15:17:59 +0000 Subject: [PATCH] From Giuseppe Donvito, "I'm using OSG 320 and I need to flush a DDS 3D texture on disk. I found a bug on DDS ReaderWriter that generates a false positive on a guard for the size check on writing operation. This is due to a wrong imageSize computation that uses img->getImageSizeInBytes() method instead of img->getTotalSizeInBytes(), that actually ignores the r() dimension, contrariwise taken into account by the function ComputeImageSizeInBytes() later. The line 1062 on file ReaderWriterDDS.cpp should be fixed with: [code]unsigned int imageSize = img->getTotalSizeInBytes();[/code] " --- src/osgPlugins/dds/ReaderWriterDDS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osgPlugins/dds/ReaderWriterDDS.cpp b/src/osgPlugins/dds/ReaderWriterDDS.cpp index f439b6cfe..475f210d6 100644 --- a/src/osgPlugins/dds/ReaderWriterDDS.cpp +++ b/src/osgPlugins/dds/ReaderWriterDDS.cpp @@ -1059,7 +1059,7 @@ bool WriteDDSFile(const osg::Image *img, std::ostream& fout, bool autoFlipDDSWri //unsigned int internalFormat = img->getInternalTextureFormat(); //unsigned int components = osg::Image::computeNumComponents(pixelFormat); unsigned int pixelSize = osg::Image::computePixelSizeInBits(pixelFormat, dataType); - unsigned int imageSize = img->getImageSizeInBytes(); + unsigned int imageSize = img->getTotalSizeInBytes(); // 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: