Skip to content
Permalink
Browse files

raster block setIsNoDataExcept fix, fixes #7608

  • Loading branch information
blazek committed May 2, 2013
1 parent ae7115f commit 6983ec39b23ba8261f75b95aa5cd47eec5f5cb66
Showing with 7 additions and 6 deletions.
  1. +7 −6 src/core/raster/qgsrasterblock.cpp
@@ -75,6 +75,7 @@ QgsRasterBlock::QgsRasterBlock( QGis::DataType theDataType, int theWidth, int th

QgsRasterBlock::~QgsRasterBlock()
{
QgsDebugMsg( QString( "mData = %1" ).arg(( ulong )mData ) );
qgsFree( mData );
delete mImage;
qgsFree( mNoDataBitmap );
@@ -474,10 +475,10 @@ bool QgsRasterBlock::setIsNoDataExcept( const QRect & theExceptRect )
int bottom = theExceptRect.bottom();
int left = theExceptRect.left();
int right = theExceptRect.right();
if ( top < 0 ) top = 0;
if ( left < 0 ) left = 0;
if ( bottom >= mHeight ) bottom = mHeight - 1;
if ( right >= mWidth ) right = mWidth - 1;
top = qMin( qMax( top, 0 ), mHeight - 1 );
left = qMin( qMax( left, 0 ), mWidth - 1 );
bottom = qMax( 0, qMin( bottom, mHeight - 1 ) );
right = qMax( 0, qMin( right, mWidth - 1 ) );

QgsDebugMsg( "Entered" );
if ( typeIsNumeric( mDataType ) )
@@ -511,12 +512,12 @@ bool QgsRasterBlock::setIsNoDataExcept( const QRect & theExceptRect )
// middle
for ( int r = top; r <= bottom; r++ )
{
size_t i = r * mWidth;
size_t i = ( size_t )r * mWidth;
// middle left
memcpy(( char* )mData + i*dataTypeSize, nodataRow, dataTypeSize*left );
// middle right
i += right + 1;
int w = mWidth - right;
int w = mWidth - right - 1;
memcpy(( char* )mData + i*dataTypeSize, nodataRow, dataTypeSize*w );
}
delete [] nodataRow;

0 comments on commit 6983ec3

Please sign in to comment.
You can’t perform that action at this time.