Navigation Menu

Skip to content

Commit

Permalink
Reenable legend icons for rasters
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13570 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 25, 2010
1 parent 1c89558 commit 61008a6
Showing 1 changed file with 38 additions and 21 deletions.
59 changes: 38 additions & 21 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -2195,7 +2195,7 @@ QPixmap QgsRasterLayer::legendAsPixmap( bool theWithNameFlag )
}

} //end of pseudocolor check
else if ( mDrawingStyle == PalettedMultiBandColor || mDrawingStyle == MultiBandColor )
else if ( mDrawingStyle == PalettedMultiBandColor || mDrawingStyle == MultiBandColor || mDrawingStyle == PalettedColor )
{
//
// Create the legend pixmap showing red green and blue band mappings
Expand Down Expand Up @@ -5539,7 +5539,7 @@ QgsRasterImageBuffer::~QgsRasterImageBuffer()

void QgsRasterImageBuffer::reset( int maxPixelsInVirtualMemory )
{
if ( !mRasterBand || !mPainter || !mViewPort || !mMapToPixel )
if ( !mRasterBand || !mPainter || !mViewPort )
{
mValid = false;
return;
Expand Down Expand Up @@ -5615,22 +5615,33 @@ bool QgsRasterImageBuffer::createNextPartImage()
}
else
{
int paintXoffset = static_cast<int>(
( mViewPort->rectXOffsetFloat -
mViewPort->rectXOffset )
/ mMapToPixel->mapUnitsPerPixel()
* fabs( mGeoTransform[1] )
);

int paintYoffset = static_cast<int>(
( mViewPort->rectYOffsetFloat -
mViewPort->rectYOffset )
/ mMapToPixel->mapUnitsPerPixel()
* fabs( mGeoTransform[5] )
);

mPainter->drawImage( static_cast<int>( mViewPort->topLeftPoint.x() + 0.5 ),
static_cast<int>( mViewPort->topLeftPoint.y() + 0.5 + fabs( mGeoTransform[5] ) * mCurrentPartRasterMin / mMapToPixel->mapUnitsPerPixel() ),
int paintXoffset = 0;
int paintYoffset = 0;
int imageX = 0;
int imageY = 0;

if ( mMapToPixel )
{
paintXoffset = static_cast<int>(
( mViewPort->rectXOffsetFloat -
mViewPort->rectXOffset )
/ mMapToPixel->mapUnitsPerPixel()
* fabs( mGeoTransform[1] )
);

paintYoffset = static_cast<int>(
( mViewPort->rectYOffsetFloat -
mViewPort->rectYOffset )
/ mMapToPixel->mapUnitsPerPixel()
* fabs( mGeoTransform[5] )
);

imageX = static_cast<int>( mViewPort->topLeftPoint.x() + 0.5 );
imageY = static_cast<int>( mViewPort->topLeftPoint.y() + 0.5 + fabs( mGeoTransform[5] ) * mCurrentPartRasterMin / mMapToPixel->mapUnitsPerPixel() );
}

mPainter->drawImage( imageX,
imageY,
*mCurrentImage,
paintXoffset,
paintYoffset );
Expand Down Expand Up @@ -5659,25 +5670,31 @@ bool QgsRasterImageBuffer::createNextPartImage()
GDALDataType type = GDALGetRasterDataType( mRasterBand );
int size = GDALGetDataTypeSize( type ) / 8;
int xSize = mViewPort->drawableAreaXDim;
int ySize = mViewPort->drawableAreaYDim;

//make the raster tiles overlap at least 2 pixels to avoid white stripes
int overlapRows = 0;
overlapRows = mMapToPixel->mapUnitsPerPixel() / fabs( mGeoTransform[5] ) + 2;
if ( mMapToPixel )
{
overlapRows = mMapToPixel->mapUnitsPerPixel() / fabs( mGeoTransform[5] ) + 2;
}
if ( mCurrentPartRasterMax + overlapRows >= mViewPort->clippedHeight )
{
overlapRows = 0;
}
int rasterYSize = mCurrentPartRasterMax - mCurrentPartRasterMin + overlapRows;

int ySize = 0;
if ( 2 >= mViewPort->clippedWidth && 2 >= mViewPort->clippedHeight ) //for zoomed in rasters
{
rasterYSize = mViewPort->clippedHeight;
ySize = mViewPort->drawableAreaYDim;
}
else //normal mode
{
ySize = fabs((( rasterYSize ) / mMapToPixel->mapUnitsPerPixel() * mGeoTransform[5] ) ) + 0.5;
if ( mMapToPixel )
{
ySize = fabs((( rasterYSize ) / mMapToPixel->mapUnitsPerPixel() * mGeoTransform[5] ) ) + 0.5;
}
}
if ( ySize == 0 )
{
Expand Down

0 comments on commit 61008a6

Please sign in to comment.