Skip to content

Commit

Permalink
raster block setIsNoDataExcept fix, fixes #7608
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed May 2, 2013
1 parent ae7115f commit 6983ec3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/raster/qgsrasterblock.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 ) )
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6983ec3

Please sign in to comment.