1
/****************************************************************************
2
**
3
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4
** All rights reserved.
5
** Contact: Nokia Corporation (qt-info@nokia.com)
6
**
7
** This file is part of the QtGui module of the Qt Toolkit.
8
**
9
** $QT_BEGIN_LICENSE:LGPL$
10
** No Commercial Usage
11
** This file contains pre-release code and may not be distributed.
12
** You may use this file in accordance with the terms and conditions
13
** contained in the Technology Preview License Agreement accompanying
14
** this package.
15
**
16
** GNU Lesser General Public License Usage
17
** Alternatively, this file may be used under the terms of the GNU Lesser
18
** General Public License version 2.1 as published by the Free Software
19
** Foundation and appearing in the file LICENSE.LGPL included in the
20
** packaging of this file.  Please review the following information to
21
** ensure the GNU Lesser General Public License version 2.1 requirements
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23
**
24
** In addition, as a special exception, Nokia gives you certain additional
25
** rights.  These rights are described in the Nokia Qt LGPL Exception
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27
**
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
30
**
31
**
32
**
33
**
34
**
35
**
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
61
QT_BEGIN_HEADER
62
63
QT_BEGIN_NAMESPACE
64
65
QT_MODULE(Gui)
66
67
class QPainter;
68
class QPixmapData;
69
70
class QPixmapFilterPrivate;
71
72
class Q_GUI_EXPORT QPixmapFilter : public QObject
73
{
74
    Q_OBJECT
75
    Q_DECLARE_PRIVATE(QPixmapFilter)
76
public:
77
    virtual ~QPixmapFilter() = 0;
78
79
    enum FilterType {
80
        ConvolutionFilter,
81
        ColorizeFilter,
82
        DropShadowFilter,
83
        BlurFilter,
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:
95
    QPixmapFilter(QPixmapFilterPrivate &d, FilterType type, QObject *parent);
96
    QPixmapFilter(FilterType type, QObject *parent);
97
};
98
99
class QPixmapConvolutionFilterPrivate;
100
101
class Q_GUI_EXPORT QPixmapConvolutionFilter : public QPixmapFilter
102
{
103
    Q_OBJECT
104
    Q_DECLARE_PRIVATE(QPixmapConvolutionFilter)
105
106
public:
107
    QPixmapConvolutionFilter(QObject *parent = 0);
108
    ~QPixmapConvolutionFilter();
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:
116
    friend class QGLPixmapConvolutionFilter;
117
    friend class QVGPixmapConvolutionFilter;
118
    const qreal *convolutionKernel() const;
119
    int rows() const;
120
    int columns() const;
121
};
122
123
class QPixmapBlurFilterPrivate;
124
125
class Q_GUI_EXPORT QPixmapBlurFilter : public QPixmapFilter
126
{
127
    Q_OBJECT
128
    Q_DECLARE_PRIVATE(QPixmapBlurFilter)
129
130
public:
131
    QPixmapBlurFilter(QObject *parent = 0);
132
    ~QPixmapBlurFilter();
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
147
class QPixmapColorizeFilterPrivate;
148
149
class Q_GUI_EXPORT QPixmapColorizeFilter : public QPixmapFilter
150
{
151
    Q_OBJECT
152
    Q_DECLARE_PRIVATE(QPixmapColorizeFilter)
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
166
class QPixmapDropShadowFilterPrivate;
167
168
class Q_GUI_EXPORT QPixmapDropShadowFilter : public QPixmapFilter
169
{
170
    Q_OBJECT
171
    Q_DECLARE_PRIVATE(QPixmapDropShadowFilter)
172
173
public:
174
    QPixmapDropShadowFilter(QObject *parent = 0);
175
    ~QPixmapDropShadowFilter();
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
191
QT_END_NAMESPACE
192
193
QT_END_HEADER
194
195
#endif //QT_NO_GRAPHICSEFFECT
196
#endif // QPIXMAPFILTER_H