39 if ( !p || !mIterator || !viewPort || !qgsMapToPixel )
57 std::unique_ptr< QgsRasterBlock > block;
61 block, topLeftCol, topLeftRow ) )
65 QgsDebugMsg( QStringLiteral(
"Cannot get block" ) );
69 QImage img = block->image();
74 QPrinter *printer =
dynamic_cast<QPrinter *
>( p->device() );
75 if ( printer && printer->outputFormat() == QPrinter::PdfFormat )
79 img = img.convertToFormat( QImage::Format_ARGB32 );
80 QRgb transparentBlack = qRgba( 0, 0, 0, 0 );
81 QRgb transparentWhite = qRgba( 255, 255, 255, 0 );
82 for (
int x = 0; x < img.width(); x++ )
84 for (
int y = 0; y < img.height(); y++ )
86 if ( img.pixel( x, y ) == transparentBlack )
88 img.setPixel( x, y, transparentWhite );
100 p->setCompositionMode( QPainter::CompositionMode_Source );
103 drawImage( p, viewPort, img, topLeftCol, topLeftRow, qgsMapToPixel );
108 p->setCompositionMode( QPainter::CompositionMode_SourceOver );
120 if ( !p || !viewPort )
128 p->setRenderHint( QPainter::Antialiasing,
false );
133 p->setBrush( QBrush( QColor( Qt::white ), Qt::NoBrush ) );
146 p->translate( cx, cy );
147 p->rotate( rotation );
148 p->translate( -cx, -cy );
152 p->drawImage( tlPoint, img );
156 QRectF br = QRectF( tlPoint, img.size() );
157 QPointF
c = br.center();
158 double rad = std::max( br.width(), br.height() ) / 10;
159 p->drawRoundedRect( br, rad, rad );
160 p->drawLine( QLineF( br.x(), br.y(), br.x() + br.width(), br.y() + br.height() ) );
161 p->drawLine( QLineF( br.x() + br.width(), br.y(), br.x(), br.y() + br.height() ) );
163 double nw = br.width() * 0.5;
164 double nh = br.height() * 0.5;
165 br = QRectF(
c - QPointF( nw / 2, nh / 2 ), QSize( nw, nh ) );
166 p->drawRoundedRect( br, rad, rad );
168 nw = br.width() * 0.5;
169 nh = br.height() * 0.5;
170 br = QRectF(
c - QPointF( nw / 2, nh / 2 ), QSize( nw, nh ) );
171 p->drawRoundedRect( br, rad, rad );
bool isCanceled() const
Tells whether the operation has been canceled already.
Perform transforms between map coordinates and device coordinates.
int mapHeight() const
Returns current map height in pixels.
int mapWidth() const
Returns current map width in pixels The information is only known if setRotation was used.
double mapRotation() const
Returns current map rotation in degrees (clockwise)
Feedback object tailored for raster block reading.
bool renderPartialOutput() const
Whether our painter is drawing to a temporary image used just by this layer.
void drawImage(QPainter *p, QgsRasterViewPort *viewPort, const QImage &img, int topLeftCol, int topLeftRow, const QgsMapToPixel *mapToPixel=nullptr) const
Draws raster part.
void draw(QPainter *p, QgsRasterViewPort *viewPort, const QgsMapToPixel *qgsMapToPixel, QgsRasterBlockFeedback *feedback=nullptr)
Draws raster data.
QgsRasterDrawer(QgsRasterIterator *iterator)
Iterator for sequentially processing raster cells.
bool readNextRasterPart(int bandNumber, int &nCols, int &nRows, QgsRasterBlock **block, int &topLeftCol, int &topLeftRow)
Fetches next part of raster data, caller takes ownership of the block and caller should delete the bl...
void startRasterRead(int bandNumber, qgssize nCols, qgssize nRows, const QgsRectangle &extent, QgsRasterBlockFeedback *feedback=nullptr)
Start reading of raster band.
Scoped object for saving and restoring a QPainter object's state.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
#define QgsDebugMsgLevel(str, level)
This class provides details of the viewable area that a raster will be rendered into.
qgssize mHeight
Height, number of rows to be rendered.
QgsPointXY mTopLeftPoint
Coordinate (in output device coordinate system) of top left corner of the part of the raster that is ...
QgsRectangle mDrawnExtent
Intersection of current map extent and layer extent.
qgssize mWidth
Width, number of columns to be rendered.