13#include "private/qguiapplication_p.h"
14#include "private/qpaintengineex_p.h"
15#include "private/qpaintengine_raster_p.h"
17#include "private/qmath_p.h"
18#include "private/qmemrotate_p.h"
19#include "private/qdrawhelper_p.h"
83 d_func()->type =
type;
94 d_func()->type =
type;
198 d->convoluteAlpha =
true;
224 delete []
d->convolutionKernel;
225 d->convolutionKernel =
new qreal[rows * columns];
226 memcpy(
d->convolutionKernel,
kernel,
sizeof(
qreal) * rows * columns);
227 d->kernelWidth = columns;
228 d->kernelHeight = rows;
236const qreal *QPixmapConvolutionFilter::convolutionKernel()
const
239 return d->convolutionKernel;
247int QPixmapConvolutionFilter::rows()
const
250 return d->kernelHeight;
258int QPixmapConvolutionFilter::columns()
const
261 return d->kernelWidth;
271 return rect.adjusted(-
d->kernelWidth / 2, -
d->kernelHeight / 2, (
d->kernelWidth - 1) / 2, (
d->kernelHeight - 1) / 2);
288 std::unique_ptr<int[]> fixedKernel(
new int[kernelWidth * kernelHeight]);
289 for(
int i = 0;
i < kernelWidth*kernelHeight;
i++)
291 fixedKernel[
i] = (int)(65536 *
kernel[
i]);
295 QRectF bounded = trect.
adjusted(-kernelWidth / 2, -kernelHeight / 2, (kernelWidth - 1) / 2, (kernelHeight - 1) / 2);
300 QRectF sbounded = srect.
adjusted(-kernelWidth / 2, -kernelHeight / 2, (kernelWidth - 1) / 2, (kernelHeight - 1) / 2);
306 int yk = srcStartPoint.
y();
307 for (
int y = targetRect.
top();
y <= targetRect.
bottom();
y++) {
309 int xk = srcStartPoint.
x();
310 for(
int x = targetRect.
left();
x <= targetRect.
right();
x++) {
317 int kernely = -kernelHeight/2;
319 int endy = kernelHeight;
320 if (yk+kernely+endy >= srcImage.
height())
321 endy = kernelHeight-((yk+kernely+endy)-srcImage.
height())-1;
323 starty = -(yk+kernely);
325 int kernelx = -kernelWidth/2;
327 int endx = kernelWidth;
328 if (xk+kernelx+endx >= srcImage.
width())
329 endx = kernelWidth-((xk+kernelx+endx)-srcImage.
width())-1;
331 startx = -(xk+kernelx);
333 for (
int ys = starty; ys < endy; ys ++) {
334 const uint *
pix = sourceStart + (processImage.
bytesPerLine()/
sizeof(
uint))*(yk+kernely+ys) + ((xk+kernelx+startx));
335 const uint *endPix =
pix+endx-startx;
336 int kernelPos = ys*kernelWidth+startx;
337 while (
pix < endPix) {
338 int factor = fixedKernel[kernelPos++];
339 a += (((*pix) & 0xff000000)>>24) * factor;
340 r += (((*pix) & 0x00ff0000)>>16) * factor;
341 g += (((*pix) & 0x0000ff00)>>8 ) * factor;
342 b += (((*pix) & 0x000000ff) ) * factor;
347 r =
qBound((
int)0,
r >> 16, (
int)255);
348 g =
qBound((
int)0,
g >> 16, (
int)255);
349 b =
qBound((
int)0,
b >> 16, (
int)255);
350 a =
qBound((
int)0,
a >> 16, (
int)255);
357 uchar ca = (current&0xff000000)>>24;
358 uchar cr = (current&0x00ff0000)>>16;
359 uchar cg = (current&0x0000ff00)>>8;
360 uchar cb = (current&0x000000ff);
362 (((ca*(255-
a) >> 8)+
a) << 24)+
363 (((cr*(255-
a) >> 8)+
r) << 16)+
364 (((cg*(255-
a) >> 8)+
g) << 8)+
365 (((
cb*(255-
a) >> 8)+
b));
383 if (
d->kernelWidth<=0 ||
d->kernelHeight <= 0)
432 d->convolutionKernel,
469 QGraphicsBlurEffect::BlurHints
hints;
555 return rect.adjusted(-delta, -delta, delta, delta);
569template<
int aprec,
int zprec>
574#define Z_MASK (0xff << zprec)
578 const int B_zprec = qt_static_shift<zprec>(*pixel) &
Z_MASK;
581 const int zR_zprec = zR >> aprec;
582 const int zG_zprec = zG >> aprec;
583 const int zB_zprec = zB >> aprec;
584 const int zA_zprec = zA >> aprec;
586 zR +=
alpha * (R_zprec - zR_zprec);
587 zG +=
alpha * (G_zprec - zG_zprec);
588 zB +=
alpha * (B_zprec - zB_zprec);
589 zA +=
alpha * (A_zprec - zA_zprec);
591#define ZA_MASK (0xff << (zprec + aprec))
594 | qt_static_shift<16 - zprec - aprec>(zR &
ZA_MASK)
596 | qt_static_shift<-zprec - aprec>(zB &
ZA_MASK);
602template<
int aprec,
int zprec>
605 const int A_zprec = int(*(bptr)) << zprec;
606 const int z_zprec =
z >> aprec;
607 z +=
alpha * (A_zprec - z_zprec);
608 *(bptr) =
z >> (zprec + aprec);
611template<
int aprec,
int zprec,
bool alphaOnly>
616 int zR = 0, zG = 0, zB = 0, zA = 0;
622 const int im_width = im.
width();
625 qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA,
alpha);
627 qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA,
alpha);
636 qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA,
alpha);
638 qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA,
alpha);
659template <
int aprec,
int zprec,
bool alphaOnly>
664 radius *=
qreal(0.5);
674 const qreal cutOffIntensity = 2;
677 :
qRound((1<<aprec)*(1 -
qPow(cutOffIntensity * (1 /
qreal(255)), 1 / radius)));
679 int img_height =
img.height();
680 for (
int row = 0;
row < img_height; ++
row) {
681 for (
int i = 0;
i <= int(improvedQuality); ++
i)
682 qt_blurrow<aprec, zprec, alphaOnly>(
img,
row,
alpha);
687 if (transposed >= 0) {
688 if (
img.depth() == 8) {
689 qt_memrotate270(
reinterpret_cast<const quint8*
>(
img.bits()),
690 img.width(),
img.height(),
img.bytesPerLine(),
694 qt_memrotate270(
reinterpret_cast<const quint32*
>(
img.bits()),
695 img.width(),
img.height(),
img.bytesPerLine(),
700 if (
img.depth() == 8) {
701 qt_memrotate90(
reinterpret_cast<const quint8*
>(
img.bits()),
702 img.width(),
img.height(),
img.bytesPerLine(),
706 qt_memrotate90(
reinterpret_cast<const quint32*
>(
img.bits()),
707 img.width(),
img.height(),
img.bytesPerLine(),
713 img_height = temp.
height();
714 for (
int row = 0;
row < img_height; ++
row) {
715 for (
int i = 0;
i <= int(improvedQuality); ++
i)
716 qt_blurrow<aprec, zprec, alphaOnly>(temp,
row,
alpha);
719 if (transposed == 0) {
720 if (
img.depth() == 8) {
721 qt_memrotate90(
reinterpret_cast<const quint8*
>(temp.
bits()),
726 qt_memrotate90(
reinterpret_cast<const quint32*
>(temp.
bits()),
735#define AVG(a,b) ( ((((a)^(b)) & 0xfefefefeUL) >> 1) + ((a)&(b)) )
736#define AVG16(a,b) ( ((((a)^(b)) & 0xf7deUL) >> 1) + ((a)&(b)) )
756 int ww = dest.
width();
759 for (
int y = hh;
y; --
y,
dst += dx,
src += sx2) {
763 for (
int x = ww;
x; --
x, ++
q,
p1 += 2,
p2 += 2)
764 *
q = ((
int(
p1[0]) + int(
p1[1]) + int(
p2[0]) + int(
p2[1])) + 2) >> 2;
778 int ww = dest.
width();
781 for (
int y = hh;
y; --
y,
dst += dx,
src += sx2) {
785 for (
int x = ww;
x; --
x,
q += 3,
p1 += 6,
p2 += 6) {
815 int ww = dest.
width();
818 for (
int y = hh;
y; --
y,
dst += dx,
src += sx2) {
822 for (
int x = ww;
x; --
x,
q++,
p1 += 2,
p2 += 2)
838 if (radius >= 4 && blurImage.
width() >= 2 && blurImage.
height() >= 2) {
841 radius *=
qreal(0.5);
845 expblur<12, 10, true>(blurImage, radius, quality, transposed);
847 expblur<12, 10, false>(blurImage, radius, quality, transposed);
859 expblur<12, 10, true>(blurImage, radius, quality, transposed);
861 expblur<12, 10, false>(blurImage, radius, quality, transposed);
880 srcRect =
src.rect();
882 if (
d->radius <= 1) {
890 scaledRadius /=
scale;
894 if (srcRect ==
src.rect()) {
895 srcImage =
src.toImage();
915 srcRect = dest.
rect();
916 destRect = dest.
rect();
918 if (&
image != &dest) {
922 const unsigned int *
data = (
const unsigned int *)
image.bits();
923 unsigned int *outData = (
unsigned int *)dest.
bits();
933 int yd = destRect.
top();
935 data = (
const unsigned int*)
image.scanLine(
y);
936 outData = (
unsigned int*)dest.
scanLine(yd++);
937 int xd = destRect.
left();
991 d->alphaBlend =
false;
1069 srcImage =
src.toImage();
1090 if (
d->alphaBlend) {
1097 destImage = std::move(
buffer);
1273 return rect.united(
rect.translated(
d->offset).adjusted(-
d->radius, -
d->radius,
d->radius,
d->radius));
1305 tmp = std::move(blurred);
1308 tmpPainter.
begin(&tmp);
1314 p->drawImage(
pos, tmp);
1322#include "moc_qpixmapfilter_p.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
The QGraphicsBlurEffect class provides a blur effect.
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false.
qsizetype bytesPerLine() const
Returns the number of bytes per image scanline.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
QSize size() const
Returns the size of the image, i.e.
int width() const
Returns the width of the image.
uchar * bits()
Returns a pointer to the first pixel data.
int height() const
Returns the height of the image.
@ Format_ARGB8565_Premultiplied
@ Format_ARGB32_Premultiplied
void fill(uint pixel)
Fills the entire image with the given pixelValue.
Format format() const
Returns the format of the image.
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the image.
QSizeF deviceIndependentSize() const
Returns the size of the image in device independent pixels.
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
virtual int devType() const
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns \nullptr...
The QPainter class performs low-level painting on widgets and other paint devices.
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
QTransform combinedTransform() const
Returns the transformation matrix combining the current window/viewport and world transformation.
bool begin(QPaintDevice *)
Begins painting the paint device and returns true if successful; otherwise returns false.
const QTransform & worldTransform() const
Returns the world transformation matrix.
void setOpacity(qreal opacity)
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
void setWorldTransform(const QTransform &matrix, bool combine=false)
Sets the world transformation matrix.
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Draws the rectangular portion source of the given image into the target rectangle in the paint device...
const QTransform & deviceTransform() const
Returns the matrix that transforms from logical coordinates to device coordinates of the platform dep...
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.
const QTransform & transform() const
Alias for worldTransform().
CompositionMode
Defines the modes supported for digital image compositing.
@ CompositionMode_SourceOver
@ CompositionMode_DestinationIn
@ CompositionMode_SourceIn
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
QPixmapBlurFilterPrivate()
QGraphicsBlurEffect::BlurHints hints
The QPixmapBlurFilter class provides blur filtering for pixmaps.
void setBlurHints(QGraphicsBlurEffect::BlurHints hints)
Setting the blur hints to PerformanceHint causes the implementation to trade off visual quality to bl...
QPixmapBlurFilter(QObject *parent=nullptr)
Constructs a pixmap blur filter.
void setRadius(qreal radius)
Sets the radius of the blur filter.
QGraphicsBlurEffect::BlurHints blurHints() const
Gets the blur hints of the blur filter.
QRectF boundingRectFor(const QRectF &rect) const override
qreal radius() const
Gets the radius of the blur filter.
~QPixmapBlurFilter()
Destructor of pixmap blur filter.
void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect=QRectF()) const override
The QPixmapColorizeFilter class provides colorizing filtering for pixmaps.
QColor color() const
Gets the color of the colorize filter.
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 *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect=QRectF()) const override
QPixmapColorizeFilter(QObject *parent=nullptr)
Constructs an pixmap colorize filter.
void setStrength(qreal strength)
Sets the strength of the colorize filter to strength.
void setColor(const QColor &color)
Sets the color of the colorize filter to the color specified.
QPixmapConvolutionFilterPrivate()
~QPixmapConvolutionFilterPrivate()
qreal * convolutionKernel
The QPixmapConvolutionFilter class provides convolution filtering for pixmaps.
void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect=QRectF()) const override
QPixmapConvolutionFilter(QObject *parent=nullptr)
Constructs a pixmap convolution filter.
void setConvolutionKernel(const qreal *matrix, int rows, int columns)
Sets convolution kernel with the given number of rows and columns.
~QPixmapConvolutionFilter()
Destructor of pixmap convolution filter.
QRectF boundingRectFor(const QRectF &rect) const override
QPixmapDropShadowFilterPrivate()
The QPixmapDropShadowFilter class is a convenience class for drawing pixmaps with drop shadows.
void setOffset(const QPointF &offset)
Sets the shadow offset in pixels to the offset specified.
qreal blurRadius() const
Returns the radius in pixels of the blur on the drop shadow.
QPixmapDropShadowFilter(QObject *parent=nullptr)
Constructs drop shadow filter.
QColor color() const
Returns the color of the drop shadow.
QRectF boundingRectFor(const QRectF &rect) const override
void draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src=QRectF()) const override
void setColor(const QColor &color)
Sets the color of the drop shadow to the color specified.
QPointF offset() const
Returns the shadow offset in pixels.
~QPixmapDropShadowFilter()
Destroys drop shadow filter.
void setBlurRadius(qreal radius)
Sets the radius in pixels of the blur on the drop shadow to the radius specified.
QPixmapFilter::FilterType type
The QPixmapFilter class provides the basic functionality for pixmap filter classes....
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 ...
virtual ~QPixmapFilter()=0
Destroys the pixmap filter.
FilterType type() const
Returns the type of the filter.
QPixmapFilter(QPixmapFilterPrivate &d, FilterType type, QObject *parent)
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
QSize size() const
Returns the size of the pixmap.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
qreal devicePixelRatio() const
Returns the device pixel ratio for the pixmap.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
The QRasterPaintEngine class enables hardware acceleration of painting operations in Qt for Embedded ...
ClipType clipType() const
QRectF clipBoundingRect() const
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr void moveTo(qreal x, qreal y) noexcept
Moves the rectangle, leaving the top-left corner at the given position (x, y).
QRect toAlignedRect() const noexcept
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
bool contains(const QRectF &r) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
constexpr QRect toRect() const noexcept
Returns a QRect based on the values of this rectangle.
\inmodule QtCore\reentrant
QRect intersected(const QRect &other) const noexcept
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr void moveTo(int x, int t) noexcept
Moves the rectangle, leaving the top-left corner at the given position (x, y).
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
constexpr QSize toSize() const noexcept
Returns an integer based copy of this size.
Combined button and popup list for selecting options.
static QT_WARNING_DISABLE_FLOAT_COMPARE ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyIsNull(qfloat16 f) noexcept
int qRound(qfloat16 d) noexcept
constexpr const T & qBound(const T &min, const T &val, const T &max)
GLboolean GLboolean GLboolean b
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
const void GLsizei GLsizei stride
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum const void * pixels
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
GLuint GLenum GLenum transform
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
GLfloat GLfloat GLfloat alpha
GLenum GLenum GLenum GLenum GLenum scale
Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
void qt_blurrow(QImage &im, int line, int alpha)
Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
void qt_blurinner_alphaOnly(uchar *bptr, int &z, int alpha)
static void grayscale(const QImage &image, QImage &dest, const QRect &rect=QRect())
void expblur(QImage &img, qreal radius, bool improvedQuality=false, int transposed=0)
Q_WIDGETS_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed=0)
static void convolute(QImage *destImage, const QPointF &pos, const QImage &srcImage, const QRectF &srcRect, QPainter::CompositionMode mode, qreal *kernel, int kernelWidth, int kernelHeight)
int qt_static_shift(int value)
Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source)
void qt_blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, int alpha)
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
constexpr int qGray(int r, int g, int b)
constexpr QRgb qRgba(int r, int g, int b, int a)
constexpr int qAlpha(QRgb rgb)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
QT_BEGIN_NAMESPACE typedef uchar * output
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent