Qt 4.8
qpixmapfilter_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QPIXMAPFILTER_H
43 #define QPIXMAPFILTER_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include <QtCore/qnamespace.h>
57 #include <QtGui/qpixmap.h>
58 #include <QtGui/qgraphicseffect.h>
59 
60 #ifndef QT_NO_GRAPHICSEFFECT
62 
64 
65 QT_MODULE(Gui)
66 
67 class QPainter;
68 class QPixmapData;
69 
71 
73 {
74  Q_OBJECT
76 public:
77  virtual ~QPixmapFilter() = 0;
78 
79  enum FilterType {
84 
85  UserFilter = 1024
86  };
87 
88  FilterType type() const;
89 
90  virtual QRectF boundingRectFor(const QRectF &rect) const;
91 
92  virtual void draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &srcRect = QRectF()) const = 0;
93 
94 protected:
97 };
98 
100 
102 {
103  Q_OBJECT
105 
106 public:
107  QPixmapConvolutionFilter(QObject *parent = 0);
109 
110  void setConvolutionKernel(const qreal *matrix, int rows, int columns);
111 
112  QRectF boundingRectFor(const QRectF &rect) const;
113  void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
114 
115 private:
118  const qreal *convolutionKernel() const;
119  int rows() const;
120  int columns() const;
121 };
122 
124 
126 {
127  Q_OBJECT
129 
130 public:
131  QPixmapBlurFilter(QObject *parent = 0);
133 
134  void setRadius(qreal radius);
135  void setBlurHints(QGraphicsBlurEffect::BlurHints hints);
136 
137  qreal radius() const;
138  QGraphicsBlurEffect::BlurHints blurHints() const;
139 
140  QRectF boundingRectFor(const QRectF &rect) const;
141  void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
142 
143 private:
144  friend class QGLPixmapBlurFilter;
145 };
146 
148 
150 {
151  Q_OBJECT
153 
154 public:
155  QPixmapColorizeFilter(QObject *parent = 0);
156 
157  void setColor(const QColor& color);
158  QColor color() const;
159 
160  void setStrength(qreal strength);
161  qreal strength() const;
162 
163  void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
164 };
165 
167 
169 {
170  Q_OBJECT
172 
173 public:
174  QPixmapDropShadowFilter(QObject *parent = 0);
176 
177  QRectF boundingRectFor(const QRectF &rect) const;
178  void draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src = QRectF()) const;
179 
180  qreal blurRadius() const;
181  void setBlurRadius(qreal radius);
182 
183  QColor color() const;
184  void setColor(const QColor &color);
185 
186  QPointF offset() const;
187  void setOffset(const QPointF &offset);
188  inline void setOffset(qreal dx, qreal dy) { setOffset(QPointF(dx, dy)); }
189 };
190 
192 
194 
195 #endif //QT_NO_GRAPHICSEFFECT
196 #endif // QPIXMAPFILTER_H
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
void setOffset(qreal dx, qreal dy)
Sets the shadow offset in pixels to be the displacement specified by the horizontal dx and vertical d...
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
virtual QRectF boundingRectFor(const QRectF &rect) const
Returns the bounding rectangle that is affected by the pixmap filter if the filter is applied to the ...
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
FilterType
This enum describes the types of filter that can be applied to pixmaps.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
const qreal * convolutionKernel() const
Gets the convolution kernel data.
The QPixmapColorizeFilter class provides colorizing filtering for pixmaps.
The QPixmapBlurFilter class provides blur filtering for pixmaps.
#define Q_OBJECT
Definition: qobjectdefs.h:157
int rows() const
Gets the number of rows in the convolution kernel.
int columns() const
Gets the number of columns in the convolution kernel.
The QPixmapFilter class provides the basic functionality for pixmap filter classes.
The QPixmapDropShadowFilter class is a convenience class for drawing pixmaps with drop shadows...
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QPixmapConvolutionFilter class provides convolution filtering for pixmaps.
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
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.
#define QT_END_HEADER
Definition: qglobal.h:137