QPixmapConvolutionFilter Class
The QPixmapConvolutionFilter class provides convolution filtering for pixmaps. More...
Header: | #include <QPixmapConvolutionFilter> |
Inherits: | QPixmapFilter |
Public Functions
QPixmapConvolutionFilter(QObject *parent = nullptr) | |
virtual | ~QPixmapConvolutionFilter() |
void | setConvolutionKernel(const qreal *kernel, int rows, int columns) |
Reimplemented Public Functions
virtual QRectF | boundingRectFor(const QRectF &rect) const override |
virtual void | draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &srcRect = QRectF()) const override |
Detailed Description
\since
4.5 \ingroup
painting
QPixmapConvolutionFilter implements a convolution pixmap filter, which is applied when draw() is called. A convolution filter lets you distort an image by setting the values of a matrix of qreal values called its kernel. The matrix's values are usually between -1.0 and 1.0.
Example:
QPixmapConvolutionFilter *myFilter = new QPixmapConvolutionFilter; qreal kernel[] = { 0.0,-1.0, 0.0, -1.0, 5.0,-1.0, 0.0,-1.0, 0.0 }; myFilter->setConvolutionKernel(kernel, 3, 3); myFilter->draw(painter, QPoint(0, 0), originalPixmap);
\internal
See also Pixmap Filters Example, QPixmapColorizeFilter, and QPixmapDropShadowFilter.
Member Function Documentation
QPixmapConvolutionFilter::QPixmapConvolutionFilter(QObject *parent = nullptr)
Constructs a pixmap convolution filter.
By default there is no convolution kernel.
\internal
[virtual noexcept]
QPixmapConvolutionFilter::~QPixmapConvolutionFilter()
Destructor of pixmap convolution filter.
\internal
[override virtual]
QRectF QPixmapConvolutionFilter::boundingRectFor(const QRectF &rect) const
Reimplements: QPixmapFilter::boundingRectFor(const QRectF &rect) const.
\internal
[override virtual]
void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &srcRect = QRectF()) const
\internal
void QPixmapConvolutionFilter::setConvolutionKernel(const qreal *kernel, int rows, int columns)
Sets convolution kernel with the given number of rows and columns. Values from kernel are copied to internal data structure.
To preserve the intensity of the pixmap, the sum of all the values in the convolution kernel should add up to 1.0. A sum greater than 1.0 produces a lighter result and a sum less than 1.0 produces a darker and transparent result.
\internal