18#include <qpa/qplatformintegration.h>
19#include <private/qguiapplication_p.h>
23#include <qpa/qplatformpixmap.h>
24#include <private/qcolorspace_p.h>
25#include <private/qcolortransform_p.h>
26#include <private/qmemrotate_p.h>
27#include <private/qimagescale_p.h>
28#include <private/qpixellayout_p.h>
29#include <private/qsimd_p.h>
33#include <private/qpaintengine_raster_p.h>
35#include <private/qimage_p.h>
36#include <private/qfont_p.h>
41#include <private/qthreadpool_p.h>
44#include <qtgui_tracepoints_p.h>
58#if defined(Q_CC_DEC) && defined(__alpha) && (__DECCXX_VER-0 >= 50190001)
59#pragma message disable narrowptr
63#define QIMAGE_SANITYCHECK_MEMORY(image) \
64 if ((image).isNull()) { \
65 qWarning("QImage: out of memory, returning null image"); \
70 "#include <qimagereader.h>"
74"ENUM { } QImage::Format;" \
75"FLAGS { } Qt::ImageConversionFlags;"
88 return 1 + serial.fetchAndAddRelaxed(1);
125 auto d = std::make_unique<QImageData>();
130 d->colortable.resize(2);
142 d->has_alpha_clut =
false;
143 d->is_cached =
false;
145 d->bytes_per_line =
params.bytesPerLine;
147 d->data = (
uchar *)malloc(
d->nbytes);
168#if defined(_M_ARM) && defined(_MSC_VER)
169#pragma optimize("", off)
174 bool has_alpha_pixels =
false;
184 has_alpha_pixels =
true;
189 for (
int y=0;
y<
height && !has_alpha_pixels; ++
y) {
190 uint alphaAnd = 0xff000000;
192 alphaAnd &=
reinterpret_cast<const uint*
>(
bits)[
x];
193 has_alpha_pixels = (alphaAnd != 0xff000000);
201 for (
int y=0;
y<
height && !has_alpha_pixels; ++
y) {
202 uchar alphaAnd = 0xff;
204 alphaAnd &=
bits[
x * 4+ 3];
205 has_alpha_pixels = (alphaAnd != 0xff);
213 for (
int y=0;
y<
height && !has_alpha_pixels; ++
y) {
214 uint alphaAnd = 0xc0000000;
216 alphaAnd &=
reinterpret_cast<const uint*
>(
bits)[
x];
217 has_alpha_pixels = (alphaAnd != 0xc0000000);
227 for (
int y=0;
y<
height && !has_alpha_pixels; ++
y) {
228 uchar alphaAnd = 0xff;
229 while (
bits < end_bits) {
233 has_alpha_pixels = (alphaAnd != 0xff);
243 for (
int y=0;
y<
height && !has_alpha_pixels; ++
y) {
244 uchar alphaAnd = 0xfc;
245 while (
bits < end_bits) {
249 has_alpha_pixels = (alphaAnd != 0xfc);
257 for (
int y=0;
y<
height && !has_alpha_pixels; ++
y) {
260 alphaAnd &=
reinterpret_cast<const ushort*
>(
bits)[
x];
261 has_alpha_pixels = (alphaAnd != 0xf000);
268 for (
int y=0;
y<
height && !has_alpha_pixels; ++
y) {
278 for (
int y = 0;
y <
height && !has_alpha_pixels; ++
y) {
287 for (
int y = 0;
y <
height && !has_alpha_pixels; ++
y) {
289 has_alpha_pixels |= ((
float *)
bits)[
x * 4 + 3] < 1.0f;
317 return has_alpha_pixels;
319#if defined(_M_ARM) && defined(_MSC_VER)
320#pragma optimize("", on)
842 if (bpl < min_bytes_per_line)
846 params.bytesPerLine = bpl;
847 if (qMulOverflow<qsizetype>(bpl,
height, &
params.totalSize))
855 d->ro_data = readOnly;
862 d->bytes_per_line =
params.bytesPerLine;
1007#ifndef QT_NO_IMAGEFORMAT_XPM
1034 qWarning(
"QImage::QImage(), XPM is not supported");
1050 if (
image.paintingActive()) {
1052 image.copy().swap(*
this);
1066 if (
d && !
d->ref.deref())
1082 if (
image.paintingActive()) {
1087 if (
d && !
d->ref.deref())
1131 if (
d->is_cached &&
d->ref.loadRelaxed() == 1)
1134 if (
d->ref.loadRelaxed() != 1 ||
d->ro_data)
1154 if (
d->is_cached &&
d->ref.loadRelaxed() == 1)
1157 if (
d->ref.loadRelaxed() != 1)
1160 if (
d && invalidateCache)
1169 dst->devicePixelRatio =
src->devicePixelRatio;
1177 dst->offset =
src->offset;
1178 dst->colorSpace =
src->colorSpace;
1183 dst->setDotsPerMeterX(
src.dotsPerMeterX());
1184 dst->setDotsPerMeterY(
src.dotsPerMeterY());
1185 dst->setDevicePixelRatio(
src.devicePixelRatio());
1186 const auto textKeys =
src.textKeys();
1187 for (
const auto &
key: textKeys)
1235 if (
image.d->nbytes !=
d->nbytes) {
1241 image.d->colortable =
d->colortable;
1242 image.d->has_alpha_clut =
d->has_alpha_clut;
1254 if (
w <= 0 ||
h <= 0)
1261 if (
x < 0 || y < 0 || x + w >
d->width ||
y +
h >
d->height) {
1274 image.d->colortable =
d->colortable;
1276 int pixels_to_copy =
qMax(
w - dx, 0);
1279 else if (pixels_to_copy >
d->width -
x)
1280 pixels_to_copy =
d->width -
x;
1281 int lines_to_copy =
qMax(
h - dy, 0);
1284 else if (lines_to_copy >
d->height -
y)
1285 lines_to_copy =
d->height -
y;
1287 bool byteAligned =
true;
1289 byteAligned = !(dx & 7) && !(
x & 7) && !(pixels_to_copy & 7);
1292 const uchar *
src =
d->data + ((
x *
d->depth) >> 3) +
y *
d->bytes_per_line;
1293 uchar *dest =
image.d->data + ((dx *
d->depth) >> 3) + dy *
image.d->bytes_per_line;
1295 for (
int i = 0;
i < lines_to_copy; ++
i) {
1296 memcpy(dest,
src, bytes_to_copy);
1297 src +=
d->bytes_per_line;
1298 dest +=
image.d->bytes_per_line;
1301 const uchar *
src =
d->data +
y *
d->bytes_per_line;
1303 for (
int i = 0;
i < lines_to_copy; ++
i) {
1304 for (
int j = 0;
j < pixels_to_copy; ++
j) {
1305 if (
src[(
x +
j) >> 3] & (0x80 >> ((
x +
j) & 7)))
1306 dest[(dx +
j) >> 3] |= (0x80 >> ((dx +
j) & 7));
1308 dest[(dx +
j) >> 3] &= ~(0x80 >> ((dx +
j) & 7));
1310 src +=
d->bytes_per_line;
1311 dest +=
image.d->bytes_per_line;
1315 const uchar *
src =
d->data +
y *
d->bytes_per_line;
1317 for (
int i = 0;
i < lines_to_copy; ++
i) {
1318 for (
int j = 0;
j < pixels_to_copy; ++
j) {
1319 if (
src[(
x +
j) >> 3] & (0x1 << ((
x +
j) & 7)))
1320 dest[(dx +
j) >> 3] |= (0x1 << ((dx +
j) & 7));
1322 dest[(dx +
j) >> 3] &= ~(0x1 << ((dx +
j) & 7));
1324 src +=
d->bytes_per_line;
1325 dest +=
image.d->bytes_per_line;
1330 image.d->has_alpha_clut =
d->has_alpha_clut;
1356 return d ?
d->width : 0;
1368 return d ?
d->height : 0;
1410 return d ?
d->depth : 0;
1426 return d ?
d->colortable.
size() : 0;
1451 d->has_alpha_clut =
false;
1452 for (
int i = 0;
i <
d->colortable.size(); ++
i) {
1453 if (
qAlpha(
d->colortable.at(
i)) != 255) {
1454 d->has_alpha_clut =
true;
1468 return d ?
d->colortable : QList<QRgb>();
1486 return d->devicePixelRatio;
1515 if (scaleFactor ==
d->devicePixelRatio)
1520 d->devicePixelRatio = scaleFactor;
1537 return QSizeF(
d->width,
d->height) /
d->devicePixelRatio;
1550 return d ?
d->nbytes : 0;
1562 return d ?
d->bytes_per_line : 0;
1599 if (i < 0 || d->
depth > 8 ||
i >= 1<<
d->depth) {
1600 qWarning(
"QImage::setColor: Index out of bound %d",
i);
1609 if (
i >=
d->colortable.size())
1611 d->colortable[
i] =
c;
1612 d->has_alpha_clut |= (
qAlpha(
c) != 255);
1648 return d->data +
i *
d->bytes_per_line;
1660 return d->data +
i *
d->bytes_per_line;
1684 return d->data +
i *
d->bytes_per_line;
1720 return d ?
d->data :
nullptr;
1735 return d ?
d->data :
nullptr;
1769 if (
d->depth == 1 ||
d->depth == 8) {
1771 if (
d->depth == 1) {
1780 qt_rectfill<quint8>(
d->data,
pixel, 0, 0,
1781 w,
d->height,
d->bytes_per_line);
1783 }
else if (
d->depth == 16) {
1786 qt_rectfill<quint16>(
reinterpret_cast<quint16*
>(
d->data),
pixel,
1787 0, 0,
d->width,
d->height,
d->bytes_per_line);
1789 }
else if (
d->depth == 24) {
1792 qt_rectfill<quint24>(
reinterpret_cast<quint24*
>(
d->data),
pixel,
1793 0, 0,
d->width,
d->height,
d->bytes_per_line);
1797 0, 0,
d->width,
d->height,
d->bytes_per_line);
1802 ::memcpy(&cu, &cf,
sizeof(
quint64));
1803 qt_rectfill<quint64>(
reinterpret_cast<quint64*
>(
d->data), cu,
1804 0, 0,
d->width,
d->height,
d->bytes_per_line);
1809 for (
int y = 0;
y <
d->height; ++
y) {
1811 for (
int x = 0;
x <
d->width; ++
x)
1813 data +=
d->bytes_per_line;
1820 pixel |= 0xff000000;
1822#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
1823 pixel |= 0xff000000;
1825 pixel |= 0x000000ff;
1828 pixel |= 0xc0000000;
1830 qt_rectfill<uint>(
reinterpret_cast<uint*
>(
d->data),
pixel,
1831 0, 0,
d->width,
d->height,
d->bytes_per_line);
1877 switch (
d->format) {
1895 fill(qConvertRgb64ToRgb30<PixelOrderBGR>(opaque));
1898 fill(qConvertRgb64ToRgb30<PixelOrderRGB>(opaque));
1905 for (
int i=0;
i<
d->colortable.size(); ++
i) {
1906 if (
color.rgba() ==
d->colortable.at(
i)) {
1922 qt_rectfill<quint64>(
reinterpret_cast<quint64*
>(
d->data), opaque,
1923 0, 0,
d->width,
d->height,
d->bytes_per_line);
1926 qt_rectfill<quint64>(
reinterpret_cast<quint64*
>(
d->data),
color.rgba64(),
1927 0, 0,
d->width,
d->height,
d->bytes_per_line);
1930 qt_rectfill<quint64>(
reinterpret_cast<quint64 *
>(
d->data),
color.rgba64().premultiplied(),
1931 0, 0,
d->width,
d->height,
d->bytes_per_line);
1943 if (
depth() == 64) {
1946 c16 = c16.premultiplied();
1947 qt_rectfill<QRgbaFloat16>(
reinterpret_cast<QRgbaFloat16 *
>(
d->data), c16,
1948 0, 0,
d->width,
d->height,
d->bytes_per_line);
1953 qt_rectfill<QRgbaFloat32>(
reinterpret_cast<QRgbaFloat32 *
>(
d->data), c32,
1954 0, 0,
d->width,
d->height,
d->bytes_per_line);
2007 }
else if (
depth() > 32) {
2019 int pad =
d->bytes_per_line - bpl;
2021 for (
int y=0;
y<
d->height; ++
y) {
2039 for (
int y = 0;
y <
d->height; ++
y) {
2040 float *
p =
reinterpret_cast<float *
>(
data);
2041 for (
int x = 0;
x <
d->width; ++
x) {
2049 data +=
d->bytes_per_line;
2051 }
else if (
depth() == 64) {
2068 switch (
d->format) {
2074#if Q_BYTE_ORDER == Q_BIG_ENDIAN
2075 xorbits = 0xffffff00;
2078 xorbits = 0x00ffffff;
2086 xorbits = 0x00ffffff;
2090 xorbits = 0x3fffffff;
2101 if (originalFormat !=
d->format) {
2102 if (!
d->convertInPlace(originalFormat, { }))
2135 qWarning(
"QImage::setColorCount: null image");
2148 d->colortable.clear();
2151 int nc =
d->colortable.size();
2154 d->colortable[
i] = 0;
2208#if QT_CONFIG(raster_fp)
2210 converter = convert_generic_over_rgba32f;
2257 return abs(
r1 -
r2) + abs(g1 - g2) + abs(b1 - b2) + abs(
a1 -
a2);
2262 int current_distance = INT_MAX;
2263 for (
int i=0;
i<clut.size(); ++
i) {
2265 if (
dist < current_distance) {
2266 current_distance =
dist;
2274 const QList<QRgb> &clut) {
2280 int h =
src.height();
2281 int w =
src.width();
2283 QHash<QRgb, int>
cache;
2286 for (
int y=0;
y<
h; ++
y) {
2287 const QRgb *src_pixels = (
const QRgb *)
src.scanLine(
y);
2289 for (
int x=0;
x<
w; ++
x) {
2290 int src_pixel = src_pixels[
x];
2300 QList<QRgb>
table = clut;
2302 for (
int y=0;
y<
h; ++
y) {
2303 const QRgb *src_pixels = (
const QRgb *)
src.scanLine(
y);
2304 for (
int x=0;
x<
w; ++
x) {
2305 int src_pixel = src_pixels[
x];
2432 &&
x >= 0 &&
x <
d->width
2433 &&
y >= 0 &&
y <
d->height;
2454 if (!
d || x < 0 || x >=
d->width || y < 0 || y >=
height()) {
2455 qWarning(
"QImage::pixelIndex: coordinate (%d,%d) out of range",
x,
y);
2461 return (*(
s + (
x >> 3)) >> (7- (
x & 7))) & 1;
2463 return (*(
s + (
x >> 3)) >> (
x & 7)) & 1;
2467 qWarning(
"QImage::pixelIndex: Not applicable for %d-bpp images (no palette)",
d->depth);
2495 if (!
d || x < 0 || x >=
d->width || y < 0 || y >=
d->height) {
2496 qWarning(
"QImage::pixel: coordinate (%d,%d) out of range",
x,
y);
2500 const uchar *
s =
d->data +
y *
d->bytes_per_line;
2503 switch (
d->format) {
2505 index = (*(
s + (
x >> 3)) >> (
~x & 7)) & 1;
2508 index = (*(
s + (
x >> 3)) >> (
x & 7)) & 1;
2517 if (
index >=
d->colortable.size()) {
2518 qWarning(
"QImage::pixel: color table index %d out of range.",
index);
2521 return d->colortable.at(
index);
2524 switch (
d->format) {
2526 return 0xff000000 |
reinterpret_cast<const QRgb *
>(
s)[
x];
2529 return reinterpret_cast<const QRgb *
>(
s)[
x];
2559 return *
layout->fetchToARGB32PM(&
result,
s,
x, 1,
nullptr,
nullptr);
2590 if (!
d || x < 0 || x >=
width() || y < 0 || y >=
height()) {
2591 qWarning(
"QImage::setPixel: coordinate (%d,%d) out of range",
x,
y);
2599 if (index_or_rgb > 1) {
2600 qWarning(
"QImage::setPixel: Index %d out of range", index_or_rgb);
2602 if (index_or_rgb==0)
2603 *(
s + (
x >> 3)) &= ~(1 << (
x & 7));
2605 *(
s + (
x >> 3)) |= (1 << (
x & 7));
2607 if (index_or_rgb==0)
2608 *(
s + (
x >> 3)) &= ~(1 << (7-(
x & 7)));
2610 *(
s + (
x >> 3)) |= (1 << (7-(
x & 7)));
2614 if (index_or_rgb >= (
uint)
d->colortable.size()) {
2615 qWarning(
"QImage::setPixel: Index %d out of range", index_or_rgb);
2618 s[
x] = index_or_rgb;
2623 ((
uint *)
s)[
x] = 0xff000000 | index_or_rgb;
2627 ((
uint *)
s)[
x] = index_or_rgb;
2682 layout->storeFromRGB32(
s, &index_or_rgb,
x, 1,
nullptr,
nullptr);
2684 layout->storeFromARGB32PM(
s, &index_or_rgb,
x, 1,
nullptr,
nullptr);
2711 if (!
d || x < 0 || x >=
d->width || y < 0 || y >=
height()) {
2712 qWarning(
"QImage::pixelColor: coordinate (%d,%d) out of range",
x,
y);
2718 switch (
d->format) {
2762 c =
c.unpremultiplied();
2790 if (!
d || x < 0 || x >=
width() || y < 0 || y >=
height()) {
2791 qWarning(
"QImage::setPixelColor: coordinate (%d,%d) out of range",
x,
y);
2795 if (!
color.isValid()) {
2796 qWarning(
"QImage::setPixelColor: color is invalid");
2805 c =
c.premultiplied();
2808 switch (
d->format) {
2812 qWarning(
"QImage::setPixelColor: called on monochrome or indexed format");
2840 c16f = c16f.premultiplied();
2877 switch (
d->format) {
2881 for (
int i = 0;
i <
d->colortable.size(); ++
i) {
2894#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
2899 for (
int j = 0;
j <
d->height; ++
j) {
2901 for (
int i = 0;
i <
d->width; ++
i) {
2908 for (
int j = 0;
j <
d->height; ++
j) {
2910 for (
int i = 0;
i <
d->width; ++
i) {
2922 const auto fetch =
layout->fetchToARGB32PM;
2923 for (
int j = 0;
j <
d->height; ++
j) {
2926 while (x < d->
width) {
2929 for (
int i = 0;
i < l; ++
i) {
3016 qWarning(
"QImage::scaled: Image is a null image");
3023 newSize.
scale(
s, aspectMode);
3026 if (newSize ==
size())
3053 qWarning(
"QImage::scaleWidth: Image is a null image");
3083 qWarning(
"QImage::scaleHeight: Image is a null image");
3118 if (
d->depth == 1) {
3125 if (!
mask.isNull()) {
3132#ifndef QT_NO_IMAGE_HEURISTIC_MASK
3162 if (
d->depth != 32) {
3164 return img32.createHeuristicMask(clipTight);
3167#define PIX(x,y) (*((const QRgb*)scanLine(y)+x) & 0x00ffffff)
3179 if (background !=
PIX(
w-1,0) &&
3180 background !=
PIX(0,
h-1) &&
3181 background !=
PIX(
w-1,
h-1)) {
3182 background =
PIX(
w-1,0);
3183 if (background !=
PIX(
w-1,
h-1) &&
3184 background !=
PIX(0,
h-1) &&
3186 background =
PIX(
w-1,
h-1);
3192 uchar *ypp, *ypc, *ypn;
3195 ypn =
m.scanLine(0);
3197 for (
y = 0;
y <
h;
y++) {
3202 for (
x = 0;
x <
w;
x++) {
3205 if ((
x == 0 ||
y == 0 ||
x ==
w-1 ||
y ==
h-1 ||
3206 !(*(ypc + ((
x-1) >> 3)) & (1 << ((
x-1) & 7))) ||
3207 !(*(ypc + ((
x+1) >> 3)) & (1 << ((
x+1) & 7))) ||
3208 !(*(ypp + (
x >> 3)) & (1 << (
x & 7))) ||
3209 !(*(ypn + (
x >> 3)) & (1 << (
x & 7)))) &&
3210 ( (*(ypc + (
x >> 3)) & (1 << (
x & 7)))) &&
3211 ((*
p & 0x00ffffff) == background)) {
3213 *(ypc + (
x >> 3)) &= ~(1 << (
x & 7));
3221 ypn =
m.scanLine(0);
3223 for (
y = 0;
y <
h;
y++) {
3228 for (
x = 0;
x <
w;
x++) {
3229 if ((*
p & 0x00ffffff) != background) {
3231 *(ypc + ((
x-1) >> 3)) |= (1 << ((
x-1) & 7));
3233 *(ypc + ((
x+1) >> 3)) |= (1 << ((
x+1) & 7));
3235 *(ypp + (
x >> 3)) |= (1 << (
x & 7));
3237 *(ypn + (
x >> 3)) |= (1 << (
x & 7));
3268 uchar *
s = maskImage.bits();
3272 if (
depth() == 32) {
3273 for (
int h = 0;
h <
d->height;
h++) {
3275 for (
int w = 0;
w <
d->width;
w++) {
3277 *(
s + (
w >> 3)) |= (1 << (
w & 7));
3279 s += maskImage.bytesPerLine();
3282 for (
int h = 0;
h <
d->height;
h++) {
3283 for (
int w = 0;
w <
d->width;
w++) {
3285 *(
s + (
w >> 3)) |= (1 << (
w & 7));
3287 s += maskImage.bytesPerLine();
3291 maskImage.invertPixels();
3322 int dstXIncr,
int dstYIncr,
3329 const int srcYEnd =
dstY0 ?
h / 2 :
h;
3331 T *srcPtr = (T *) (
src->data +
srcY *
src->bytes_per_line);
3332 T *dstPtr = (T *) (
dst->data +
dstY *
dst->bytes_per_line);
3334 std::swap(srcPtr[
srcX], dstPtr[
dstX]);
3339 int srcXEnd2 =
w / 2;
3340 T *srcPtr = (T *) (
src->data +
srcY *
src->bytes_per_line);
3342 std::swap(srcPtr[
srcX], srcPtr[
dstX]);
3346 T *srcPtr = (T *) (
src->data +
srcY *
src->bytes_per_line);
3347 T *dstPtr = (T *) (
dst->data +
dstY *
dst->bytes_per_line);
3356 const int data_bytes_per_line =
w * (
depth / 8);
3358 uint *srcPtr =
reinterpret_cast<uint *
>(
src->data);
3359 uint *dstPtr =
reinterpret_cast<uint *
>(
dst->data + (
h - 1) *
dst->bytes_per_line);
3361 const int uint_per_line = (data_bytes_per_line + 3) >> 2;
3362 for (
int y = 0;
y <
h; ++
y) {
3364 for (
int x = 0;
x < uint_per_line;
x++) {
3365 const uint d = dstPtr[
x];
3366 const uint s = srcPtr[
x];
3370 srcPtr +=
src->bytes_per_line >> 2;
3371 dstPtr -=
dst->bytes_per_line >> 2;
3376 uchar *dstPtr =
dst->data + (
h - 1) *
dst->bytes_per_line;
3377 for (
int y = 0;
y <
h; ++
y) {
3378 memcpy(dstPtr, srcPtr, data_bytes_per_line);
3379 srcPtr +=
src->bytes_per_line;
3380 dstPtr -=
dst->bytes_per_line;
3389 int h =
src->height;
3392 if (
src->depth == 1) {
3397 if (vertical && !horizontal) {
3403 int dstX0 = 0, dstXIncr = 1;
3404 int dstY0 = 0, dstYIncr = 1;
3442 if (horizontal &&
dst->depth == 1) {
3444 const int shift = 8 - (
dst->width % 8);
3446 for (
int y = 0;
y <
h; ++
y) {
3457 p[-1] |= (*
p & (128 >>
i)) >> (7 -
i);
3462 p[-1] |= (*
p & (1 <<
i)) << (7 -
i);
3485 if ((
d->width <= 1 &&
d->height <= 1) || (!horizontal && !vertical))
3496 result.d->colortable =
d->colortable;
3497 result.d->has_alpha_clut =
d->has_alpha_clut;
3510 if (!
d || (
d->width <= 1 &&
d->height <= 1) || (!horizontal && !vertical))
3549 qWarning(
"Trying to rb-swap an image format where it doesn't make sense");
3574 switch (
d->format) {
3587 for (
int i = 0;
i <
res.d->colortable.size();
i++) {
3589 res.d->colortable[
i] =
QRgb(((
c << 16) & 0xff0000) | ((
c >> 16) & 0xff) | (
c & 0xff00ff00));
3595#if Q_BYTE_ORDER == Q_BIG_ENDIAN
3598 for (
int i = 0;
i <
d->height;
i++) {
3604 *
q = ((
c << 16) & 0xff000000) | ((
c >> 16) & 0xff00) | (
c & 0x00ff00ff);
3619 for (
int i = 0;
i <
d->height;
i++) {
3625 *
q = ((
c << 16) & 0xff0000) | ((
c >> 16) & 0xff) | (
c & 0xff00ff00);
3634 for (
int i = 0;
i <
d->height;
i++) {
3640 *
q = ((
c << 11) & 0xf800) | ((
c >> 11) & 0x1f) | (
c & 0x07e0);
3670 switch (
d->format) {
3682 for (
int i = 0;
i <
d->colortable.size();
i++) {
3684 d->colortable[
i] =
QRgb(((
c << 16) & 0xff0000) | ((
c >> 16) & 0xff) | (
c & 0xff00ff00));
3690#if Q_BYTE_ORDER == Q_BIG_ENDIAN
3691 for (
int i = 0;
i <
d->height;
i++) {
3696 *
p = ((
c << 16) & 0xff000000) | ((
c >> 16) & 0xff00) | (
c & 0x00ff00ff);
3708 for (
int i = 0;
i <
d->height;
i++) {
3713 *
p = ((
c << 16) & 0xff0000) | ((
c >> 16) & 0xff) | (
c & 0xff00ff00);
3719 for (
int i = 0;
i <
d->height;
i++) {
3724 *
p = ((
c << 11) & 0xf800) | ((
c >> 11) & 0x1f) | (
c & 0x07e0);
3733 for (
int i = 0;
i <
d->height;
i++) {
3893 return d->doImageIO(
this, &writer, quality);
3912 return d->doImageIO(
this, &writer, quality);
3920 if (quality > 100 || quality < -1)
3921 qWarning(
"QImage::save: Quality out of range [-1, 100]");
3923 writer->setQuality(
qMin(quality,100));
3927 qWarning(
"QImage::save: failed to write image - %s",
qPrintable(writer->errorString()));
3935#if !defined(QT_NO_DATASTREAM)
3949 if (
s.version() >= 5) {
3950 if (
image.isNull()) {
3958 QImageWriter writer(
s.device(),
s.version() == 1 ?
"bmp" :
"png");
3975 if (
s.version() >= 5) {
3984 if (
image.isNull() &&
s.version() >= 5)
3985 s.setStatus(QDataStream::ReadPastEnd);
4014 if (
i.d->height !=
d->height ||
i.d->width !=
d->width ||
i.d->format !=
d->format ||
i.d->colorSpace !=
d->colorSpace)
4019 const int n =
d->width *
d->depth / 8;
4020 if (
n ==
d->bytes_per_line &&
n ==
i.d->bytes_per_line) {
4021 if (memcmp(
bits(),
i.bits(),
d->nbytes))
4024 for (
int y = 0;
y <
d->height; ++
y) {
4032 const QList<QRgb> &colortable =
d->colortable;
4033 const QList<QRgb> &icolortable =
i.d->colortable;
4034 for (
int y=0;
y<
h; ++
y) {
4035 for (
int x=0;
x<
w; ++
x) {
4043 for(
int l = 0; l <
d->height; l++) {
4046 const uint *
p2 =
reinterpret_cast<const uint*
>(
i.scanLine(l));
4048 if ((*
p1++ & 0x00ffffff) != (*
p2++ & 0x00ffffff))
4072 return !(*
this ==
i);
4118 if (!
d || !
x ||
d->dpmx ==
x)
4140 if (!
d || !
y ||
d->dpmy ==
y)
4172 if (!
d ||
d->offset ==
p)
4206 return d->text.value(
key);
4210 tmp +=
it.key() +
": "_L1 +
it.value().simplified() +
"\n\n"_L1;
4260 if (!
d->paintEngine) {
4263 if (platformIntegration)
4265 if (!
d->paintEngine)
4269 return d->paintEngine;
4291 return qRound(
d->width * 1000 /
d->dpmx);
4294 return qRound(
d->height * 1000 /
d->dpmy);
4297 return d->colortable.size();
4303 return qRound(
d->dpmx * 0.0254);
4307 return qRound(
d->dpmy * 0.0254);
4311 return qRound(
d->dpmx * 0.0254);
4315 return qRound(
d->dpmy * 0.0254);
4319 return d->devicePixelRatio;
4359#define IWX_MSB(b) if (trigx < maxws && trigy < maxhs) { \
4360 if (*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \
4361 (1 << (7-((trigx>>12)&7)))) \
4368#define IWX_LSB(b) if (trigx < maxws && trigy < maxhs) { \
4369 if (*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \
4370 (1 << ((trigx>>12)&7))) \
4377#define IWX_PIX(b) if (trigx < maxws && trigy < maxhs) { \
4378 if ((*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \
4379 (1 << (7-((trigx>>12)&7)))) == 0) \
4389 int m11 = int(trueMat.m11()*4096.0);
4390 int m12 = int(trueMat.m12()*4096.0);
4391 int m21 = int(trueMat.m21()*4096.0);
4392 int m22 = int(trueMat.m22()*4096.0);
4393 int dx =
qRound(trueMat.dx()*4096.0);
4394 int dy =
qRound(trueMat.dy()*4096.0);
4396 int m21ydx = dx + (
xoffset<<16) + (m11 + m21) / 2;
4397 int m22ydy = dy + (m12 + m22) / 2;
4400 uint maxws = sWidth<<12;
4401 uint maxhs = sHeight<<12;
4403 for (
int y=0;
y<dHeight;
y++) {
4406 uchar *maxp = dptr + dbpl;
4410 while (dptr < maxp) {
4411 if (trigx < maxws && trigy < maxhs)
4412 *dptr = *(sptr+sbpl*(trigy>>12)+(trigx>>12));
4420 while (dptr < maxp) {
4421 if (trigx < maxws && trigy < maxhs)
4422 *((
ushort*)dptr) = *((
const ushort *)(sptr+sbpl*(trigy>>12) +
4432 while (dptr < maxp) {
4433 if (trigx < maxws && trigy < maxhs) {
4434 const uchar *
p2 = sptr+sbpl*(trigy>>12) + ((trigx>>12)*3);
4446 while (dptr < maxp) {
4447 if (trigx < maxws && trigy < maxhs)
4448 *((
uint*)dptr) = *((
const uint *)(sptr+sbpl*(trigy>>12) +
4463 while (dptr < maxp) {
4476 while (dptr < maxp) {
4525 return d &&
d->ref.loadRelaxed() == 1;
4550 if (!
d || alphaChannel.isNull())
4553 if (
d->paintEngine &&
d->paintEngine->isActive()) {
4554 qWarning(
"QImage::setAlphaChannel: "
4555 "Unable to set alpha channel while image is being painted on");
4560 if (
d->format == alphaFormat)
4569 if (alphaChannel.format() ==
QImage::Format_Alpha8 || (alphaChannel.d->depth == 8 && alphaChannel.isGrayscale()))
4570 sourceImage = alphaChannel;
4577 if (sourceImage.size() !=
size())
4597 return d->has_alpha_clut;
4616 switch (
d->format) {
4667 switch (
src.format()) {
4670#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
4674#if QT_CONFIG(raster_64bit)
4683#if QT_CONFIG(raster_fp)
4697 if (
src.hasAlphaChannel())
4714 if (
image.colorCount() > 0)
4715 out.setColorTable(
image.colorTable());
4720 memrotate(
image.constBits(),
w,
h,
image.bytesPerLine(),
out.bits(),
out.bytesPerLine());
4722 for (
int y=0;
y<
h; ++
y) {
4723 if (
image.colorCount())
4724 for (
int x=0;
x<
w; ++
x)
4727 for (
int x=0;
x<
w; ++
x)
4738 return image.mirrored(
true,
true);
4744 if (
image.colorCount() > 0)
4745 out.setColorTable(
image.colorTable());
4748 memrotate(
image.constBits(),
w,
h,
image.bytesPerLine(),
out.bits(),
out.bytesPerLine());
4758 if (
image.colorCount() > 0)
4759 out.setColorTable(
image.colorTable());
4764 memrotate(
image.constBits(),
w,
h,
image.bytesPerLine(),
out.bits(),
out.bytesPerLine());
4766 for (
int y=0;
y<
h; ++
y) {
4767 if (
image.colorCount())
4768 for (
int x=0;
x<
w; ++
x)
4771 for (
int x=0;
x<
w; ++
x)
4822 bool complex_xform =
false;
4823 bool scale_xform =
false;
4824 bool nonpaintable_scale_xform =
false;
4828 else if (mat.m11() == -1. && mat.m22() == -1.)
4836 if (hd * 2 < hs || wd * 2 < ws)
4837 nonpaintable_scale_xform =
true;
4840 if (mat.m12() == 1. && mat.m21() == -1.)
4842 else if (mat.m12() == -1. && mat.m21() == 1.)
4848 QRect r =
a.boundingRect().toAlignedRect();
4851 complex_xform =
true;
4854 if (wd == 0 || hd == 0)
4861#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
4865#if QT_CONFIG(raster_64bit)
4870 if (mat.m11() > 0.0F && mat.m22() > 0.0F)
4877 if (nonpaintable_scale_xform
4878#
if QT_CONFIG(thread) && !defined(Q_OS_WASM)
4879 || (ws * hs) >= (1<<20)
4883 if (mat.m11() < 0.0F && mat.m22() < 0.0F) {
4885 }
else if (mat.m11() < 0.0F) {
4887 }
else if (mat.m22() < 0.0F) {
4917 QImage dImage(wd, hd, target_format);
4923 dImage.d->colortable =
d->colortable;
4924 dImage.d->has_alpha_clut =
d->has_alpha_clut | complex_xform;
4929 if (dImage.d->colortable.size() < 256) {
4931 dImage.d->colortable.append(0x0);
4932 memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.d->nbytes);
4934 memset(dImage.bits(), 0, dImage.d->nbytes);
4937 memset(dImage.bits(), 0x00, dImage.d->nbytes);
4946 sImage.d->colortable =
d->colortable;
4947 sImage.d->has_alpha_clut =
d->has_alpha_clut;
4950 Q_ASSERT(sImage.devicePixelRatio() == 1);
4951 Q_ASSERT(sImage.devicePixelRatio() == dImage.devicePixelRatio());
4958 p.setTransform(mat);
4959 p.drawImage(
QPoint(0, 0), sImage);
4962 mat = mat.inverted(&invertible);
4969 qt_xForm_helper(mat, 0,
type, bpp, dImage.bits(), dbpl, 0, hd, sptr, sbpl, ws, hs);
5040 if (!
d || !
d->colorSpace.isValid())
5043 qWarning() <<
"QImage::convertToColorSpace: Output colorspace is not valid";
5053 if (
d->ref.loadRelaxed() != 1)
5073 if (!
d || !
d->colorSpace.isValid())
5076 qWarning() <<
"QImage::convertToColorSpace: Output colorspace is not valid";
5080 qWarning() <<
"QImage::convertToColorSpace: Color space is not compatible with format";
5106 if (!
d || !
d->colorSpace.isValid())
5109 qWarning() <<
"QImage::convertedToColorSpace: Output colorspace is not valid";
5133 if (!
d || !
d->colorSpace.isValid())
5136 qWarning() <<
"QImage::convertedToColorSpace: Output colorspace is not valid";
5140 qWarning() <<
"QImage::convertedToColorSpace: Color space is not compatible with format";
5159 return d->colorSpace;
5174 qWarning() <<
"QImage::applyColorTransform can not apply format switching transform without switching format";
5182 for (
int i = 0;
i <
d->colortable.size(); ++
i)
5191 }
else if (
depth() > 32) {
5227 std::function<
void(
int,
int)> transformSegment;
5230 transformSegment = [&](
int yStart,
int yEnd) {
5231 for (
int y = yStart;
y < yEnd; ++
y) {
5232 uint8_t *scanline =
reinterpret_cast<uint8_t *
>(
d->data +
y *
d->bytes_per_line);
5237 transformSegment = [&](
int yStart,
int yEnd) {
5238 for (
int y = yStart;
y < yEnd; ++
y) {
5239 uint16_t *scanline =
reinterpret_cast<uint16_t *
>(
d->data +
y *
d->bytes_per_line);
5244 transformSegment = [&](
int yStart,
int yEnd) {
5245 for (
int y = yStart;
y < yEnd; ++
y) {
5250 }
else if (
depth() > 32) {
5251 transformSegment = [&](
int yStart,
int yEnd) {
5252 for (
int y = yStart;
y < yEnd; ++
y) {
5253 QRgba64 *scanline =
reinterpret_cast<QRgba64 *
>(
d->data +
y *
d->bytes_per_line);
5258 transformSegment = [&](
int yStart,
int yEnd) {
5259 for (
int y = yStart;
y < yEnd; ++
y) {
5260 QCmyk32 *scanline =
reinterpret_cast<QCmyk32 *
>(
d->data +
y *
d->bytes_per_line);
5265 transformSegment = [&](
int yStart,
int yEnd) {
5266 for (
int y = yStart;
y < yEnd; ++
y) {
5267 QRgb *scanline =
reinterpret_cast<QRgb *
>(
d->data +
y *
d->bytes_per_line);
5273#if QT_CONFIG(thread) && !defined(Q_OS_WASM)
5282 threadPool->
start([&,
y, yn]() {
5283 transformSegment(
y,
y + yn);
5291 transformSegment(0,
height());
5293 if (oldFormat !=
format())
5294 *
this = std::move(*this).convertToFormat(oldFormat);
5337 qWarning() <<
"QImage::colorTransformed: Invalid input color space for transform";
5342 switch (outColorModel) {
5419 return convertedTo(toFormat,
flags);
5424 qWarning() <<
"QImage::colorTransformed: Invalid input color space for transform";
5428 qWarning() <<
"QImage::colorTransformed: Invalid output color space for transform";
5432 QImage fromImage = *
this;
5493 if (inColorData != outColorData) {
5512 std::function<
void(
int,
int)> transformSegment;
5515 if (inColorData != outColorData) {
5520 transformSegment = [&](
int yStart,
int yEnd) {
5521 for (
int y = yStart;
y < yEnd; ++
y) {
5522 const quint8 *in_scanline =
reinterpret_cast<const quint8 *
>(
d->data +
y *
d->bytes_per_line);
5528 transformSegment = [&](
int yStart,
int yEnd) {
5529 for (
int y = yStart;
y < yEnd; ++
y) {
5530 const quint16 *in_scanline =
reinterpret_cast<const quint16 *
>(
d->data +
y *
d->bytes_per_line);
5539 transformSegment = [&](
int yStart,
int yEnd) {
5540 for (
int y = yStart;
y < yEnd; ++
y) {
5541 const quint8 *in_scanline =
reinterpret_cast<const quint8 *
>(
d->data +
y *
d->bytes_per_line);
5547 transformSegment = [&](
int yStart,
int yEnd) {
5548 for (
int y = yStart;
y < yEnd; ++
y) {
5549 const quint16 *in_scanline =
reinterpret_cast<const quint16 *
>(
d->data +
y *
d->bytes_per_line);
5559 transformSegment = [&](
int yStart,
int yEnd) {
5560 for (
int y = yStart;
y < yEnd; ++
y) {
5568 transformSegment = [&](
int yStart,
int yEnd) {
5569 for (
int y = yStart;
y < yEnd; ++
y) {
5579 transformSegment = [&](
int yStart,
int yEnd) {
5580 for (
int y = yStart;
y < yEnd; ++
y) {
5587 transformSegment = [&](
int yStart,
int yEnd) {
5588 for (
int y = yStart;
y < yEnd; ++
y) {
5598 transformSegment = [&](
int yStart,
int yEnd) {
5599 for (
int y = yStart;
y < yEnd; ++
y) {
5606 transformSegment = [&](
int yStart,
int yEnd) {
5607 for (
int y = yStart;
y < yEnd; ++
y) {
5615 transformSegment = [&](
int yStart,
int yEnd) {
5616 for (
int y = yStart;
y < yEnd; ++
y) {
5630 transformSegment = [&](
int yStart,
int yEnd) {
5631 for (
int y = yStart;
y < yEnd; ++
y) {
5638 transformSegment = [&](
int yStart,
int yEnd) {
5639 for (
int y = yStart;
y < yEnd; ++
y) {
5647 transformSegment = [&](
int yStart,
int yEnd) {
5648 for (
int y = yStart;
y < yEnd; ++
y) {
5661 for (
int i = 0;
i <
d->colortable.size(); ++
i)
5678 if (hasAlphaChannel())
5689 if (fromImage.
format() == Format_Grayscale8) {
5690 transformSegment = [&](
int yStart,
int yEnd) {
5691 for (
int y = yStart;
y < yEnd; ++
y) {
5693 if (tmpFormat == Format_Grayscale8) {
5697 Q_ASSERT(tmpFormat == Format_Grayscale16);
5703 }
else if (fromImage.
format() == Format_Grayscale16) {
5704 transformSegment = [&](
int yStart,
int yEnd) {
5705 for (
int y = yStart;
y < yEnd; ++
y) {
5711 }
else if (fromImage.
format() == Format_CMYK8888) {
5712 Q_ASSERT(tmpFormat == Format_CMYK8888);
5713 transformSegment = [&](
int yStart,
int yEnd) {
5714 for (
int y = yStart;
y < yEnd; ++
y) {
5722 transformSegment = [&](
int yStart,
int yEnd) {
5723 for (
int y = yStart;
y < yEnd; ++
y) {
5730 transformSegment = [&](
int yStart,
int yEnd) {
5731 for (
int y = yStart;
y < yEnd; ++
y) {
5744 transformSegment = [&](
int yStart,
int yEnd) {
5745 for (
int y = yStart;
y < yEnd; ++
y) {
5763#if QT_CONFIG(thread) && !defined(Q_OS_WASM)
5772 threadPool->
start([&,
y, yn]() {
5773 transformSegment(
y,
y + yn);
5781 transformSegment(0,
height());
5783 if (tmpFormat != toFormat)
5805 qWarning() <<
"QImage::colorTransformed: Invalid input color space for transform";
5810 switch (outColorModel) {
5824 return std::move(*
this);
5852 return converter(
this,
flags);
5858#if QT_CONFIG(raster_fp)
5860 return convert_generic_inplace_over_rgba32f(
this, newFormat,
flags);
5879#ifndef QT_NO_DEBUG_STREAM
5889 dbg <<
i.size() <<
",format=" <<
i.format() <<
",depth=" <<
i.depth();
5891 dbg <<
",colorCount=" <<
i.colorCount();
5892 const int bytesPerLine =
i.bytesPerLine();
5893 dbg <<
",devicePixelRatio=" <<
i.devicePixelRatio()
5894 <<
",bytesPerLine=" << bytesPerLine <<
",sizeInBytes=" <<
i.sizeInBytes();
5895 if (dbg.verbosity() > 2 &&
i.height() > 0) {
5896 const int outputLength =
qMin(bytesPerLine, 24);
5898 <<
QByteArray(
reinterpret_cast<const char *
>(
i.scanLine(0)), outputLength).toHex()
6403 for (
int i = 0;
i < NImageFormats;
i++) {
6407 return Format_Invalid;
6427 const auto textKeys =
image.textKeys();
6437 QMap<QString, QString>
text;
6440 if (
index >= 0 && pair.indexOf(u
' ') <
index) {
6441 if (!pair.trimmed().isEmpty())
6442 text.
insert(
"Description"_L1, pair.toString().simplified());
6445 if (!
key.trimmed().isEmpty())
6454#include "moc_qimage.cpp"
IOBluetoothDevice * device
\inmodule QtCore \reentrant
void setData(const QByteArray &data)
Sets the contents of the internal buffer to be data.
static QByteArray fromRawData(const char *data, qsizetype size)
Constructs a QByteArray that uses the first size bytes of the data array.
The QColorSpace class provides a color space abstraction.
bool isValid() const noexcept
Returns true if the color space is valid.
ColorModel colorModel() const noexcept
Returns the color model this color space can represent.
bool isValidTarget() const noexcept
The QColor class provides colors based on RGB, HSV or CMYK values.
QRgb rgba() const noexcept
Returns the RGB value of the color, including its alpha.
void setRgbF(float r, float g, float b, float a=1.0)
Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha,...
\inmodule QtCore\reentrant
static QPlatformIntegration * platformIntegration()
\inmodule QtCore \reentrant
@ TransformationRotate270
static void executeImageHooks(qint64 key)
The QImageReader class provides a format independent interface for reading images from files or other...
QImage read()
Reads an image from the device.
The QImageWriter class provides a format independent interface for writing images to files or other d...
bool write(const QImage &image)
Writes the image image to the assigned device or file name.
void setDotsPerMeterY(int)
Sets the number of pixels that fit vertically in a physical meter, to y.
bool loadFromData(QByteArrayView data, const char *format=nullptr)
void detachMetadata(bool invalidateCache=false)
int dotsPerMeterX() const
Returns the number of pixels that fit horizontally in a physical meter.
int bitPlaneCount() const
Returns the number of bit planes in the image.
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false.
bool valid(int x, int y) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QImage createAlphaMask(Qt::ImageConversionFlags flags=Qt::AutoColor) const
QImage scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setAlphaChannel(const QImage &alphaChannel)
Sets the alpha channel of this image to the given alphaChannel.
QColorSpace colorSpace() const
void setText(const QString &key, const QString &value)
Sets the image text to the given text and associate it with the given key.
static QPixelFormat toPixelFormat(QImage::Format format) noexcept
Converts format into a QPixelFormat.
qsizetype bytesPerLine() const
Returns the number of bytes per image scanline.
void setPixel(int x, int y, uint index_or_rgb)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QImage colorTransformed(const QColorTransform &transform) const &
void setPixelColor(int x, int y, const QColor &c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QList< QRgb > colorTable() const
Returns a list of the colors contained in the image's color table, or an empty list if the image does...
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
QRgb pixel(int x, int y) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QImage transformed(const QTransform &matrix, Qt::TransformationMode mode=Qt::FastTransformation) const
void setColorCount(int)
Resizes the color table to contain colorCount entries.
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
QImage createHeuristicMask(bool clipTight=true) const
qsizetype sizeInBytes() const
bool allGray() const
Returns true if all the colors in the image are shades of gray (i.e.
QImage smoothScaled(int w, int h) const
void rgbSwapped_inplace()
QRgb color(int i) const
Returns the color in the color table at index i.
QSize size() const
Returns the size of the image, i.e.
bool isGrayscale() const
For 32-bit images, this function is equivalent to allGray().
void convertTo(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor)
bool operator==(const QImage &) const
Returns true if this image and the given image have the same contents; otherwise returns false.
int width() const
Returns the width of the image.
bool save(const QString &fileName, const char *format=nullptr, int quality=-1) const
Saves the image to the file with the given fileName, using the given image file format and quality fa...
uchar * bits()
Returns a pointer to the first pixel data.
bool isNull() const
Returns true if it is a null image, otherwise returns false.
void applyColorTransform(const QColorTransform &transform)
int height() const
Returns the height of the image.
void setColorTable(const QList< QRgb > &colors)
QImage createMaskFromColor(QRgb color, Qt::MaskMode mode=Qt::MaskInColor) const
QPaintEngine * paintEngine() const override
bool convertToFormat_inplace(Format format, Qt::ImageConversionFlags flags)
Format
The following image formats are available in Qt.
@ Format_RGBA32FPx4_Premultiplied
@ Format_RGBA64_Premultiplied
@ Format_ARGB6666_Premultiplied
@ Format_ARGB8555_Premultiplied
@ Format_RGBA8888_Premultiplied
@ Format_ARGB8565_Premultiplied
@ Format_RGBA16FPx4_Premultiplied
@ Format_A2BGR30_Premultiplied
@ Format_ARGB32_Premultiplied
@ Format_A2RGB30_Premultiplied
@ Format_ARGB4444_Premultiplied
virtual int metric(PaintDeviceMetric metric) const override
QImage() noexcept
Constructs a null image.
void fill(uint pixel)
Fills the entire image with the given pixelValue.
QImage mirrored(bool horizontally=false, bool vertically=true) const &
QPixelFormat pixelFormat() const noexcept
Returns the QImage::Format as a QPixelFormat.
QColor pixelColor(int x, int y) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setColorSpace(const QColorSpace &colorSpace)
QImage scaledToHeight(int h, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a scaled copy of the image.
Format format() const
Returns the format of the image.
bool operator!=(const QImage &) const
Returns true if this image and the given image have different contents; otherwise returns false.
static QImage fromData(QByteArrayView data, const char *format=nullptr)
bool load(QIODevice *device, const char *format)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const uchar * constScanLine(int) const
Returns a pointer to the pixel data at the scanline with index i.
QStringList textKeys() const
Returns the text keys for this image.
void setColor(int i, QRgb c)
Sets the color at the given index in the color table, to the given to colorValue.
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.
void mirrored_inplace(bool horizontal, bool vertical)
qreal devicePixelRatio() const
Returns the device pixel ratio for the image.
void setDotsPerMeterX(int)
Sets the number of pixels that fit horizontally in a physical meter, to x.
QImage rgbSwapped_helper() const
int dotsPerMeterY() const
Returns the number of pixels that fit vertically in a physical meter.
static QImage::Format toImageFormat(QPixelFormat format) noexcept
Converts format into a QImage::Format.
const uchar * constBits() const
Returns a pointer to the first pixel data.
int colorCount() const
Returns the depth of the image.
QSizeF deviceIndependentSize() const
Returns the size of the image in device independent pixels.
QImage mirrored_helper(bool horizontal, bool vertical) const
QString text(const QString &key=QString()) const
Returns the image text associated with the given key.
QImage & operator=(const QImage &)
Move-assigns other to this QImage instance.
~QImage()
Destroys the image and cleans up.
int pixelIndex(int x, int y) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QImage convertToFormat_helper(Format format, Qt::ImageConversionFlags flags) const
QImage convertedTo(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
InvertMode
This enum type is used to describe how pixel values should be inverted in the invertPixels() function...
static QTransform trueMatrix(const QTransform &, int w, int h)
Returns a copy of the image that is transformed using the given transformation matrix and transformat...
QImage scaledToWidth(int w, Qt::TransformationMode mode=Qt::FastTransformation) const
[9]
void convertToColorSpace(const QColorSpace &colorSpace)
QPoint offset() const
Returns the number of pixels by which the image is intended to be offset by when positioning relative...
bool reinterpretAsFormat(Format f)
void setOffset(const QPoint &)
Sets the number of pixels by which the image is intended to be offset by when positioning relative to...
QImage convertedToColorSpace(const QColorSpace &colorSpace) const
int devType() const override
void invertPixels(InvertMode=InvertRgb)
Inverts all pixel values in the image.
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
qint64 cacheKey() const
Returns a number that identifies the contents of this QImage object.
@ PdmDevicePixelRatioScaled
static qreal devicePixelRatioFScale()
The QPainter class performs low-level painting on widgets and other paint devices.
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
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...
@ CompositionMode_DestinationIn
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
\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 QPolygonF class provides a list of points using floating point precision.
The QRasterPaintEngine class enables hardware acceleration of painting operations in Qt for Embedded ...
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr int width() const noexcept
Returns the width of the rectangle.
void setAlpha(quint16 _alpha)
static constexpr QRgba64 fromArgb32(uint rgb)
static constexpr QRgbaFloat fromArgb32(uint rgb)
constexpr Q_ALWAYS_INLINE QRgbaFloat premultiplied() const
constexpr Q_ALWAYS_INLINE QRgbaFloat unpremultiplied() const
void acquire(int n=1)
Tries to acquire n resources guarded by the semaphore.
void release(int n=1)
Releases n resources guarded by the semaphore.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr int & rheight() noexcept
Returns a reference to the height.
void scale(int w, int h, Qt::AspectRatioMode mode) noexcept
Scales the size to a rectangle with the given width and height, according to the specified mode:
constexpr int & rwidth() noexcept
Returns a reference to the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString left(qsizetype n) const &
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
void chop(qsizetype n)
Removes n characters from the end of the string.
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
QString & insert(qsizetype i, QChar c)
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
auto tokenize(Needle &&needle, Flags...flags) const &noexcept(noexcept(qTokenize(std::declval< const QString & >(), std::forward< Needle >(needle), flags...))) -> decltype(qTokenize(*this, std::forward< Needle >(needle), flags...))
static QThreadPool * qtGuiInstance()
Returns the QThreadPool instance for Qt Gui.
void start(QRunnable *runnable, int priority=0)
Reserves a thread and uses it to run runnable, unless this thread will make the current thread count ...
bool contains(const QThread *thread) const
static QThread * currentThread()
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
\keyword 16-bit Floating Point Support\inmodule QtCore \inheaderfile QFloat16
QCache< int, Employee > cache
[0]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
QFuture< QtPrivate::MapResultType< Sequence, MapFunctor > > mapped(QThreadPool *pool, Sequence &&sequence, MapFunctor &&map)
QTextStream & ws(QTextStream &stream)
Calls \l {QTextStream::}{skipWhiteSpace()} on stream and returns stream.
static jboolean copy(JNIEnv *, jobject)
#define Q_BASIC_ATOMIC_INITIALIZER(a)
static QT_WARNING_DISABLE_FLOAT_COMPARE ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
#define QT_WARNING_DISABLE_MSVC(number)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
static constexpr int BufferSize
ushort qConvertRgb32To16(uint c)
QRgb qConvertRgb16To32(uint c)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
Q_GUI_EXPORT int qt_defaultDpiX()
Q_GUI_EXPORT int qt_defaultDpiY()
static QImage rotated90(const QImage &src)
static void copyMetadata(QImageData *dst, const QImageData *src)
static void rgbSwapped_generic(int width, int height, const QImage *src, QImage *dst, const QPixelLayout *layout)
QDataStream & operator<<(QDataStream &s, const QImage &image)
[0]
bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth, uchar *dptr, qsizetype dbpl, int p_inc, int dHeight, const uchar *sptr, qsizetype sbpl, int sWidth, int sHeight)
QImage Q_TRACE_INSTRUMENT(qtgui) QImage
bool qt_read_xpm_image_or_array(QIODevice *device, const char *const *source, QImage &image)
static bool isRgb32fpx4Data(QImage::Format f)
static int next_qimage_serial_number()
#define QIMAGE_SANITYCHECK_MEMORY(image)
static QImage convertWithPalette(const QImage &src, QImage::Format format, const QList< QRgb > &clut)
void do_flip(QImageData *dst, QImageData *src, int w, int h, int depth)
static void copyPhysicalMetadata(QImageData *dst, const QImageData *src)
Q_GUI_EXPORT void qt_imageTransform(QImage &src, QImageIOHandler::Transformations orient)
static QImage rotated270(const QImage &src)
QMap< QString, QString > qt_getImageText(const QImage &image, const QString &description)
void do_mirror(QImageData *dst, QImageData *src, bool horizontal, bool vertical)
static int pixel_distance(QRgb p1, QRgb p2)
static int closestMatch(QRgb pixel, const QList< QRgb > &clut)
static constexpr QPixelFormat pixelformats[]
static bool isRgb64Data(QImage::Format f)
static QImage rotated180(const QImage &src)
QDataStream & operator>>(QDataStream &s, QImage &image)
static bool isRgb32Data(QImage::Format f)
QMap< QString, QString > qt_getImageTextFromDescription(const QString &description)
void(* QImageCleanupFunction)(void *)
Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormats]
static const uchar bitflip[256]
const uchar * qt_get_bitflip_array()
void dither_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags, bool fromalpha)
void convert_generic_over_rgb64(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags flags)
bool convert_generic_inplace_over_rgb64(QImageData *data, QImage::Format dst_format, Qt::ImageConversionFlags)
int qt_depthForFormat(QImage::Format format)
Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormats]
QColorSpace::ColorModel qt_csColorData(QPixelFormat::ColorModel format)
bool qt_fpColorPrecision(QImage::Format format)
bool(* InPlace_Image_Converter)(QImageData *data, Qt::ImageConversionFlags)
bool qt_compatibleColorModel(QPixelFormat::ColorModel data, QColorSpace::ColorModel cs)
InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QImage::NImageFormats]
QImage::Format qt_alphaVersion(QImage::Format format)
bool qt_highColorPrecision(QImage::Format format, bool opaque=false)
void(* Image_Converter)(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
QImage::Format qt_alphaVersionForPainting(QImage::Format format)
bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::ImageConversionFlags)
QImage qSmoothScaleImage(const QImage &src, int dw, int dh)
static ControlElement< T > * ptr(QWidget *widget)
MemRotateFunc qMemRotateFunctions[QPixelLayout::BPPCount][3]
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLint GLint GLint GLint dstX0
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLint GLenum GLsizei GLsizei GLsizei depth
GLenum GLint GLint GLint GLint GLuint GLenum GLint GLint GLint dstY
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLint GLint GLint srcY
GLenum GLint GLint GLint GLint GLuint GLenum GLint GLint dstX
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLuint GLintptr offset
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLint GLint GLint GLint GLint dstY0
GLfloat GLfloat GLfloat GLfloat h
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 * table
QPixelLayout qPixelLayouts[]
QRgba64 qConvertA2rgb30ToRgb64< PixelOrderBGR >(uint rgb)
unsigned int qConvertRgb64ToRgb30< PixelOrderBGR >(QRgba64 c)
QRgb qConvertA2rgb30ToArgb32< PixelOrderBGR >(uint c)
void(QT_FASTCALL * RbSwapFunc)(uchar *dst, const uchar *src, int count)
static quint32 RGBA2ARGB(quint32 x)
uint qConvertRgb32ToRgb30< PixelOrderRGB >(QRgb c)
QRgba64 qConvertA2rgb30ToRgb64< PixelOrderRGB >(uint rgb)
uint qConvertArgb32ToA2rgb30< PixelOrderBGR >(QRgb c)
uint qConvertRgb32ToRgb30< PixelOrderBGR >(QRgb c)
QRgb qConvertA2rgb30ToArgb32< PixelOrderRGB >(uint c)
static quint32 ARGB2RGBA(quint32 x)
unsigned int qConvertRgb64ToRgb30< PixelOrderRGB >(QRgba64 c)
void(* MemRotateFunc)(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
uint qConvertArgb32ToA2rgb30< PixelOrderRGB >(QRgb c)
uint qRgbSwapRgb30(uint c)
static QT_BEGIN_NAMESPACE const QRgb colors[][14]
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
constexpr bool qIsGray(QRgb rgb)
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
constexpr QRgb qRgb(int r, int g, int b)
constexpr int qRed(QRgb rgb)
constexpr int qGreen(QRgb rgb)
constexpr int qBlue(QRgb rgb)
constexpr QRgb qPremultiply(QRgb x)
constexpr int qAlpha(QRgb rgb)
constexpr QRgba64 qRgba64(quint16 r, quint16 g, quint16 b, quint16 a)
static uint toArgb32(QRgba64 rgba64)
#define qPrintable(string)
#define QT_CONFIG(feature)
#define Q_TRACE_PARAM_REPLACE(in, out)
#define Q_TRACE_METADATA(provider, metadata)
#define Q_TRACE_PREFIX(provider, prefix)
#define Q_TRACE_SCOPE(x,...)
unsigned long long quint64
ReturnedValue read(const char *data)
std::uniform_real_distribution dist(1, 2.5)
[2]
QTextStream out(stdout)
[7]
bool checkForAlphaPixels() const
bool doImageIO(const QImage *image, QImageWriter *io, int quality) const
static QImageData * get(QImage &img) noexcept
static ImageSizeParameters calculateImageParameters(qsizetype width, qsizetype height, qsizetype depth)
bool convertInPlace(QImage::Format newFormat, Qt::ImageConversionFlags)
static QImageData * create(const QSize &size, QImage::Format format)
QPaintEngine * paintEngine
QImageCleanupFunction cleanupFunction