Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qpixmapfilter_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QPIXMAPFILTER_H
5#define QPIXMAPFILTER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include <QtCore/qnamespace.h>
20#include <QtGui/qpixmap.h>
21#include <QtWidgets/qgraphicseffect.h>
22
23QT_REQUIRE_CONFIG(graphicseffect);
24
26
27class QPainter;
28class QPlatformPixmap;
29
31
32class Q_WIDGETS_EXPORT QPixmapFilter : public QObject
33{
35 Q_DECLARE_PRIVATE(QPixmapFilter)
36public:
37 virtual ~QPixmapFilter() = 0;
38
47
48 FilterType type() const;
49
50 virtual QRectF boundingRectFor(const QRectF &rect) const;
51
52 virtual void draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &srcRect = QRectF()) const = 0;
53
54protected:
57};
58
60
61class Q_WIDGETS_EXPORT QPixmapConvolutionFilter : public QPixmapFilter
62{
64 Q_DECLARE_PRIVATE(QPixmapConvolutionFilter)
65
66public:
67 QPixmapConvolutionFilter(QObject *parent = nullptr);
69
70 void setConvolutionKernel(const qreal *matrix, int rows, int columns);
71
72 QRectF boundingRectFor(const QRectF &rect) const override;
73 void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const override;
74
75private:
76 friend class QVGPixmapConvolutionFilter;
77 const qreal *convolutionKernel() const;
78 int rows() const;
79 int columns() const;
80};
81
83
84class Q_WIDGETS_EXPORT QPixmapBlurFilter : public QPixmapFilter
85{
87 Q_DECLARE_PRIVATE(QPixmapBlurFilter)
88
89public:
90 QPixmapBlurFilter(QObject *parent = nullptr);
92
93 void setRadius(qreal radius);
94 void setBlurHints(QGraphicsBlurEffect::BlurHints hints);
95
96 qreal radius() const;
97 QGraphicsBlurEffect::BlurHints blurHints() const;
98
99 QRectF boundingRectFor(const QRectF &rect) const override;
100 void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const override;
101};
102
104
105class Q_WIDGETS_EXPORT QPixmapColorizeFilter : public QPixmapFilter
106{
108 Q_DECLARE_PRIVATE(QPixmapColorizeFilter)
109
110public:
111 QPixmapColorizeFilter(QObject *parent = nullptr);
113
114 void setColor(const QColor& color);
115 QColor color() const;
116
117 void setStrength(qreal strength);
118 qreal strength() const;
119
120 void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const override;
121};
122
124
125class Q_WIDGETS_EXPORT QPixmapDropShadowFilter : public QPixmapFilter
126{
128 Q_DECLARE_PRIVATE(QPixmapDropShadowFilter)
129
130public:
131 QPixmapDropShadowFilter(QObject *parent = nullptr);
133
134 QRectF boundingRectFor(const QRectF &rect) const override;
135 void draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src = QRectF()) const override;
136
137 qreal blurRadius() const;
138 void setBlurRadius(qreal radius);
139
140 QColor color() const;
141 void setColor(const QColor &color);
142
143 QPointF offset() const;
144 void setOffset(const QPointF &offset);
145 inline void setOffset(qreal dx, qreal dy) { setOffset(QPointF(dx, dy)); }
146};
147
149
150#endif // QPIXMAPFILTER_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
Definition qobject.h:103
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
The QPixmapBlurFilter class provides blur filtering for pixmaps.
The QPixmapColorizeFilter class provides colorizing filtering for pixmaps.
The QPixmapConvolutionFilter class provides convolution filtering for pixmaps.
The QPixmapDropShadowFilter class is a convenience class for drawing pixmaps with drop shadows.
void setOffset(qreal dx, qreal dy)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QPixmapFilter class provides the basic functionality for pixmap filter classes....
virtual void draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &srcRect=QRectF()) const =0
Uses painter to draw filtered result of src at the point specified by p.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
The QPlatformPixmap class provides an abstraction for native pixmaps.
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore\reentrant
Definition qrect.h:484
rect
[4]
Combined button and popup list for selecting options.
GLenum src
GLuint color
[2]
GLenum type
GLenum GLuint GLintptr offset
GLuint GLenum matrix
GLfloat GLfloat p
[1]
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
double qreal
Definition qtypes.h:187
myFilter setColor(QColor(128, 0, 0))
myFilter setConvolutionKernel(kernel, 3, 3)
myFilter draw(painter, QPoint(0, 0), originalPixmap)
QPainter painter(this)
[7]