4#include <private/qguiapplication_p.h>
5#include <private/qcolortransform_p.h>
6#include <private/qcolortrclut_p.h>
7#include <private/qdrawhelper_p.h>
8#include <private/qendian_p.h>
9#include <private/qpixellayout_p.h>
10#include <private/qsimd_p.h>
11#include <private/qimage_p.h>
18#include <private/qthreadpool_p.h>
22#define QT_USE_THREAD_PARALLEL_IMAGE_CONVERSIONS
33 for (
int i = 0;
i < 256; ++
i) {
56 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240,
57 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248,
58 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244,
59 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252,
60 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242,
61 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250,
62 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246,
63 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254,
64 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241,
65 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249,
66 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245,
67 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253,
68 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243,
69 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251,
70 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247,
71 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255
88 for (
int y=0;
y<
h; ++
y) {
90 for (
int x=0;
x<
w; ++
x)
100#if !defined(__ARM_NEON__) || !(Q_BYTE_ORDER == Q_LITTLE_ENDIAN)
115 d[
i] = 0xff000000 |
src[
i];
127#ifdef QT_COMPILER_SUPPORTS_SSE4_1
130#elif defined(__ARM_NEON__) && (Q_BYTE_ORDER == Q_LITTLE_ENDIAN)
153#ifdef QT_COMPILER_SUPPORTS_SSE4_1
155 store = storeRGB32FromARGB32PM_sse4;
158#elif defined(__ARM_NEON__) && (Q_BYTE_ORDER == Q_LITTLE_ENDIAN)
159 store = storeRGB32FromARGB32PM_neon;
175 auto convertSegment = [=](
int yStart,
int yEnd) {
178 const uchar *srcData =
src->data +
src->bytes_per_line * yStart;
184 for (
int y = yStart;
y < yEnd; ++
y) {
187 while (x < src->
width) {
189 int l =
src->width -
x;
194 const uint *
ptr = fetch(
buffer, srcData,
x, l,
nullptr, ditherPtr);
195 store(destData,
ptr,
x, l,
nullptr, ditherPtr);
198 srcData +=
src->bytes_per_line;
203#ifdef QT_USE_THREAD_PARALLEL_IMAGE_CONVERSIONS
209 return convertSegment(0,
src->height);
215 threadPool->
start([&,
y, yn]() {
216 convertSegment(
y,
y + yn);
223 convertSegment(0,
src->height);
237 auto convertSegment = [=](
int yStart,
int yEnd) {
240 const uchar *srcData =
src->data + yStart *
src->bytes_per_line;
242 for (
int y = yStart;
y < yEnd; ++
y) {
244 while (x < src->
width) {
245 int l =
src->width -
x;
251 store(destData,
ptr,
x, l,
nullptr,
nullptr);
254 srcData +=
src->bytes_per_line;
258#ifdef QT_USE_THREAD_PARALLEL_IMAGE_CONVERSIONS
264 return convertSegment(0,
src->height);
270 threadPool->
start([&,
y, yn]() {
271 convertSegment(
y,
y + yn);
278 convertSegment(0,
src->height);
282#if QT_CONFIG(raster_fp)
291 auto convertSegment = [=](
int yStart,
int yEnd) {
294 const uchar *srcData =
src->data + yStart *
src->bytes_per_line;
296 for (
int y = yStart;
y < yEnd; ++
y) {
298 while (x < src->
width) {
299 int l =
src->width -
x;
300 if (dest->
depth == 128)
305 store(destData,
ptr,
x, l,
nullptr,
nullptr);
308 srcData +=
src->bytes_per_line;
312#ifdef QT_USE_THREAD_PARALLEL_IMAGE_CONVERSIONS
318 return convertSegment(0,
src->height);
324 threadPool->
start([&,
y, yn]() {
325 convertSegment(
y,
y + yn);
332 convertSegment(0,
src->height);
343 if (
data->depth < destDepth)
355 if (
data->depth != destDepth) {
371#ifdef QT_COMPILER_SUPPORTS_SSE4_1
373 store = storeRGB32FromARGB32PM_sse4;
376#elif defined(__ARM_NEON__) && (Q_BYTE_ORDER == Q_LITTLE_ENDIAN)
377 store = storeRGB32FromARGB32PM_neon;
393 auto convertSegment = [=](
int yStart,
int yEnd) {
397 uchar *destData = srcData;
402 for (
int y = yStart;
y < yEnd; ++
y) {
405 while (x < data->
width) {
407 int l =
data->width -
x;
412 const uint *
ptr = fetch(
buffer, srcData,
x, l,
nullptr, ditherPtr);
413 store(destData,
ptr,
x, l,
nullptr, ditherPtr);
416 srcData +=
data->bytes_per_line;
417 destData +=
params.bytesPerLine;
420#ifdef QT_USE_THREAD_PARALLEL_IMAGE_CONVERSIONS
429 threadPool->
start([&,
y, yn]() {
430 convertSegment(
y,
y + yn);
436 if (
data->bytes_per_line !=
params.bytesPerLine) {
443 if (srcData != destData)
444 memmove(destData, srcData,
params.bytesPerLine * yn);
450 convertSegment(0,
data->height);
453 void *newData = realloc(
data->data,
params.totalSize);
460 data->depth = destDepth;
461 data->format = dst_format;
470 if (
data->depth < destDepth)
477 if (
data->depth != destDepth) {
493 auto convertSegment = [=](
int yStart,
int yEnd) {
497 uchar *destData = srcData;
498 for (
int y = yStart;
y < yEnd; ++
y) {
500 while (x < data->
width) {
501 int l =
data->width -
x;
507 store(destData,
ptr,
x, l,
nullptr,
nullptr);
510 srcData +=
data->bytes_per_line;
511 destData +=
params.bytesPerLine;
514#ifdef QT_USE_THREAD_PARALLEL_IMAGE_CONVERSIONS
523 threadPool->
start([&,
y, yn]() {
524 convertSegment(
y,
y + yn);
530 if (
data->bytes_per_line !=
params.bytesPerLine) {
537 if (srcData != destData)
538 memmove(destData, srcData,
params.bytesPerLine * yn);
544 convertSegment(0,
data->height);
547 void *newData = realloc(
data->data,
params.totalSize);
554 data->depth = destDepth;
555 data->format = dst_format;
559#if QT_CONFIG(raster_fp)
565 if (
data->depth < destDepth)
572 if (
data->depth != destDepth) {
584 fetch = qFetchToRGBA32F[
data->format + 1];
585 store = qStoreFromRGBA32F[dst_format + 1];
588 auto convertSegment = [=](
int yStart,
int yEnd) {
592 uchar *destData = srcData;
593 for (
int y = yStart;
y < yEnd; ++
y) {
595 while (x < data->
width) {
596 int l =
data->width -
x;
602 store(destData,
ptr,
x, l,
nullptr,
nullptr);
605 srcData +=
data->bytes_per_line;
606 destData +=
params.bytesPerLine;
609#ifdef QT_USE_THREAD_PARALLEL_IMAGE_CONVERSIONS
618 threadPool->
start([&,
y, yn]() {
619 convertSegment(
y,
y + yn);
625 if (
data->bytes_per_line !=
params.bytesPerLine) {
632 if (srcData != destData)
633 memmove(destData, srcData,
params.bytesPerLine * yn);
639 convertSegment(0,
data->height);
642 void *newData = realloc(
data->data,
params.totalSize);
649 data->depth = destDepth;
650 data->format = dst_format;
660 const int src_bpl =
src->bytes_per_line;
665 for (
int i = 0;
i <
src->height; ++
i) {
666 memcpy(dest_data, src_data, src_bpl);
668 dest_data += dest_bpl;
672template<QImage::Format Format>
683 while ((
quintptr(src_data) & 0x3) && pixel <
len) {
684 *dest_data = 0xff000000 | (src_data[0] << 16) | (src_data[1] << 8) | (src_data[2]);
691 for (; pixel + 3 <
len; pixel += 4) {
693 const quint32 src1 = src_packed[0];
694 const quint32 src2 = src_packed[1];
695 const quint32 src3 = src_packed[2];
697 dest_data[0] = 0xff000000 | (src1 >> 8);
698 dest_data[1] = 0xff000000 | (src1 << 16) | (src2 >> 16);
699 dest_data[2] = 0xff000000 | (src2 << 8) | (src3 >> 24);
700 dest_data[3] = 0xff000000 | src3;
707 for (; pixel <
len; ++pixel) {
708 *dest_data = 0xff000000 | (src_data[0] << 16) | (src_data[1] << 8) | (src_data[2]);
718 while ((
quintptr(src_data) & 0x3) && pixel <
len) {
719 *dest_data =
ARGB2RGBA(0xff000000 | (src_data[0] << 16) | (src_data[1] << 8) | (src_data[2]));
726 for (; pixel + 3 <
len; pixel += 4) {
728 const quint32 src1 = src_packed[0];
729 const quint32 src2 = src_packed[1];
730 const quint32 src3 = src_packed[2];
732#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
733 dest_data[0] = 0xff000000 | src1;
734 dest_data[1] = 0xff000000 | (src1 >> 24) | (src2 << 8);
735 dest_data[2] = 0xff000000 | (src2 >> 16) | (src3 << 16);
736 dest_data[3] = 0xff000000 | (src3 >> 8);
738 dest_data[0] = 0xff | src1;
739 dest_data[1] = 0xff | (src1 << 24) | (src2 >> 8);
740 dest_data[2] = 0xff | (src2 << 16) | (src3 >> 16);
741 dest_data[3] = 0xff | (src3 << 8);
749 for (; pixel <
len; ++pixel) {
750 *dest_data =
ARGB2RGBA(0xff000000 | (src_data[0] << 16) | (src_data[1] << 8) | (src_data[2]));
774 for (
int i = 0;
i <
src->height; ++
i) {
775 line_converter(dest_data, src_data,
src->width);
776 src_data +=
src->bytes_per_line;
788 const int src_pad = (
src->bytes_per_line >> 2) -
src->width;
793 for (
int i = 0;
i <
src->height; ++
i) {
795 while (src_data <
end) {
796 *dest_data =
ARGB2RGBA(0xff000000 | *src_data);
801 dest_data += dest_pad;
812 const int src_pad = (
src->bytes_per_line >> 2) -
src->width;
817 for (
int i = 0;
i <
src->height; ++
i) {
819 while (src_data <
end) {
825 dest_data += dest_pad;
829template<QImage::Format DestFormat>
834 const int pad = (
data->bytes_per_line >> 2) -
data->width;
838 for (
int i = 0;
i <
data->height; ++
i) {
840 while (rgb_data <
end) {
847 data->format = DestFormat;
858 const int src_pad = (
src->bytes_per_line >> 2) -
src->width;
863 for (
int i = 0;
i <
src->height; ++
i) {
865 while (src_data <
end) {
871 dest_data += dest_pad;
875template<QImage::Format DestFormat>
880 const int pad = (
data->bytes_per_line >> 2) -
data->width;
884 for (
int i = 0;
i <
data->height; ++
i) {
886 while (rgb_data <
end) {
892 data->format = DestFormat;
909 for (
int i = 0;
i <
src->height; ++
i) {
910 func(dest_data, src_data,
src->width);
925 for (
int i = 0;
i <
data->height; ++
i) {
926 func(line_data, line_data,
data->width);
930 switch (
data->format) {
957template<QtPixelOrder PixelOrder,
bool RGBA>
968 const int src_pad = (
src->bytes_per_line >> 2) -
src->width;
973 for (
int i = 0;
i <
src->height; ++
i) {
975 while (src_data <
end) {
981 *dest_data = (qConvertRgb32ToRgb30<PixelOrder>(
c) & 0x3fffffff) | (
alpha << 30);
986 dest_data += dest_pad;
990template<QtPixelOrder PixelOrder,
bool RGBA>
996 const int pad = (
data->bytes_per_line >> 2) -
data->width;
999 for (
int i = 0;
i <
data->height; ++
i) {
1001 while (rgb_data <
end) {
1007 *rgb_data = (qConvertRgb32ToRgb30<PixelOrder>(
c) & 0x3fffffff) | (
alpha << 30);
1020 const uint a = rgb30 >> 30;
1025 uint rgb = rgb30 & 0x3fffffff;
1027 return (
a << 30) |
rgb;
1030 uint rgb = rgb30 & 0x3fffffff;
1031 rgb += (
rgb >> 1) & 0x5ff7fdff;
1032 return (
a << 30) |
rgb;
1037 Q_UNREACHABLE_RETURN(0);
1040template<
bool rgbswap>
1048 const int src_pad = (
src->bytes_per_line >> 2) -
src->width;
1053 for (
int i = 0;
i <
src->height; ++
i) {
1055 while (src_data <
end) {
1061 src_data += src_pad;
1062 dest_data += dest_pad;
1066template<
bool rgbswap>
1071 const int pad = (
data->bytes_per_line >> 2) -
data->width;
1074 for (
int i = 0;
i <
data->height; ++
i) {
1076 while (rgb_data <
end) {
1104template<QtPixelOrder PixelOrder,
bool RGBA>
1112 const int src_pad = (
src->bytes_per_line >> 2) -
src->width;
1117 for (
int i = 0;
i <
src->height; ++
i) {
1119 while (src_data <
end) {
1126 src_data += src_pad;
1127 dest_data += dest_pad;
1131template<QtPixelOrder PixelOrder,
bool RGBA>
1136 const int pad = (
data->bytes_per_line >> 2) -
data->width;
1139 for (
int i = 0;
i <
data->height; ++
i) {
1141 while (rgb_data <
end) {
1163 const int src_pad = (
src->bytes_per_line >> 2) -
src->width;
1168 for (
int i = 0;
i <
src->height; ++
i) {
1170 while (src_data <
end) {
1171 *dest_data =
RGBA2ARGB(*src_data) | 0xff000000;
1175 src_data += src_pad;
1176 dest_data += dest_pad;
1194 while (src_data <
end) {
1195 *dest_data =
bitflip[*src_data];
1206 const int src_pad = (
src->bytes_per_line >> 2) -
src->width;
1211 for (
int i = 0;
i <
src->height; ++
i) {
1213 while (src_data <
end) {
1214 *dest_data = *src_data | 0xff000000;
1218 src_data += src_pad;
1219 dest_data += dest_pad;
1223template<QImage::Format DestFormat>
1229 const int pad = (
data->bytes_per_line >> 2) -
data->width;
1232 for (
int i = 0;
i <
data->height; ++
i) {
1234 while (rgb_data <
end) {
1235 *rgb_data = *rgb_data | 0xff000000;
1240 data->format = DestFormat;
1246#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
1253 const int src_pad = (
src->bytes_per_line >> 2) -
src->width;
1258 for (
int i = 0;
i <
src->height; ++
i) {
1260 while (src_data <
end) {
1261 *dest_data = *src_data | 0x000000ff;
1265 src_data += src_pad;
1266 dest_data += dest_pad;
1273#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
1274 return mask_alpha_converter_inplace<QImage::Format_RGBX8888>(
data,
flags);
1278 const int pad = (
data->bytes_per_line >> 2) -
data->width;
1281 for (
int i = 0;
i <
data->height; ++
i) {
1283 while (rgb_data <
end) {
1284 *rgb_data = *rgb_data | 0x000000fff;
1306 for (
int i = 0;
i <
src->height; ++
i) {
1307 uint *
d =
reinterpret_cast<uint *
>(destData);
1309 qt_convertRGBA64ToARGB32<RGBA>(
d,
s,
src->width);
1310 srcData +=
src->bytes_per_line;
1328 for (
int i = 0;
i <
src->height; ++
i) {
1329 fetch(
reinterpret_cast<QRgba64 *
>(dest_data), src_data, 0,
src->width,
nullptr,
nullptr);
1330 src_data +=
src->bytes_per_line;;
1342 const int src_pad = (
src->bytes_per_line >> 3) -
src->width;
1347 for (
int i = 0;
i <
src->height; ++
i) {
1349 while (src_data <
end) {
1350 *dest_data = *src_data;
1355 src_data += src_pad;
1356 dest_data += dest_pad;
1364 const int pad = (
data->bytes_per_line >> 3) -
data->width;
1367 for (
int i = 0;
i <
data->height; ++
i) {
1369 while (rgb_data <
end) {
1392 for (
int i = 0;
i <
src->height; ++
i) {
1393 const quint16 *src_line =
reinterpret_cast<const quint16 *
>(src_data);
1395 for (
int j = 0;
j <
src->width; ++
j) {
1404template<
bool Premultiplied>
1422 QColorTransformPrivate::TransformFlags
flags = Premultiplied
1426 for (
int i = 0;
i <
src->height; ++
i) {
1427 const QRgb *src_line =
reinterpret_cast<const QRgb *
>(src_data);
1434template<
bool Premultiplied>
1452 QColorTransformPrivate::TransformFlags
flags = Premultiplied
1457 for (
int i = 0;
i <
src->height; ++
i) {
1458 const QRgb *src_line =
reinterpret_cast<const QRgb *
>(src_data);
1461 while (j < src->
width) {
1463 for (
int k = 0; k <
len; ++k)
1473template<
bool Premultiplied>
1491 QColorTransformPrivate::TransformFlags
flags = Premultiplied
1496 for (
int i = 0;
i <
src->height; ++
i) {
1497 const QRgba64 *src_line =
reinterpret_cast<const QRgba64 *
>(src_data);
1498 uchar *dest_line = dest_data;
1500 while (j < src->
width) {
1503 for (
int k = 0; k <
len; ++k)
1512template<
bool Premultiplied>
1530 QColorTransformPrivate::TransformFlags
flags = Premultiplied
1534 for (
int i = 0;
i <
src->height; ++
i) {
1535 const QRgba64 *src_line =
reinterpret_cast<const QRgba64 *
>(src_data);
1543template<
bool MaskAlpha>
1551 const int src_pad = (
src->bytes_per_line >> 3) -
src->width;
1556 for (
int i = 0;
i <
src->height; ++
i) {
1558 while (src_data <
end) {
1565 src_data += src_pad;
1566 dest_data += dest_pad;
1570template<
bool MaskAlpha>
1575 const int pad = (
data->bytes_per_line >> 3) -
data->width;
1578 for (
int i = 0;
i <
data->height; ++
i) {
1580 while (rgb_data <
end) {
1597 for (
int i = 0;
i < colorTable.
size(); ++
i)
1599 colorTable[
i] = colorTable.
at(
i) | 0xff000000;
1602 for (
int i = 0;
i < colorTable.
size(); ++
i)
1613 Qt::ImageConversionFlags
flags,
bool fromalpha)
1619 dst->colortable.clear();
1620 dst->colortable.append(0xffffffff);
1621 dst->colortable.append(0xff000000);
1623 enum { Threshold, Ordered,
Diffuse } dithermode;
1629 dithermode = Ordered;
1631 dithermode = Threshold;
1634 dithermode = Threshold;
1636 dithermode = Ordered;
1642 int h =
src->height;
1645 bool use_gray = (
d == 8);
1650 for (
int i = 0;
i <
src->colortable.size();
i++)
1651 gray[
i] = (255 - (
src->colortable.at(
i) >> 24));
1655 for (
int i = 0;
i <
src->colortable.size();
i++)
1665 switch (dithermode) {
1668 int *line1 = lineBuffer.
data();
1669 int *line2 = lineBuffer.
data() +
w;
1670 int bmwidth = (
w+7)/8;
1673 int wbytes =
w * (
d/8);
1683 *b2++ = 255 - (*(
const uint*)
p >> 24);
1693 for (
int y=0;
y<
h;
y++) {
1694 int *tmp = line1; line1 = line2; line2 = tmp;
1695 bool not_last_line =
y <
h - 1;
1696 if (not_last_line) {
1697 p =
src->data + (
y+1)*
src->bytes_per_line;
1706 *b2++ = 255 - (*(
const uint*)
p >> 24);
1720 memset(
p, 0, bmwidth);
1724 for (
int x=1;
x<=
w;
x++) {
1737 const int e7 = ((err * 7) + 8) >> 4;
1738 const int e5 = ((err * 5) + 8) >> 4;
1739 const int e3 = ((err * 3) + 8) >> 4;
1740 const int e1 = err - (e7 + e5 + e3);
1743 if (not_last_line) {
1756 memset(
dst->data, 0,
dst->nbytes);
1758 for (
int i=0;
i<
h;
i++) {
1787 dst_data += dst_bpl;
1788 src_data += src_bpl;
1790 }
else if (
d == 8) {
1791 for (
int i=0;
i<
h;
i++) {
1792 const uchar *
p = src_data;
1807 dst_data += dst_bpl;
1808 src_data += src_bpl;
1813 memset(
dst->data, 0,
dst->nbytes);
1815 for (
int i=0;
i<
h;
i++) {
1822 if ((*
p++ >> 24) >= 128)
1843 dst_data += dst_bpl;
1844 src_data += src_bpl;
1848 for (
int i=0;
i<
h;
i++) {
1849 const uchar *
p = src_data;
1854 if (gray[*
p++] < 128)
1863 dst_data += dst_bpl;
1864 src_data += src_bpl;
1873 int bpl = (
dst->width + 7) *
dst->depth / 8;
1874 int pad =
dst->bytes_per_line - bpl;
1875 for (
int y=0;
y<
dst->height; ++
y) {
1876 for (
int x=0;
x<bpl; ++
x) {
1923 const int tablesize = 997;
1927 if (!
dst->colortable.isEmpty()) {
1932 for (
int i = 0;
i <
dst->colortable.size(); ++
i) {
1935 int hash =
p % tablesize;
1960 dst->colortable.resize(256);
1963 for (
int y = 0;
y <
src->height;
y++) {
1966 for (
int x = 0;
x <
src->width; ++
x) {
1968 int hash =
p % tablesize;
1997 src_data +=
src->bytes_per_line;
1998 dest_data +=
dst->bytes_per_line;
2001 int numColors = do_quant ? 256 :
pix;
2003 dst->colortable.resize(numColors);
2010#define INDEXOF(r,g,b) (((r)*(MAX_G+1)+(g))*(MAX_B+1)+(b))
2012 for (
int rc=0; rc<=
MAX_R; rc++)
2013 for (
int gc=0; gc<=
MAX_G; gc++)
2014 for (
int bc=0; bc<=
MAX_B; bc++)
2020 for (
int y = 0;
y <
src->height;
y++) {
2026#define DITHER(p,m) ((uchar) ((p * (m) + 127) / 255))
2036 src_data +=
src->bytes_per_line;
2037 dest_data +=
dst->bytes_per_line;
2044 line1[0] = lineBuffer.
data();
2045 line2[0] = lineBuffer.
data() +
src->width;
2046 line1[1] = lineBuffer.
data() +
src->width * 2;
2047 line2[1] = lineBuffer.
data() +
src->width * 3;
2048 line1[2] = lineBuffer.
data() +
src->width * 4;
2049 line2[2] = lineBuffer.
data() +
src->width * 5;
2050 pv[0] = lineBuffer.
data() +
src->width * 6;
2051 pv[1] = lineBuffer.
data() +
src->width * 7;
2052 pv[2] = lineBuffer.
data() +
src->width * 8;
2055 for (
int y = 0;
y <
src->height;
y++) {
2056 const uchar*
q = src_data;
2057 const uchar* q2 =
y <
src->height - 1 ?
q +
src->bytes_per_line :
src->data;
2059 for (
int chan = 0; chan < 3; chan++) {
2060 int *l1 = (
y&1) ? line2[chan] : line1[chan];
2061 int *l2 = (
y&1) ? line1[chan] : line2[chan];
2063 for (
int i = 0;
i <
src->width;
i++)
2064 l1[
i] =
q[
i*4+chan+endian];
2066 if (
y+1 <
src->height) {
2067 for (
int i = 0;
i <
src->width;
i++)
2068 l2[
i] = q2[
i*4+chan+endian];
2072 for (
int x = 0;
x <
src->width;
x++) {
2074 int err = l1[
x] -
pix * 255 / 5;
2078 if (
x + 1<
src->width) {
2079 l1[
x+1] += (err*7)>>4;
2084 l2[
x-1]+=(err*3)>>4;
2087 for (
int x =
src->width;
x-- > 0;) {
2089 int err = l1[
x] -
pix * 255 / 5;
2094 l1[
x-1] += (err*7)>>4;
2098 if (
x + 1 <
src->width)
2099 l2[
x+1]+=(err*3)>>4;
2104 for (
int x = 0;
x <
src->width;
x++) {
2108 for (
int x = 0;
x <
src->width;
x++) {
2112 src_data +=
src->bytes_per_line;
2113 dest_data +=
dst->bytes_per_line;
2116 for (
int y = 0;
y <
src->height;
y++) {
2125#define DITHER(p, d, m) ((uchar) ((((256 * (m) + (m) + 1)) * (p) + (d)) >> 16))
2137 src_data +=
src->bytes_per_line;
2138 dest_data +=
dst->bytes_per_line;
2144 const int trans = 216;
2146 dst->colortable[trans] = 0;
2151 for (
int y = 0;
y <
src->height;
y++) {
2152 for (
int x = 0;
x <
src->width ;
x++) {
2153 if (!(mask_data[
x>>3] & (0x80 >> (
x & 7))))
2154 dst_data[
x] = trans;
2156 mask_data +=
mask->bytes_per_line;
2157 dst_data +=
dst->bytes_per_line;
2159 dst->has_alpha_clut =
true;
2192 if (colorTable.
size() == 0) {
2194 for (
int i=0;
i<256; ++
i)
2197 if (colorTable.
size() < 256) {
2198 int tableSize = colorTable.
size();
2201 for (
int i=tableSize;
i<256; ++
i)
2202 colorTable[
i] = fallbackColor;
2209 for (
int y = 0;
y <
src->height;
y++) {
2210 uint *
p =
reinterpret_cast<uint *
>(dest_data);
2211 const uchar *
b = src_data;
2215 *
p++ = colorTablePtr[*
b++];
2217 src_data +=
src->bytes_per_line;
2234 if (colorTable.
size() < 2) {
2235 if (colorTable.
size() == 0)
2236 colorTable << 0xff000000;
2237 colorTable << 0xffffffff;
2243 for (
int y = 0;
y < dest->
height;
y++) {
2245 for (
int x = 0;
x < dest->
width;
x++)
2246 *
p++ = colorTable.
at((src_data[
x>>3] >> (7 - (
x & 7))) & 1);
2248 src_data +=
src->bytes_per_line;
2252 for (
int y = 0;
y < dest->
height;
y++) {
2254 for (
int x = 0;
x < dest->
width;
x++)
2255 *
p++ = colorTable.
at((src_data[
x>>3] >> (
x & 7)) & 1);
2257 src_data +=
src->bytes_per_line;
2272 if (ctbl.
size() > 2) {
2274 }
else if (ctbl.
size() < 2) {
2275 if (ctbl.
size() == 0)
2286 for (
int y = 0;
y < dest->
height;
y++) {
2288 for (
int x = 0;
x < dest->
width;
x++)
2289 *
p++ = (src_data[
x>>3] >> (7 - (
x & 7))) & 1;
2290 src_data +=
src->bytes_per_line;
2294 for (
int y = 0;
y < dest->
height;
y++) {
2296 for (
int x = 0;
x < dest->
width;
x++)
2297 *
p++ = (src_data[
x>>3] >> (
x & 7)) & 1;
2298 src_data +=
src->bytes_per_line;
2307 memcpy(dest->
data,
src->data,
src->bytes_per_line *
src->height);
2311 for (
int y = 0;
y <
src->height; ++
y) {
2312 memcpy(ddata, sdata,
src->width);
2313 sdata +=
src->bytes_per_line;
2326 bool simpleCase = (
colors.size() == 256);
2327 for (
int i = 0;
i <
colors.size(); ++
i) {
2330 simpleCase = simpleCase && (
alpha ==
i);
2338 for (
int y = 0;
y <
src->height; ++
y) {
2339 for (
int x = 0;
x <
src->width; ++
x)
2341 sdata +=
src->bytes_per_line;
2354 bool simpleCase = (
colors.size() == 256);
2355 for (
int i = 0;
i <
colors.size() && simpleCase; ++
i) {
2366 for (
int i = 0;
i <
colors.size(); ++
i) {
2373 for (
int y = 0;
y <
src->height; ++
y) {
2374 for (
int x = 0;
x <
src->width; ++
x)
2376 sdata +=
src->bytes_per_line;
2387 if (
colors.size() != 256)
2389 for (
int i = 0;
i <
colors.size(); ++
i) {
2394 data->colortable.clear();
2406 if (
colors.size() != 256)
2408 for (
int i = 0;
i <
colors.size(); ++
i) {
2413 data->colortable.clear();
2426 dest->
colortable = defaultColorTables->alpha;
2443 data->colortable = defaultColorTables->alpha;
2453 data->colortable = defaultColorTables->gray;
2583#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
2602 mask_alpha_converter_inplace<QImage::Format_ARGB32>;
2604 mask_alpha_converter_inplace<QImage::Format_ARGB32_Premultiplied>;
2607 mask_alpha_converter_inplace<QImage::Format_RGB32>;
2609 convert_ARGB_to_RGBA_inplace<QImage::Format_RGBX8888>;
2611 convert_ARGB_to_RGBA_inplace<QImage::Format_RGBA8888>;
2613 convert_ARGB_to_A2RGB30_inplace<PixelOrderBGR, false>;
2615 convert_ARGB_to_A2RGB30_inplace<PixelOrderRGB, false>;
2618 convert_ARGB_to_RGBA_inplace<QImage::Format_RGBA8888_Premultiplied>;
2624 convert_RGBA_to_ARGB_inplace<QImage::Format_RGB32>;
2626 convert_RGBA_to_ARGB_inplace<QImage::Format_ARGB32>;
2628 convert_RGBA_to_ARGB_inplace<QImage::Format_ARGB32_Premultiplied>;
2630 convert_passthrough_inplace<QImage::Format_RGBA8888>;
2632 convert_passthrough_inplace<QImage::Format_RGBA8888_Premultiplied>;
2635 convert_RGBA_to_ARGB_inplace<QImage::Format_RGB32>;
2637 convert_RGBA_to_ARGB_inplace<QImage::Format_ARGB32>;
2641 convert_ARGB_to_A2RGB30_inplace<PixelOrderBGR, true>;
2643 convert_ARGB_to_A2RGB30_inplace<PixelOrderRGB, true>;
2646 convert_RGBA_to_ARGB_inplace<QImage::Format_ARGB32_Premultiplied>;
2649 convert_passthrough_inplace<QImage::Format_A2BGR30_Premultiplied>;
2656 convert_A2RGB30_PM_to_ARGB_inplace<PixelOrderBGR, false>;
2658 convert_A2RGB30_PM_to_ARGB_inplace<PixelOrderBGR, true>;
2660 convert_A2RGB30_PM_to_RGB30_inplace<false>;
2662 convert_A2RGB30_PM_to_RGB30_inplace<true>;
2671 convert_passthrough_inplace<QImage::Format_A2RGB30_Premultiplied>;
2674 convert_A2RGB30_PM_to_ARGB_inplace<PixelOrderRGB, false>;
2676 convert_A2RGB30_PM_to_ARGB_inplace<PixelOrderRGB, true>;
2678 convert_A2RGB30_PM_to_RGB30_inplace<true>;
2682 convert_A2RGB30_PM_to_RGB30_inplace<false>;
2690 convert_passthrough_inplace<QImage::Format_RGBA64>;
2692 convert_passthrough_inplace<QImage::Format_RGBA64_Premultiplied>;
2701 convert_passthrough_inplace<QImage::Format_RGBA16FPx4>;
2703 convert_passthrough_inplace<QImage::Format_RGBA16FPx4_Premultiplied>;
2706 convert_passthrough_inplace<QImage::Format_RGBA32FPx4>;
2708 convert_passthrough_inplace<QImage::Format_RGBA32FPx4_Premultiplied>;
2711#if defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSSE3)
2723#if defined(__ARM_NEON__)
2730#if defined(__MIPS_DSPR2__)
QColorTransform transformationToXYZ() const
static const QColorSpacePrivate * get(const QColorSpace &colorSpace)
The QColorSpace class provides a color space abstraction.
bool isValid() const noexcept
Returns true if the color space is valid.
QRgb toLinear(QRgb rgb32) const
static QGuiApplicationPrivate * instance()
const QColorTrcLut * colorProfileForA32Text()
Format
The following image formats are available in Qt.
@ Format_RGBA32FPx4_Premultiplied
@ Format_RGBA64_Premultiplied
@ Format_RGBA8888_Premultiplied
@ Format_RGBA16FPx4_Premultiplied
@ Format_A2BGR30_Premultiplied
@ Format_ARGB32_Premultiplied
@ Format_A2RGB30_Premultiplied
qsizetype size() const noexcept
const_pointer constData() const noexcept
const_reference at(qsizetype i) const noexcept
void resize(qsizetype size)
void setAlpha(quint16 _alpha)
constexpr quint8 green8() const
static constexpr QRgba64 fromArgb32(uint rgb)
void setAlpha(FastType _alpha)
constexpr Q_ALWAYS_INLINE QRgbaFloat unpremultiplied() const
T * data() const noexcept
Returns the value of the pointer referenced by this object.
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.
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()
QHash< int, QWidget * > hash
[35multi]
Combined button and popup list for selecting options.
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
static constexpr uint qt_div_257(uint x)
static uint BYTE_MUL(uint x, uint a)
const uint qt_bayer_matrix[16][16]
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
bool convert_generic_inplace_over_rgb64(QImageData *data, QImage::Format dst_format, Qt::ImageConversionFlags)
static void convert_RGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormats]
void(QT_FASTCALL * Rgb888ToRgbConverter)(quint32 *dst, const uchar *src, int len)
static void convert_rgbswap_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static const uchar bitflip[256]
static void convert_Mono_to_Indexed8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void swap_bit_order(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static bool convert_rgbswap_generic_inplace(QImageData *data, Qt::ImageConversionFlags)
static bool convert_ARGB_to_RGBA_inplace(QImageData *data, Qt::ImageConversionFlags)
static bool mask_alpha_converter_inplace(QImageData *data, Qt::ImageConversionFlags)
static void convert_Indexed8_to_Alpha8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_ARGB_to_A2RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
void qGamma_correct_back_to_linear_cs(QImage *image)
static void convert_ARGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
static bool convert_RGBA64_to_RGBx64_inplace(QImageData *data, Qt::ImageConversionFlags)
static void convert_RGBA_to_ARGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void qInitImageConversions()
static bool convert_passthrough_inplace(QImageData *data, Qt::ImageConversionFlags)
static void convert_A2RGB30_PM_to_RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_RGBA16FPM_to_RGBA16F(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static bool convert_A2RGB30_PM_to_RGB30_inplace(QImageData *data, Qt::ImageConversionFlags)
static bool convert_RGBA_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags)
static void convert_X_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
static uint qUnpremultiplyRgb30(uint rgb30)
static void convert_Mono_to_X32(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_passthrough(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static QList< QRgb > fix_color_table(const QList< QRgb > &ctbl, QImage::Format format)
InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QImage::NImageFormats]
static bool convert_Indexed8_to_Grayscale8_inplace(QImageData *data, Qt::ImageConversionFlags)
static void mask_alpha_converter(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_ARGB_PM_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
const uchar * qt_get_bitflip_array()
static bool convert_Indexed8_to_Alpha8_inplace(QImageData *data, Qt::ImageConversionFlags)
static void convert_gray16_to_RGBA64(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
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)
static bool convert_BGR30_to_A2RGB30_inplace(QImageData *data, Qt::ImageConversionFlags flags)
static bool convert_Alpha8_to_Indexed8_inplace(QImageData *data, Qt::ImageConversionFlags)
static void convert_ARGB_to_gray16(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgbx8888(quint32 *dest_data, const uchar *src_data, int len)
static bool convert_RGBA16FPM_to_RGBA16F_inplace(QImageData *data, Qt::ImageConversionFlags)
static void copy_8bit_pixels(QImageData *dest, const QImageData *src)
static void convert_Indexed8_to_Grayscale8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void QT_FASTCALL storeRGB32FromARGB32(uchar *dest, const uint *src, int index, int count, const QList< QRgb > *, QDitherInfo *)
static bool convert_ARGB_to_A2RGB30_inplace(QImageData *data, Qt::ImageConversionFlags)
static void convert_ARGB_PM_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
static bool convert_A2RGB30_PM_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags)
static void mask_alpha_converter_RGBx(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags flags)
static void convert_ARGB_to_RGBx(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
Q_CONSTRUCTOR_FUNCTION(qInitImageConversions)
static void convert_RGBA64_to_gray16(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static bool convert_Grayscale8_to_Indexed8_inplace(QImageData *data, Qt::ImageConversionFlags)
static const uint *QT_FASTCALL fetchRGB32ToARGB32PM(uint *buffer, const uchar *src, int index, int count, const QList< QRgb > *, QDitherInfo *)
static void convert_Alpha8_to_Indexed8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_ARGB_to_gray8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_A2RGB30_PM_to_ARGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags flags)
Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32(quint32 *dest_data, const uchar *src_data, int len)
static bool mask_alpha_converter_rgbx_inplace(QImageData *data, Qt::ImageConversionFlags flags)
bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::ImageConversionFlags flags)
static void convert_ARGB32_to_RGBA64(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_RGBA64_to_gray8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_RGBA64_to_RGBx64(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_Grayscale8_to_Indexed8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void QT_FASTCALL storeRGB32FromARGB32PM(uchar *dest, const uint *src, int index, int count, const QList< QRgb > *, QDitherInfo *)
static void convert_RGBA_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_RGB888_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_ARGB_to_RGBA(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static void convert_RGBA64_to_ARGB32(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
void convert_RGB888_to_RGB32_mips_dspr2(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
bool convert_ARGB_to_ARGB_PM_inplace_mips_dspr2(QImageData *data, Qt::ImageConversionFlags)
int qt_depthForFormat(QImage::Format format)
bool(* InPlace_Image_Converter)(QImageData *data, Qt::ImageConversionFlags)
bool qt_highColorPrecision(QImage::Format format, bool opaque=false)
void(* Image_Converter)(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static ControlElement< T > * ptr(QWidget *widget)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLenum GLsizei count
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum const void * pixels
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
GLfloat GLfloat GLfloat alpha
GLenum GLenum GLsizei void * table
ConvertAndStorePixelsFunc64 qStoreFromRGBA64PM[QImage::NImageFormats]
QPixelLayout qPixelLayouts[QImage::NImageFormats]
void(QT_FASTCALL * RbSwapFunc)(uchar *dst, const uchar *src, int count)
static quint32 RGBA2ARGB(quint32 x)
const uint *(QT_FASTCALL * FetchAndConvertPixelsFunc)(uint *buffer, const uchar *src, int index, int count, const QList< QRgb > *clut, QDitherInfo *dither)
const QRgba64 *(QT_FASTCALL * FetchAndConvertPixelsFunc64)(QRgba64 *buffer, const uchar *src, int index, int count, const QList< QRgb > *clut, QDitherInfo *dither)
static quint32 ARGB2RGBA(quint32 x)
void(QT_FASTCALL * ConvertAndStorePixelsFuncFP)(uchar *dest, const QRgbaFloat32 *src, int index, int count, const QList< QRgb > *clut, QDitherInfo *dither)
const QRgbaFloat32 *(QT_FASTCALL * FetchAndConvertPixelsFuncFP)(QRgbaFloat32 *buffer, const uchar *src, int index, int count, const QList< QRgb > *clut, QDitherInfo *dither)
void(QT_FASTCALL * ConvertAndStorePixelsFunc)(uchar *dest, const uint *src, int index, int count, const QList< QRgb > *clut, QDitherInfo *dither)
void(QT_FASTCALL * ConvertAndStorePixelsFunc64)(uchar *dest, const QRgba64 *src, int index, int count, const QList< QRgb > *clut, QDitherInfo *dither)
uint qRgbSwapRgb30(uint c)
static QT_BEGIN_NAMESPACE const QRgb colors[][14]
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 qGray(int r, int g, int b)
QRgb qUnpremultiply(QRgb p)
constexpr QRgb qRgba(int r, int g, int b, int a)
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)
#define qCpuHasFeature(feature)
static bool translate(xcb_connection_t *connection, xcb_window_t child, xcb_window_t parent, int *x, int *y)
static ImageSizeParameters calculateImageParameters(qsizetype width, qsizetype height, qsizetype depth)
static QImageData * create(const QSize &size, QImage::Format format)
ConvertAndStorePixelsFunc storeFromARGB32PM
FetchAndConvertPixelsFunc64 fetchToRGBA64PM
FetchAndConvertPixelsFunc fetchToARGB32PM
ConvertAndStorePixelsFunc storeFromRGB32