From 7c8ab128a6c14999576d62279ad4ad8fccfa9ceb Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 26 Feb 2015 19:13:46 +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/branches/OpenSceneGraph-3.2@14731 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 8634410a2..195ec8a60 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -1510,16 +1510,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); } } }