Navigation Menu

Skip to content

Commit

Permalink
Fix image format conversion (used e.g. for WMS client) and two memory…
Browse files Browse the repository at this point in the history
… leaks
  • Loading branch information
mhugent committed Oct 19, 2012
1 parent 6461a01 commit 7e5435c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/core/raster/qgsrasterblock.cpp
Expand Up @@ -54,7 +54,7 @@ QgsRasterBlock::QgsRasterBlock( DataType theDataType, int theWidth, int theHeigh
QgsRasterBlock::~QgsRasterBlock()
{
QgsFree( mData );

delete mImage;
}

bool QgsRasterBlock::reset( DataType theDataType, int theWidth, int theHeight, double theNoDataValue )
Expand Down Expand Up @@ -416,12 +416,9 @@ bool QgsRasterBlock::convert( QgsRasterBlock::DataType destDataType )
}
else if ( typeIsColor( mDataType ) && typeIsColor( destDataType ) )
{
// It would be probably faster to convert value by value here instead of
// creating new image, QImage (4.8) does not have any method to convert in place
QImage::Format format = imageFormat( destDataType );
QImage image = mImage->convertToFormat( format );
memcpy( mImage->bits(), image.bits(), mImage->byteCount() );
//mImage = new QImage( mWidth, mHeight, format );
*mImage = image;
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/core/raster/qgsrasterprojector.cpp
Expand Up @@ -708,6 +708,7 @@ QgsRasterBlock * QgsRasterProjector::block( int bandNo, QgsRectangle const & ex
if ( ! mSrcCRS.isValid() || ! mDestCRS.isValid() || mSrcCRS == mDestCRS )
{
QgsDebugMsg( "No projection necessary" );
delete outputBlock;
return mInput->block( bandNo, extent, width, height );
}

Expand Down

0 comments on commit 7e5435c

Please sign in to comment.