44 #include <QtCore/qvarlengtharray.h> 45 #include <QtGui/qpainter.h> 49 #if !defined(QT_SHIVAVG) 82 if (srcImage == VG_INVALID_HANDLE)
88 VG_IMAGE_QUALITY_FASTER, pd);
89 if (dstImage == VG_INVALID_HANDLE)
92 int kernelWidth =
rows();
96 for (
int i = 0; i < kernelWidth; ++i) {
97 for (
int j = 0; j < kernelHeight; ++j) {
98 kernel.
append((VGshort)(kern[j * kernelWidth + i] * 1024.0f));
107 vgSetfv(VG_TILE_FILL_COLOR, 4, values);
109 vgConvolve(dstImage, srcImage,
110 kernelWidth, kernelHeight, 0, 0,
111 kernel.
constData(), 1.0f / 1024.0f, 0.0f,
114 VGImage child = VG_INVALID_HANDLE;
121 child = vgChildImage(dstImage, src.
x(), src.
y(), src.
width(), src.
height());
126 if(child != dstImage)
127 vgDestroyImage(child);
155 if (srcImage == VG_INVALID_HANDLE)
161 VG_IMAGE_QUALITY_FASTER, pd);
162 if (dstImage == VG_INVALID_HANDLE)
169 VGfloat invweights[3];
170 VGfloat alpha = c.
alphaF();
171 weights[0] = c.
redF() * alpha;
172 weights[1] = c.
greenF() * alpha;
173 weights[2] = c.
blueF() * alpha;
174 invweights[0] = (1.0f - weights[0]) * strength;
175 invweights[1] = (1.0f - weights[1]) * strength;
176 invweights[2] = (1.0f - weights[2]) * strength;
179 static const VGfloat redGray = 11.0f / 32.0f;
180 static const VGfloat greenGray = 16.0f / 32.0f;
181 static const VGfloat blueGray = 1.0f - (redGray + greenGray);
183 VGfloat matrix[5][4];
184 matrix[0][0] = redGray * invweights[0] + (1.0f -
strength);
185 matrix[0][1] = redGray * invweights[1];
186 matrix[0][2] = redGray * invweights[2];
188 matrix[1][0] = greenGray * invweights[0];
189 matrix[1][1] = greenGray * invweights[1] + (1.0f -
strength);
190 matrix[1][2] = greenGray * invweights[2];
192 matrix[2][0] = blueGray * invweights[0];
193 matrix[2][1] = blueGray * invweights[1];
194 matrix[2][2] = blueGray * invweights[2] + (1.0f -
strength);
200 matrix[4][0] = weights[0] *
strength;
201 matrix[4][1] = weights[1] *
strength;
202 matrix[4][2] = weights[2] *
strength;
205 vgColorMatrix(dstImage, srcImage, matrix[0]);
207 VGImage child = VG_INVALID_HANDLE;
214 child = vgChildImage(dstImage, src.
x(), src.
y(), src.
width(), src.
height());
219 if(child != dstImage)
220 vgDestroyImage(child);
248 if (srcImage == VG_INVALID_HANDLE)
254 VG_IMAGE_QUALITY_FASTER, pd);
255 if (dstImage == VG_INVALID_HANDLE)
260 VGfloat maxRadius = VGfloat(vgGeti(VG_MAX_GAUSSIAN_STD_DEVIATION));
261 VGfloat radiusF = VGfloat(
blurRadius()) / 2.0f;
262 if (radiusF < 0.001f)
264 else if (radiusF > maxRadius)
268 vgGaussianBlur(dstImage, srcImage, radiusF, radiusF, VG_TILE_PAD);
270 VGImage child = VG_INVALID_HANDLE;
279 child = vgChildImage(dstImage, srect.
x(), srect.
y(), srect.
width(), srect.
height());
284 if(child != dstImage)
285 vgDestroyImage(child);
316 if (srcImage == VG_INVALID_HANDLE)
322 VG_IMAGE_QUALITY_FASTER, pd);
323 if (dstImage == VG_INVALID_HANDLE)
328 VGfloat maxRadius = VGfloat(vgGeti(VG_MAX_GAUSSIAN_STD_DEVIATION));
329 VGfloat radiusF = VGfloat(
radius()) / 2.0f;
330 if (radiusF < 0.001f)
332 else if (radiusF > maxRadius)
335 vgGaussianBlur(dstImage, srcImage, radiusF, radiusF, VG_TILE_PAD);
337 VGImage child = VG_INVALID_HANDLE;
344 child = vgChildImage(dstImage, src.
x(), src.
y(), src.
width(), src.
height());
349 if(child != dstImage)
350 vgDestroyImage(child);
qreal radius() const
Gets the radius of the blur filter.
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
const T * constData() const
QVGPixmapDropShadowFilter()
qreal alphaF() const
Returns the alpha color component of this color.
#define QT_END_NAMESPACE
This macro expands to.
QVGPixmapConvolutionFilter()
qreal greenF() const
Returns the green color component of this color.
The QPointF class defines a point in the plane using floating point precision.
QPointF topLeft() const
Returns the position of the rectangle's top-left corner.
int width() const
Returns the width of the rectangle.
int height() const
Returns the height of the rectangle.
The QObject class is the base class of all Qt objects.
void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect=QRectF()) const
virtual VGImage createTemporaryImage(VGImageFormat format, VGint width, VGint height, VGbitfield allowedQuality, QVGPixmapData *keepData=0)
int width() const
Returns the width.
QPainter * painter() const
Returns the paint engine's painter.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
virtual VGImage toVGImage()
QColor color() const
Gets the color of the colorize filter.
const qreal * convolutionKernel() const
Gets the convolution kernel data.
The QPixmapColorizeFilter class provides colorizing filtering for pixmaps.
void draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src) const
The QPixmapBlurFilter class provides blur filtering for pixmaps.
QVGPixmapColorizeFilter()
qreal blurRadius() const
Returns the radius in pixels of the blur on the drop shadow.
QRect toRect() const
Returns a QRect based on the values of this rectangle.
int rows() const
Gets the number of rows in the convolution kernel.
~QVGPixmapDropShadowFilter()
The QBrush class defines the fill pattern of shapes drawn by QPainter.
static QVGImagePool * instance()
int columns() const
Gets the number of columns in the convolution kernel.
~QVGPixmapColorizeFilter()
int y() const
Returns the y-coordinate of the rectangle's top edge.
QColor color() const
Returns the color of the drop shadow.
QVGPixmapBlurFilter(QObject *parent=0)
qreal redF() const
Returns the red color component of this color.
int x() const
Returns the x-coordinate of the rectangle's left edge.
QObject * parent() const
Returns a pointer to the parent object.
void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const
The QPixmapDropShadowFilter class is a convenience class for drawing pixmaps with drop shadows...
int height() const
Returns the height.
qreal blueF() const
Returns the blue color component of this color.
The QRect class defines a rectangle in the plane using integer precision.
bool isNull() const
Returns true if both the x and y coordinates are set to +0.
QSizeF size() const
Returns the size of the rectangle.
The QPixmap class is an off-screen image representation that can be used as a paint device...
The QPixmapConvolutionFilter class provides convolution filtering for pixmaps.
void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
The QSize class defines the size of a two-dimensional object using integer point precision.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
void qt_vg_drawVGImage(QPainter *painter, const QPointF &pos, VGImage vgImg)
void qt_vg_drawVGImageStencil(QPainter *painter, const QPointF &pos, VGImage vgImg, const QBrush &brush)
void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect=QRectF()) const
qreal strength() const
Gets the strength of the colorize filter, 1.0 means full colorized while 0.0 equals to no filtering a...
void draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src=QRectF()) const
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
virtual void releaseImage(QVGPixmapData *data, VGImage image)
QPointF offset() const
Returns the shadow offset in pixels.
void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect=QRectF()) const
void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect=QRectF()) const
QPixmapData * pixmapData() const
~QVGPixmapConvolutionFilter()