26template<
int aprec,
int zprec>
31#define Z_MASK (0xff << zprec)
35 const int B_zprec = qt_static_shift<zprec>(*pixel) &
Z_MASK;
38 const int zR_zprec = zR >> aprec;
39 const int zG_zprec = zG >> aprec;
40 const int zB_zprec = zB >> aprec;
41 const int zA_zprec = zA >> aprec;
43 zR +=
alpha * (R_zprec - zR_zprec);
44 zG +=
alpha * (G_zprec - zG_zprec);
45 zB +=
alpha * (B_zprec - zB_zprec);
46 zA +=
alpha * (A_zprec - zA_zprec);
48#define ZA_MASK (0xff << (zprec + aprec))
51 | qt_static_shift<16 - zprec - aprec>(zR &
ZA_MASK)
53 | qt_static_shift<-zprec - aprec>(zB &
ZA_MASK);
59template<
int aprec,
int zprec>
62 const int A_zprec = int(*(bptr)) << zprec;
63 const int z_zprec =
z >> aprec;
64 z +=
alpha * (A_zprec - z_zprec);
65 *(bptr) =
z >> (zprec + aprec);
68template<
int aprec,
int zprec,
bool alphaOnly>
73 int zR = 0, zG = 0, zB = 0, zA = 0;
79 const int im_width = im.
width();
82 qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA,
alpha);
84 qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA,
alpha);
93 qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA,
alpha);
95 qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA,
alpha);
116template <
int aprec,
int zprec,
bool alphaOnly>
121 radius *=
qreal(0.5);
131 const qreal cutOffIntensity = 2;
134 :
qRound((1<<aprec)*(1 -
qPow(cutOffIntensity * (1 /
qreal(255)), 1 / radius)));
136 int img_height =
img.height();
137 for (
int row = 0;
row < img_height; ++
row) {
138 for (
int i = 0;
i <= int(improvedQuality); ++
i)
139 qt_blurrow<aprec, zprec, alphaOnly>(
img,
row,
alpha);
144 if (transposed >= 0) {
145 if (
img.depth() == 8) {
146 qt_memrotate270(
reinterpret_cast<const quint8*
>(
img.bits()),
147 img.width(),
img.height(),
img.bytesPerLine(),
151 qt_memrotate270(
reinterpret_cast<const quint32*
>(
img.bits()),
152 img.width(),
img.height(),
img.bytesPerLine(),
157 if (
img.depth() == 8) {
158 qt_memrotate90(
reinterpret_cast<const quint8*
>(
img.bits()),
159 img.width(),
img.height(),
img.bytesPerLine(),
163 qt_memrotate90(
reinterpret_cast<const quint32*
>(
img.bits()),
164 img.width(),
img.height(),
img.bytesPerLine(),
170 img_height = temp.
height();
171 for (
int row = 0;
row < img_height; ++
row) {
172 for (
int i = 0;
i <= int(improvedQuality); ++
i)
173 qt_blurrow<aprec, zprec, alphaOnly>(temp,
row,
alpha);
176 if (transposed == 0) {
177 if (
img.depth() == 8) {
178 qt_memrotate90(
reinterpret_cast<const quint8*
>(temp.
bits()),
183 qt_memrotate90(
reinterpret_cast<const quint32*
>(temp.
bits()),
195#define AVG(a,b) ( ((((a)^(b)) & 0xfefefefeUL) >> 1) + ((a)&(b)) )
196#define AVG16(a,b) ( ((((a)^(b)) & 0xf7deUL) >> 1) + ((a)&(b)) )
216 int ww = dest.
width();
219 for (
int y = hh;
y; --
y,
dst += dx,
src += sx2) {
223 for (
int x = ww;
x; --
x, ++
q,
p1 += 2,
p2 += 2)
224 *
q = ((
int(
p1[0]) + int(
p1[1]) + int(
p2[0]) + int(
p2[1])) + 2) >> 2;
238 int ww = dest.
width();
241 for (
int y = hh;
y; --
y,
dst += dx,
src += sx2) {
245 for (
int x = ww;
x; --
x,
q += 3,
p1 += 6,
p2 += 6) {
270 qsizetype sx = srcImage.bytesPerLine() >> 2;
275 int ww = dest.
width();
278 for (
int y = hh;
y; --
y,
dst += dx,
src += sx2) {
282 for (
int x = ww;
x; --
x,
q++,
p1 += 2,
p2 += 2)
301 if (radius >= 4 && blurImage.width() >= 2 && blurImage.height() >= 2) {
304 radius *=
qreal(0.5);
308 expblur<12, 10, true>(blurImage, radius, quality, transposed);
310 expblur<12, 10, false>(blurImage, radius, quality, transposed);
315 p->drawImage(
QRect(
QPoint(0, 0), blurImage.deviceIndependentSize().toSize()), blurImage);
322 expblur<12, 10, true>(blurImage, radius, quality, transposed);
324 expblur<12, 10, false>(blurImage, radius, quality, transposed);
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.
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
Format format() const
Returns the format of the image.
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the image.
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
The QPainter class performs low-level painting on widgets and other paint devices.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
Combined button and popup list for selecting options.
void expblur(QImage &img, qreal radius, bool improvedQuality=false, int transposed=0)
int qt_static_shift(int value)
void qt_blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, int alpha)
void qt_blurinner_alphaOnly(uchar *bptr, int &z, int alpha)
void qt_blurrow(QImage &im, int line, int alpha)
static QT_WARNING_DISABLE_FLOAT_COMPARE ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
Q_GUI_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed=0)
QImage qt_halfScaled(const QImage &source)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
const void GLsizei GLsizei stride
GLsizei GLsizei GLchar * source
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
QT_BEGIN_NAMESPACE typedef unsigned int QRgb