1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2015 The Qt Company Ltd. 4 ** Contact: http://www.qt.io/licensing/ 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 The Qt Company. For licensing terms 14 ** and conditions see http://www.qt.io/terms-conditions. For further 15 ** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free 20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and 21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the 22 ** following information to ensure the GNU Lesser General Public License 23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and 24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 25 ** 26 ** As a special exception, The Qt Company gives you certain additional 27 ** rights. These rights are described in The Qt Company LGPL Exception 28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 29 ** 30 ** GNU General Public License Usage 31 ** Alternatively, this file may be used under the terms of the GNU 32 ** General Public License version 3.0 as published by the Free Software 33 ** Foundation and appearing in the file LICENSE.GPL included in the 34 ** packaging of this file. Please review the following information to 35 ** ensure the GNU General Public License version 3.0 requirements will be 36 ** met: http://www.gnu.org/copyleft/gpl.html. 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); setOffset(qreal dx,qreal dy)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 197