37 if ( !p || !mIterator || !viewPort || !qgsMapToPixel )
55 std::unique_ptr< QgsRasterBlock > block;
59 block, topLeftCol, topLeftRow ) )
67 QImage img = block->image();
72 QPrinter *printer =
dynamic_cast<QPrinter *
>( p->device() );
73 if ( printer && printer->outputFormat() == QPrinter::PdfFormat )
77 img = img.convertToFormat( QImage::Format_ARGB32 );
78 QRgb transparentBlack = qRgba( 0, 0, 0, 0 );
79 QRgb transparentWhite = qRgba( 255, 255, 255, 0 );
80 for (
int x = 0; x < img.width(); x++ )
82 for (
int y = 0; y < img.height(); y++ )
84 if ( img.pixel( x, y ) == transparentBlack )
86 img.setPixel( x, y, transparentWhite );
98 p->setCompositionMode( QPainter::CompositionMode_Source );
101 drawImage( p, viewPort, img, topLeftCol, topLeftRow, qgsMapToPixel );
106 p->setCompositionMode( QPainter::CompositionMode_SourceOver );
118 if ( !p || !viewPort )
126 p->setRenderHint( QPainter::Antialiasing,
false );
131 p->setBrush( QBrush( QColor( Qt::white ), Qt::NoBrush ) );
144 p->translate( cx, cy );
145 p->rotate( rotation );
146 p->translate( -cx, -cy );
150 p->drawImage( tlPoint, img );
154 QRectF br = QRectF( tlPoint, img.size() );
155 QPointF
c = br.center();
156 double rad = std::max( br.width(), br.height() ) / 10;
157 p->drawRoundedRect( br, rad, rad );
158 p->drawLine( QLineF( br.x(), br.y(), br.x() + br.width(), br.y() + br.height() ) );
159 p->drawLine( QLineF( br.x() + br.width(), br.y(), br.x(), br.y() + br.height() ) );
161 double nw = br.width() * 0.5;
162 double nh = br.height() * 0.5;
163 br = QRectF( c - QPointF( nw / 2, nh / 2 ), QSize( nw, nh ) );
164 p->drawRoundedRect( br, rad, rad );
166 nw = br.width() * 0.5;
167 nh = br.height() * 0.5;
168 br = QRectF( c - QPointF( nw / 2, nh / 2 ), QSize( nw, nh ) );
169 p->drawRoundedRect( br, rad, rad );
void drawImage(QPainter *p, QgsRasterViewPort *viewPort, const QImage &img, int topLeftCol, int topLeftRow, const QgsMapToPixel *mapToPixel=nullptr) const
Draws raster part.
bool renderPartialOutput() const
Whether our painter is drawing to a temporary image used just by this layer.
Iterator for sequentially processing raster cells.
int mWidth
Width, number of columns to be rendered.
double mapRotation() const
Returns current map rotation in degrees.
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
Perform transforms between map coordinates and device coordinates.
int mapWidth() const
Returns current map width in pixels The information is only known if setRotation was used...
int mapHeight() const
Returns current map height in pixels.
#define QgsDebugMsgLevel(str, level)
QgsRasterDrawer(QgsRasterIterator *iterator)
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...
bool isCanceled() const
Tells whether the operation has been canceled already.
int mHeight
Distance in map units from bottom edge to top edge for the part of the raster that is to be rendered...
This class provides details of the viewable area that a raster will be rendered into.
Feedback object tailored for raster block reading.
void draw(QPainter *p, QgsRasterViewPort *viewPort, const QgsMapToPixel *qgsMapToPixel, QgsRasterBlockFeedback *feedback=nullptr)
Draws raster data.
void startRasterRead(int bandNumber, int nCols, int nRows, const QgsRectangle &extent, QgsRasterBlockFeedback *feedback=nullptr)
Start reading of raster band.
QgsRectangle mDrawnExtent
Intersection of current map extent and layer extent.
QgsPointXY mTopLeftPoint
Coordinate (in output device coordinate system) of top left corner of the part of the raster that is ...