@@ -2195,7 +2195,7 @@ QPixmap QgsRasterLayer::legendAsPixmap( bool theWithNameFlag )
2195
2195
}
2196
2196
2197
2197
} // end of pseudocolor check
2198
- else if ( mDrawingStyle == PalettedMultiBandColor || mDrawingStyle == MultiBandColor )
2198
+ else if ( mDrawingStyle == PalettedMultiBandColor || mDrawingStyle == MultiBandColor || mDrawingStyle == PalettedColor )
2199
2199
{
2200
2200
//
2201
2201
// Create the legend pixmap showing red green and blue band mappings
@@ -5539,7 +5539,7 @@ QgsRasterImageBuffer::~QgsRasterImageBuffer()
5539
5539
5540
5540
void QgsRasterImageBuffer::reset ( int maxPixelsInVirtualMemory )
5541
5541
{
5542
- if ( !mRasterBand || !mPainter || !mViewPort || ! mMapToPixel )
5542
+ if ( !mRasterBand || !mPainter || !mViewPort )
5543
5543
{
5544
5544
mValid = false ;
5545
5545
return ;
@@ -5615,22 +5615,33 @@ bool QgsRasterImageBuffer::createNextPartImage()
5615
5615
}
5616
5616
else
5617
5617
{
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,
5634
5645
*mCurrentImage ,
5635
5646
paintXoffset,
5636
5647
paintYoffset );
@@ -5659,25 +5670,31 @@ bool QgsRasterImageBuffer::createNextPartImage()
5659
5670
GDALDataType type = GDALGetRasterDataType ( mRasterBand );
5660
5671
int size = GDALGetDataTypeSize ( type ) / 8 ;
5661
5672
int xSize = mViewPort ->drawableAreaXDim ;
5673
+ int ySize = mViewPort ->drawableAreaYDim ;
5662
5674
5663
5675
// make the raster tiles overlap at least 2 pixels to avoid white stripes
5664
5676
int overlapRows = 0 ;
5665
- overlapRows = mMapToPixel ->mapUnitsPerPixel () / fabs ( mGeoTransform [5 ] ) + 2 ;
5677
+ if ( mMapToPixel )
5678
+ {
5679
+ overlapRows = mMapToPixel ->mapUnitsPerPixel () / fabs ( mGeoTransform [5 ] ) + 2 ;
5680
+ }
5666
5681
if ( mCurrentPartRasterMax + overlapRows >= mViewPort ->clippedHeight )
5667
5682
{
5668
5683
overlapRows = 0 ;
5669
5684
}
5670
5685
int rasterYSize = mCurrentPartRasterMax - mCurrentPartRasterMin + overlapRows;
5671
5686
5672
- int ySize = 0 ;
5673
5687
if ( 2 >= mViewPort ->clippedWidth && 2 >= mViewPort ->clippedHeight ) // for zoomed in rasters
5674
5688
{
5675
5689
rasterYSize = mViewPort ->clippedHeight ;
5676
5690
ySize = mViewPort ->drawableAreaYDim ;
5677
5691
}
5678
5692
else // normal mode
5679
5693
{
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
+ }
5681
5698
}
5682
5699
if ( ySize == 0 )
5683
5700
{
0 commit comments