From 6a307058708b90ec826ca3e607d2af8de8eb3e2f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 26 Feb 2015 19:14:28 +0000 Subject: [PATCH] From Bradley Baker Searles, "We had someone replace a DDS texture with a GL_RGB/GL_UNSIGNED_SHORT_5_6_6 image, which would trigger a crash in Image.cpp while flipping the mipmap chain. The code was trying to flip the mipmaps using the rowStep for the full-size image (we have "dds_flip" set in the osgDB::ReaderWriter::Options in the osgDB::Registry)." git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14732 16af8721-9629-0410-8352-f15c8da7e697 --- src/osg/Image.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 2c2cae196..50d5076fd 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -1558,16 +1558,18 @@ void Image::flipVertical() { if (!dxtc_tool::VerticalFlip(s,t,_pixelFormat,_data+_mipmapData[i])) { - OSG_NOTICE << "Notice Image::flipVertical(): Vertical flip do not succeed" << std::endl; + OSG_NOTICE << "Notice Image::flipVertical(): Vertical flip did not succeed" << std::endl; } } else { - // its not a compressed image, so implement flip oursleves. + // it's not a compressed image, so implement flip ourselves. + unsigned int mipRowSize = computeRowWidthInBytes(s, _pixelFormat, _dataType, _packing); + unsigned int mipRowStep = mipRowSize; unsigned char* top = _data+_mipmapData[i]; - unsigned char* bottom = top + (t-1)*rowStep; + unsigned char* bottom = top + (t-1)*mipRowStep; - flipImageVertical(top, bottom, rowSize, rowStep); + flipImageVertical(top, bottom, mipRowSize, mipRowStep); } } }