Added handling of possible zero divisor

This commit is contained in:
Robert Osfield 2016-06-30 08:20:31 +01:00
parent 1a10795198
commit 7f335fd528

View File

@ -126,7 +126,8 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
} }
//wish there was a Image::computeComponentSizeInBits() //wish there was a Image::computeComponentSizeInBits()
bitDepth = Image::computePixelSizeInBits(img.getPixelFormat(),img.getDataType())/Image::computeNumComponents(img.getPixelFormat()); unsigned int numComponents = Image::computeNumComponents(img.getPixelFormat());
bitDepth = (numComponents>0) ? (Image::computePixelSizeInBits(img.getPixelFormat(),img.getDataType())/numComponents) : 0;
if(bitDepth!=8 && bitDepth!=16) return WriteResult::ERROR_IN_WRITING_FILE; if(bitDepth!=8 && bitDepth!=16) return WriteResult::ERROR_IN_WRITING_FILE;
//Create row data //Create row data