Skip to content

Commit c7d91d5

Browse files
author
mhugent
committed
Reenable legend icons for rasters
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13570 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 48b8f10 commit c7d91d5

File tree

1 file changed

+38
-21
lines changed

1 file changed

+38
-21
lines changed

src/core/raster/qgsrasterlayer.cpp

+38-21
Original file line numberDiff line numberDiff line change
@@ -2195,7 +2195,7 @@ QPixmap QgsRasterLayer::legendAsPixmap( bool theWithNameFlag )
21952195
}
21962196

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

55405540
void QgsRasterImageBuffer::reset( int maxPixelsInVirtualMemory )
55415541
{
5542-
if ( !mRasterBand || !mPainter || !mViewPort || !mMapToPixel )
5542+
if ( !mRasterBand || !mPainter || !mViewPort )
55435543
{
55445544
mValid = false;
55455545
return;
@@ -5615,22 +5615,33 @@ bool QgsRasterImageBuffer::createNextPartImage()
56155615
}
56165616
else
56175617
{
5618-
int paintXoffset = static_cast<int>(
5619-
( mViewPort->rectXOffsetFloat -
5620-
mViewPort->rectXOffset )
5621-
/ mMapToPixel->mapUnitsPerPixel()
5622-
* fabs( mGeoTransform[1] )
5623-
);
5624-
5625-
int paintYoffset = static_cast<int>(
5626-
( mViewPort->rectYOffsetFloat -
5627-
mViewPort->rectYOffset )
5628-
/ mMapToPixel->mapUnitsPerPixel()
5629-
* fabs( mGeoTransform[5] )
5630-
);
5631-
5632-
mPainter->drawImage( static_cast<int>( mViewPort->topLeftPoint.x() + 0.5 ),
5633-
static_cast<int>( mViewPort->topLeftPoint.y() + 0.5 + fabs( mGeoTransform[5] ) * mCurrentPartRasterMin / mMapToPixel->mapUnitsPerPixel() ),
5618+
int paintXoffset = 0;
5619+
int paintYoffset = 0;
5620+
int imageX = 0;
5621+
int imageY = 0;
5622+
5623+
if ( mMapToPixel )
5624+
{
5625+
paintXoffset = static_cast<int>(
5626+
( mViewPort->rectXOffsetFloat -
5627+
mViewPort->rectXOffset )
5628+
/ mMapToPixel->mapUnitsPerPixel()
5629+
* fabs( mGeoTransform[1] )
5630+
);
5631+
5632+
paintYoffset = static_cast<int>(
5633+
( mViewPort->rectYOffsetFloat -
5634+
mViewPort->rectYOffset )
5635+
/ mMapToPixel->mapUnitsPerPixel()
5636+
* fabs( mGeoTransform[5] )
5637+
);
5638+
5639+
imageX = static_cast<int>( mViewPort->topLeftPoint.x() + 0.5 );
5640+
imageY = static_cast<int>( mViewPort->topLeftPoint.y() + 0.5 + fabs( mGeoTransform[5] ) * mCurrentPartRasterMin / mMapToPixel->mapUnitsPerPixel() );
5641+
}
5642+
5643+
mPainter->drawImage( imageX,
5644+
imageY,
56345645
*mCurrentImage,
56355646
paintXoffset,
56365647
paintYoffset );
@@ -5659,25 +5670,31 @@ bool QgsRasterImageBuffer::createNextPartImage()
56595670
GDALDataType type = GDALGetRasterDataType( mRasterBand );
56605671
int size = GDALGetDataTypeSize( type ) / 8;
56615672
int xSize = mViewPort->drawableAreaXDim;
5673+
int ySize = mViewPort->drawableAreaYDim;
56625674

56635675
//make the raster tiles overlap at least 2 pixels to avoid white stripes
56645676
int overlapRows = 0;
5665-
overlapRows = mMapToPixel->mapUnitsPerPixel() / fabs( mGeoTransform[5] ) + 2;
5677+
if ( mMapToPixel )
5678+
{
5679+
overlapRows = mMapToPixel->mapUnitsPerPixel() / fabs( mGeoTransform[5] ) + 2;
5680+
}
56665681
if ( mCurrentPartRasterMax + overlapRows >= mViewPort->clippedHeight )
56675682
{
56685683
overlapRows = 0;
56695684
}
56705685
int rasterYSize = mCurrentPartRasterMax - mCurrentPartRasterMin + overlapRows;
56715686

5672-
int ySize = 0;
56735687
if ( 2 >= mViewPort->clippedWidth && 2 >= mViewPort->clippedHeight ) //for zoomed in rasters
56745688
{
56755689
rasterYSize = mViewPort->clippedHeight;
56765690
ySize = mViewPort->drawableAreaYDim;
56775691
}
56785692
else //normal mode
56795693
{
5680-
ySize = fabs((( rasterYSize ) / mMapToPixel->mapUnitsPerPixel() * mGeoTransform[5] ) ) + 0.5;
5694+
if ( mMapToPixel )
5695+
{
5696+
ySize = fabs((( rasterYSize ) / mMapToPixel->mapUnitsPerPixel() * mGeoTransform[5] ) ) + 0.5;
5697+
}
56815698
}
56825699
if ( ySize == 0 )
56835700
{

0 commit comments

Comments
 (0)