57 #include <private/qdrawhelper_p.h> 58 #include <private/qmemrotate_p.h> 59 #include <private/qpixmapdata_p.h> 60 #include <private/qimagescale_p.h> 61 #include <private/qsimd_p.h> 65 #if defined(Q_OS_SYMBIAN) 66 #include <private/qpaintengine_raster_symbian_p.h> 68 #include <private/qpaintengine_raster_p.h> 71 #include <private/qimage_p.h> 72 #include <private/qfont_p.h> 100 #if defined(Q_CC_DEC) && defined(__alpha) && (__DECCXX_VER-0 >= 50190001) 101 #pragma message disable narrowptr 105 #define QIMAGE_SANITYCHECK_MEMORY(image) \ 106 if ((image).isNull()) { \ 107 qWarning("QImage: out of memory, returning null image"); \ 130 : ref(0), width(0), height(0), depth(0), nbytes(0),
data(0),
135 ser_no(qimage_serial_number.fetchAndAddRelaxed(1)),
139 offset(0, 0), own_data(true), ro_data(false), has_alpha_clut(false),
140 is_cached(false), paintEngine(0)
157 qWarning(
"QImageData::create(): Invalid pixel size for format %i",
172 numColors =
qBound(0, numColors, 256);
183 || bytes_per_line <= 0
195 for (
int i = 0; i < numColors; ++i)
238 bool has_alpha_pixels =
false;
251 for (
int y=0; y<
height && !has_alpha_pixels; ++y) {
252 for (
int x=0; x<
width; ++x)
253 has_alpha_pixels |= (((
uint *)bits)[x] & 0xff000000) != 0xff000000;
263 for (
int y=0; y<
height && !has_alpha_pixels; ++y) {
264 while (bits < end_bits) {
265 has_alpha_pixels |= bits[0] != 0;
277 for (
int y=0; y<
height && !has_alpha_pixels; ++y) {
278 while (bits < end_bits) {
279 has_alpha_pixels |= (bits[0] & 0xfc) != 0;
291 for (
int y=0; y<
height && !has_alpha_pixels; ++y) {
292 while (bits < end_bits) {
293 has_alpha_pixels |= (bits[0] & 0xf0) != 0;
305 return has_alpha_pixels;
747 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240,
748 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248,
749 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244,
750 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252,
751 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242,
752 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250,
753 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246,
754 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254,
755 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241,
756 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249,
757 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245,
758 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253,
759 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243,
760 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251,
761 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247,
762 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255
770 #if defined(QT3_SUPPORT) 776 }
else if (
depth == 8) {
778 }
else if (
depth == 32) {
780 }
else if (
depth == 24) {
782 }
else if (
depth == 16) {
845 qWarning(
"QImageData::create(): Invalid pixel size for format %i",
851 const int calc_bytes_per_line = ((width * depth + 31)/32) * 4;
852 const int min_bytes_per_line = (width * depth + 7)/8;
855 bpl = calc_bytes_per_line;
857 if (width <= 0 || height <= 0 || !data
862 || bpl < min_bytes_per_line
975 d =
QImageData::create(const_cast<uchar*>(data), width, height, bytesPerLine, format,
true);
1000 load(fileName, format);
1026 #ifndef QT_NO_CAST_FROM_ASCII 1038 #ifndef QT_NO_IMAGEFORMAT_XPM 1065 qWarning(
"QImage::QImage(), XPM is not supported");
1067 #endif // QT_NO_IMAGEFORMAT_XPM 1202 const int bytes_per_line = ((w*
depth+31)/32)*4;
1206 || bytes_per_line <= 0
1283 #endif // QT3_SUPPORT 1424 for (
int i = 0; i <
height(); i++)
1433 #ifndef QT_NO_IMAGE_TEXT 1446 if (w <= 0 || h <= 0)
1453 if (x < 0 || y < 0 || x + w >
d->
width || y + h >
d->
height) {
1468 int pixels_to_copy =
qMax(w - dx, 0);
1471 else if (pixels_to_copy >
d->
width - x)
1472 pixels_to_copy =
d->
width - x;
1473 int lines_to_copy =
qMax(h - dy, 0);
1476 else if (lines_to_copy >
d->
height - y)
1477 lines_to_copy =
d->
height - y;
1479 bool byteAligned =
true;
1481 byteAligned = !(dx & 7) && !(x & 7) && !(pixels_to_copy & 7);
1486 const int bytes_to_copy = (pixels_to_copy *
d->
depth) >> 3;
1487 for (
int i = 0; i < lines_to_copy; ++i) {
1488 memcpy(dest, src, bytes_to_copy);
1495 for (
int i = 0; i < lines_to_copy; ++i) {
1496 for (
int j = 0; j < pixels_to_copy; ++j) {
1497 if (src[(x + j) >> 3] & (0x80 >> ((x + j) & 7)))
1498 dest[(dx + j) >> 3] |= (0x80 >> ((dx + j) & 7));
1500 dest[(dx + j) >> 3] &= ~(0x80 >> ((dx + j) & 7));
1509 for (
int i = 0; i < lines_to_copy; ++i) {
1510 for (
int j = 0; j < pixels_to_copy; ++j) {
1511 if (src[(x + j) >> 3] & (0x1 << ((x + j) & 7)))
1512 dest[(dx + j) >> 3] |= (0x1 << ((dx + j) & 7));
1514 dest[(dx + j) >> 3] &= ~(0x1 << ((dx + j) & 7));
1525 #ifndef QT_NO_IMAGE_TEXT 1685 uchar **QImage::jumpTable()
1695 if (!
d->jumptable) {
1701 uchar **p =
d->jumptable;
1707 return d->jumptable;
1713 const uchar *
const *QImage::jumpTable()
const 1717 if (!
d->jumptable) {
1723 uchar **p =
d->jumptable;
1729 return d->jumptable;
1855 qWarning(
"QImage::setColor: Index out of bound %d", i);
2057 }
else if (
d->
depth == 16) {
2058 qt_rectfill<quint16>(
reinterpret_cast<quint16*
>(
d->
data), pixel,
2061 }
else if (
d->
depth == 24) {
2062 qt_rectfill<quint24>(
reinterpret_cast<quint24*
>(
d->
data), pixel,
2068 pixel |= 0xff000000;
2070 qt_rectfill<uint>(
reinterpret_cast<uint*
>(
d->
data), pixel,
2134 }
else if (
d->
depth == 1) {
2140 }
else if (
d->
depth == 8) {
2190 if (
depth() != 32) {
2195 for (
int y=0; y<
d->
height; ++y) {
2196 for (
int x=0; x<bpl; ++x)
2278 qWarning(
"QImage::setColorCount: null image");
2290 if (colorCount <= 0) {
2319 bool QImage::hasAlphaBuffer()
const 2348 void QImage::setAlphaBuffer(
bool enable)
2426 #endif // QT3_SUPPORT 2448 for (
int i = 0; i < src->
height; ++i) {
2450 while (src_data < end) {
2451 *dest_data =
PREMUL(*src_data);
2455 src_data += src_pad;
2456 dest_data += dest_pad;
2467 for (
int i = 0; i < data->
height; ++i) {
2469 while (rgb_data < end) {
2470 *rgb_data =
PREMUL(*rgb_data);
2482 const int depth = 32;
2484 const int dst_bytes_per_line = ((data->
width * depth + 31) >> 5) << 2;
2485 const int nbytes = dst_bytes_per_line * data->
height;
2490 data->
data = newData;
2497 const int dest_pad = (dst_bytes_per_line >> 2) - width;
2500 for (
int i = 0; i < 256; ++i)
2512 for (
int i = 0; i < data->
height; ++i) {
2513 src_data -= src_pad;
2514 dest_data -= dest_pad;
2515 for (
int pixI = 0; pixI <
width; ++pixI) {
2534 const int depth = 32;
2536 const int dst_bytes_per_line = ((data->
width * depth + 31) >> 5) << 2;
2537 const int nbytes = dst_bytes_per_line * data->
height;
2542 data->
data = newData;
2549 const int dest_pad = (dst_bytes_per_line >> 2) - width;
2552 for (
int i = 0; i < 256; ++i)
2561 for (
int i = 0; i < data->
height; ++i) {
2562 src_data -= src_pad;
2563 dest_data -= dest_pad;
2564 for (
int pixI = 0; pixI <
width; ++pixI) {
2583 const int depth = 16;
2585 const int dst_bytes_per_line = ((data->
width * depth + 31) >> 5) << 2;
2586 const int nbytes = dst_bytes_per_line * data->
height;
2591 data->
data = newData;
2598 const int dest_pad = (dst_bytes_per_line >> 1) - width;
2602 for (
int i = 0; i < 256; ++i)
2603 colorTableRGB16[i] = qt_colorConvert<quint16, quint32>(
qRgb(i, i, i), 0);
2607 for (
int i = 0; i < tableSize; ++i)
2608 colorTableRGB16[i] = qt_colorConvert<quint16, quint32>(data->
colortable.
at(i), 0);
2612 const quint16 lastColor = colorTableRGB16[tableSize - 1];
2613 for (
int i = tableSize; i < 256; ++i)
2614 colorTableRGB16[i] = lastColor;
2617 for (
int i = 0; i < data->
height; ++i) {
2618 src_data -= src_pad;
2619 dest_data -= dest_pad;
2620 for (
int pixI = 0; pixI <
width; ++pixI) {
2623 *dest_data = colorTableRGB16[*src_data];
2638 const int depth = 16;
2640 const int dst_bytes_per_line = ((data->
width * depth + 31) >> 5) << 2;
2645 for (
int i = 0; i < data->
height; ++i) {
2647 src_data = (
quint32 *) (((
char*)src_data) + src_bytes_per_line);
2648 dst_data = (
quint16 *) (((
char*)dst_data) + dst_bytes_per_line);
2656 data->
data = newData;
2675 for (
int i = 0; i < src->
height; ++i) {
2677 while (src_data < end) {
2682 src_data += src_pad;
2683 dest_data += dest_pad;
2699 for (
int i = 0; i < src->
height; ++i) {
2701 while (src_data < end) {
2702 *dest_data = 0xff000000 |
INV_PREMUL(*src_data);
2706 src_data += src_pad;
2707 dest_data += dest_pad;
2725 while (src_data < end) {
2726 *dest_data =
bitflip[*src_data];
2742 for (
int i = 0; i < src->
height; ++i) {
2744 while (src_data < end) {
2745 *dest_data = *src_data | 0xff000000;
2749 src_data += src_pad;
2750 dest_data += dest_pad;
2759 for (
int i = 0; i < colorTable.
size(); ++i)
2760 if (
qAlpha(colorTable.
at(i) != 0xff))
2761 colorTable[i] = colorTable.
at(i) | 0xff000000;
2764 for (
int i = 0; i < colorTable.
size(); ++i)
2765 colorTable[i] =
PREMUL(colorTable.
at(i));
2775 Qt::ImageConversionFlags flags,
bool fromalpha)
2785 enum { Threshold, Ordered, Diffuse } dithermode;
2789 dithermode = Diffuse;
2791 dithermode = Ordered;
2793 dithermode = Threshold;
2796 dithermode = Threshold;
2798 dithermode = Ordered;
2800 dithermode = Diffuse;
2807 bool use_gray = (d == 8);
2827 switch (dithermode) {
2830 int *line1 = lineBuffer.
data();
2831 int *line2 = lineBuffer.
data() + w;
2832 int bmwidth = (w+7)/8;
2835 int wbytes = w * (d/8);
2845 *b2++ = 255 - (*(
uint*)p >> 24);
2855 for (
int y=0; y<h; y++) {
2856 int *tmp = line1; line1 = line2; line2 = tmp;
2857 bool not_last_line = y < h - 1;
2858 if (not_last_line) {
2868 *b2++ = 255 - (*(
uint*)p >> 24);
2882 memset(p, 0, bmwidth);
2886 for (
int x=1; x<=w; x++) {
2901 if (not_last_line) {
2902 b2[0] += (err*5)>>4;
2904 b2[-1] += (err*3)>>4;
2916 for (
int i=0; i<h; i++) {
2917 const uint *p = (
const uint *)src_data;
2919 uchar *m = dst_data;
2945 dst_data += dst_bpl;
2946 src_data += src_bpl;
2950 for (
int i=0; i<h; i++) {
2951 const uchar *p = src_data;
2953 uchar *m = dst_data;
2966 dst_data += dst_bpl;
2967 src_data += src_bpl;
2974 for (
int i=0; i<h; i++) {
2975 const uint *p = (
const uint *)src_data;
2977 uchar *m = dst_data;
2981 if ((*p++ >> 24) >= 128)
2992 if (
qGray(*p++) < 128)
3002 dst_data += dst_bpl;
3003 src_data += src_bpl;
3007 for (
int i=0; i<h; i++) {
3008 const uchar *p = src_data;
3010 uchar *m = dst_data;
3013 if (gray[*p++] < 128)
3022 dst_data += dst_bpl;
3023 src_data += src_bpl;
3035 for (
int x=0; x<bpl; ++x) {
3082 const int tablesize = 997;
3093 QRgb p = ctbl.
at(i) | alpha_mask;
3094 int hash = p % tablesize;
3096 if (table[hash].used) {
3097 if (table[hash].
rgb == p) {
3102 if (++hash == tablesize) hash = 0;
3109 table[
hash].pix = pix++;
3110 table[
hash].rgb = p;
3111 table[
hash].used = 1;
3122 for (
int y = 0; y < src->
height; y++) {
3123 const QRgb *s = (
const QRgb *)src_data;
3124 uchar *b = dest_data;
3125 for (
int x = 0; x < src->
width; ++x) {
3126 QRgb p = s[x] | alpha_mask;
3127 int hash = p % tablesize;
3129 if (table[hash].used) {
3130 if (table[hash].
rgb == (p)) {
3135 if (++hash == tablesize) hash = 0;
3147 table[
hash].pix = pix++;
3148 table[
hash].rgb = p;
3149 table[
hash].used = 1;
3154 *b++ = table[
hash].pix;
3169 #define INDEXOF(r,g,b) (((r)*(MAX_G+1)+(g))*(MAX_B+1)+(b)) 3171 for (
int rc=0; rc<=
MAX_R; rc++)
3172 for (
int gc=0; gc<=
MAX_G; gc++)
3173 for (
int bc=0; bc<=
MAX_B; bc++)
3179 for (
int y = 0; y < src->
height; y++) {
3180 const QRgb *p = (
const QRgb *)src_data;
3182 uchar *b = dest_data;
3185 #define DITHER(p,m) ((uchar) ((p * (m) + 127) / 255)) 3203 line1[0] = lineBuffer.
data();
3204 line2[0] = lineBuffer.
data() + src->
width;
3205 line1[1] = lineBuffer.
data() + src->
width * 2;
3206 line2[1] = lineBuffer.
data() + src->
width * 3;
3207 line1[2] = lineBuffer.
data() + src->
width * 4;
3208 line2[2] = lineBuffer.
data() + src->
width * 5;
3209 pv[0] = lineBuffer.
data() + src->
width * 6;
3210 pv[1] = lineBuffer.
data() + src->
width * 7;
3211 pv[2] = lineBuffer.
data() + src->
width * 8;
3213 int endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian);
3214 for (
int y = 0; y < src->
height; y++) {
3215 const uchar* q = src_data;
3217 uchar *b = dest_data;
3218 for (
int chan = 0; chan < 3; chan++) {
3219 int *l1 = (y&1) ? line2[chan] : line1[chan];
3220 int *l2 = (y&1) ? line1[chan] : line2[chan];
3222 for (
int i = 0; i < src->
width; i++)
3223 l1[i] = q[i*4+chan+endian];
3226 for (
int i = 0; i < src->
width; i++)
3227 l2[i] = q2[i*4+chan+endian];
3231 for (
int x = 0; x < src->
width; x++) {
3232 int pix =
qMax(
qMin(5, (l1[x] * 5 + 128)/ 255), 0);
3233 int err = l1[x] - pix * 255 / 5;
3237 if (x + 1< src->
width) {
3238 l1[x+1] += (err*7)>>4;
3243 l2[x-1]+=(err*3)>>4;
3246 for (
int x = src->
width; x-- > 0;) {
3247 int pix =
qMax(
qMin(5, (l1[x] * 5 + 128)/ 255), 0);
3248 int err = l1[x] - pix * 255 / 5;
3253 l1[x-1] += (err*7)>>4;
3257 if (x + 1 < src->
width)
3258 l2[x+1]+=(err*3)>>4;
3263 for (
int x = 0; x < src->
width; x++) {
3264 *b++ =
INDEXOF(pv[0][x],pv[1][x],pv[2][x]);
3267 for (
int x = 0; x < src->
width; x++) {
3268 *b++ =
INDEXOF(pv[2][x],pv[1][x],pv[0][x]);
3275 for (
int y = 0; y < src->
height; y++) {
3276 const QRgb *p = (
const QRgb *)src_data;
3278 uchar *b = dest_data;
3284 #define DITHER(p, d, m) ((uchar) ((((256 * (m) + (m) + 1)) * (p) + (d)) >> 16)) 3303 const int trans = 216;
3310 for (
int y = 0; y < src->
height; y++) {
3311 for (
int x = 0; x < src->
width ; x++) {
3312 if (!(mask_data[x>>3] & (0x80 >> (x & 7))))
3313 dst_data[x] = trans;
3351 if (colorTable.
size() == 0) {
3353 for (
int i=0; i<256; ++i)
3354 colorTable[i] =
qRgb(i, i, i);
3360 int tableSize = colorTable.
size() - 1;
3361 for (
int y = 0; y < src->
height; y++) {
3363 const uchar *b = src_data;
3367 *p++ = colorTable.
at(qMin<int>(tableSize, *b++));
3386 if (colorTable.
size() < 2) {
3387 if (colorTable.
size() == 0)
3388 colorTable << 0xff000000;
3389 colorTable << 0xffffffff;
3395 for (
int y = 0; y < dest->
height; y++) {
3396 register uint *p = (
uint *)dest_data;
3397 for (
int x = 0; x < dest->
width; x++)
3398 *p++ = colorTable.
at((src_data[x>>3] >> (7 - (x & 7))) & 1);
3404 for (
int y = 0; y < dest->
height; y++) {
3405 register uint *p = (
uint *)dest_data;
3406 for (
int x = 0; x < dest->
width; x++)
3407 *p++ = colorTable.
at((src_data[x>>3] >> (x & 7)) & 1);
3424 if (ctbl.
size() > 2) {
3426 }
else if (ctbl.
size() < 2) {
3427 if (ctbl.
size() == 0)
3438 for (
int y = 0; y < dest->
height; y++) {
3439 register uchar *p = dest_data;
3440 for (
int x = 0; x < dest->
width; x++)
3441 *p++ = (src_data[x>>3] >> (7 - (x & 7))) & 1;
3446 for (
int y = 0; y < dest->
height; y++) {
3447 register uchar *p = dest_data;
3448 for (
int x = 0; x < dest->
width; x++)
3449 *p++ = (src_data[x>>3] >> (x & 7)) & 1;
3456 #define CONVERT_DECL(DST, SRC) \ 3457 static void convert_##SRC##_to_##DST(QImageData *dest, \ 3458 const QImageData *src, \ 3459 Qt::ImageConversionFlags) \ 3461 qt_rectconvert<DST, SRC>(reinterpret_cast<DST*>(dest->data), \ 3462 reinterpret_cast<const SRC*>(src->data), \ 3463 0, 0, src->width, src->height, \ 3464 dest->bytes_per_line, src->bytes_per_line); \ 3477 #if !defined(Q_WS_QWS) || (defined(QT_QWS_DEPTH_15) && defined(QT_QWS_DEPTH_16)) 3490 #define CONVERT_PTR(DST, SRC) convert_##SRC##_to_##DST 3516 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3644 #if !defined(Q_WS_QWS) || (defined(QT_QWS_DEPTH_15) && defined(QT_QWS_DEPTH_16)) 3720 #if !defined(Q_WS_QWS) || (defined(QT_QWS_DEPTH_15) && defined(QT_QWS_DEPTH_16)) 3815 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3818 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3821 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3878 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3881 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3884 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3887 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3890 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3893 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3896 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3899 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3902 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3905 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3915 if (features &
SSE2) {
3916 extern bool convert_ARGB_to_ARGB_PM_inplace_sse2(
QImageData *
data, Qt::ImageConversionFlags);
3920 #ifdef QT_HAVE_SSSE3 3921 if (features &
SSSE3) {
3922 extern void convert_RGB888_to_RGB32_ssse3(
QImageData *dest,
const QImageData *src, Qt::ImageConversionFlags);
3929 if (features &
NEON) {
3930 extern void convert_RGB888_to_RGB32_neon(
QImageData *dest,
const QImageData *src, Qt::ImageConversionFlags);
3944 int w = image->
width();
3946 for (
int y=0; y<h; ++y) {
3948 for (
int x=0; x<w; ++x) {
3950 uint r = qt_pow_rgb_gamma[
qRed(p)];
3953 pixels[x] = (r << 16) | (g << 8) | b | 0xff000000;
3984 #if !defined(QT_NO_IMAGE_TEXT) 3986 #endif // !QT_NO_IMAGE_TEXT 3988 converter(image.
d,
d, flags);
4012 return abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2) + abs(a1 - a2);
4017 int current_distance =
INT_MAX;
4018 for (
int i=0; i<clut.
size(); ++i) {
4020 if (dist < current_distance) {
4021 current_distance = dist;
4032 dest.setColorTable(clut);
4034 #if !defined(QT_NO_IMAGE_TEXT) 4037 foreach (
const QString &textKey, textKeyList) {
4039 dest.setText(textKeySplitted[0], textKeySplitted[1]);
4041 #endif // !QT_NO_IMAGE_TEXT 4044 int w = src.
width();
4049 for (
int y=0; y<h; ++y) {
4051 uchar *dest_pixels = (
uchar *) dest.scanLine(y);
4052 for (
int x=0; x<w; ++x) {
4053 int src_pixel = src_pixels[x];
4054 int value = cache.
value(src_pixel, -1);
4057 cache.
insert(src_pixel, value);
4059 dest_pixels[x] = (
uchar) value;
4065 for (
int y=0; y<h; ++y) {
4067 for (
int x=0; x<w; ++x) {
4068 int src_pixel = src_pixels[x];
4069 int value = cache.
value(src_pixel, -1);
4072 cache.
insert(src_pixel, value);
4074 dest.setPixel(x, y, value);
4112 #if !defined(QT_NO_IMAGE_TEXT) 4114 #endif // !QT_NO_IMAGE_TEXT 4116 converter(image.
d,
d, flags);
4134 QImage QImage::convertDepth(
int depth, Qt::ImageConversionFlags flags)
const 4139 Format format = formatFor (depth, QImage::LittleEndian);
4168 && x >= 0 && x <
d->
width 4196 if (!
d || x < 0 || x >=
d->
width || y < 0 || y >=
height()) {
4197 qWarning(
"QImage::pixelIndex: coordinate (%d,%d) out of range", x, y);
4203 return (*(s + (x >> 3)) >> (7- (x & 7))) & 1;
4205 return (*(s + (x >> 3)) >> (x & 7)) & 1;
4209 qWarning(
"QImage::pixelIndex: Not applicable for %d-bpp images (no palette)",
d->
depth);
4242 if (!
d || x < 0 || x >=
d->
width || y < 0 || y >=
height()) {
4243 qWarning(
"QImage::pixel: coordinate (%d,%d) out of range", x, y);
4249 return d->
colortable.
at((*(s + (x >> 3)) >> (7- (x & 7))) & 1);
4255 return qt_colorConvert<quint32, qargb8565>(
reinterpret_cast<const qargb8565*
>(s)[x], 0);
4257 return qt_colorConvert<quint32, qrgb666>(
reinterpret_cast<const qrgb666*
>(s)[x], 0);
4259 return qt_colorConvert<quint32, qargb6666>(
reinterpret_cast<const qargb6666*
>(s)[x], 0);
4261 return qt_colorConvert<quint32, qrgb555>(
reinterpret_cast<const qrgb555*
>(s)[x], 0);
4263 return qt_colorConvert<quint32, qargb8555>(
reinterpret_cast<const qargb8555*
>(s)[x], 0);
4265 return qt_colorConvert<quint32, qrgb888>(
reinterpret_cast<const qrgb888*
>(s)[x], 0);
4267 return qt_colorConvert<quint32, qrgb444>(
reinterpret_cast<const qrgb444*
>(s)[x], 0);
4269 return qt_colorConvert<quint32, qargb4444>(
reinterpret_cast<const qargb4444*
>(s)[x], 0);
4271 return qt_colorConvert<quint32, quint16>(
reinterpret_cast<const quint16*
>(s)[x], 0);
4273 return ((
QRgb*)s)[x];
4313 if (!
d || x < 0 || x >=
width() || y < 0 || y >=
height()) {
4314 qWarning(
"QImage::setPixel: coordinate (%d,%d) out of range", x, y);
4320 qWarning(
"setPixel: Out of memory");
4327 if (index_or_rgb > 1) {
4328 qWarning(
"QImage::setPixel: Index %d out of range", index_or_rgb);
4330 if (index_or_rgb==0)
4331 *(s + (x >> 3)) &= ~(1 << (x & 7));
4333 *(s + (x >> 3)) |= (1 << (x & 7));
4335 if (index_or_rgb==0)
4336 *(s + (x >> 3)) &= ~(1 << (7-(x & 7)));
4338 *(s + (x >> 3)) |= (1 << (7-(x & 7)));
4343 qWarning(
"QImage::setPixel: Index %d out of range", index_or_rgb);
4346 s[x] = index_or_rgb;
4351 ((
uint *)s)[x] =
uint(255 << 24) | index_or_rgb;
4355 ((
uint *)s)[x] = index_or_rgb;
4358 ((
quint16 *)s)[x] = qt_colorConvert<quint16, quint32p>(p, 0);
4361 ((
qargb8565*)s)[x] = qt_colorConvert<qargb8565, quint32p>(p, 0);
4364 ((
qrgb666*)s)[x] = qt_colorConvert<qrgb666, quint32p>(p, 0);
4367 ((
qargb6666*)s)[x] = qt_colorConvert<qargb6666, quint32p>(p, 0);
4370 ((
qrgb555*)s)[x] = qt_colorConvert<qrgb555, quint32p>(p, 0);
4373 ((
qargb8555*)s)[x] = qt_colorConvert<qargb8555, quint32p>(p, 0);
4376 ((
qrgb888*)s)[x] = qt_colorConvert<qrgb888, quint32p>(p, 0);
4379 ((
qrgb444*)s)[x] = qt_colorConvert<qrgb444, quint32p>(p, 0);
4382 ((
qargb4444*)s)[x] = qt_colorConvert<qargb4444, quint32p>(p, 0);
4403 if (!
d ||
isNull() ||
d->
depth != 1 || !(bitOrder == BigEndian || bitOrder == LittleEndian))
4446 }
else if (
d->
depth == 16) {
4450 if (!
qIsGray(qt_colorConvert<quint32, quint16>(*b++, 0)))
4456 if (!
qIsGray(qt_colorConvert<quint32, qrgb888>(*b++, 0)))
4580 qWarning(
"QImage::scaled: Image is a null image");
4587 newSize.
scale(s, aspectMode);
4590 if (newSize ==
size())
4618 qWarning(
"QImage::scaleWidth: Image is a null image");
4649 qWarning(
"QImage::scaleHeight: Image is a null image");
4737 #ifndef QT_NO_IMAGE_HEURISTIC_MASK 4772 #define PIX(x,y) (*((QRgb*)scanLine(y)+x) & 0x00ffffff) 4784 if (background !=
PIX(w-1,0) &&
4785 background !=
PIX(0,h-1) &&
4786 background !=
PIX(w-1,h-1)) {
4787 background =
PIX(w-1,0);
4788 if (background !=
PIX(w-1,h-1) &&
4789 background !=
PIX(0,h-1) &&
4790 PIX(0,h-1) ==
PIX(w-1,h-1)) {
4791 background =
PIX(w-1,h-1);
4797 uchar *ypp, *ypc, *ypn;
4802 for (y = 0; y < h; y++) {
4805 ypn = (y == h-1) ? 0 : m.
scanLine(y+1);
4807 for (x = 0; x < w; x++) {
4810 if ((x == 0 || y == 0 || x == w-1 || y == h-1 ||
4811 !(*(ypc + ((x-1) >> 3)) & (1 << ((x-1) & 7))) ||
4812 !(*(ypc + ((x+1) >> 3)) & (1 << ((x+1) & 7))) ||
4813 !(*(ypp + (x >> 3)) & (1 << (x & 7))) ||
4814 !(*(ypn + (x >> 3)) & (1 << (x & 7)))) &&
4815 ( (*(ypc + (x >> 3)) & (1 << (x & 7)))) &&
4816 ((*p & 0x00ffffff) == background)) {
4818 *(ypc + (x >> 3)) &= ~(1 << (x & 7));
4828 for (y = 0; y < h; y++) {
4831 ypn = (y == h-1) ? 0 : m.
scanLine(y+1);
4833 for (x = 0; x < w; x++) {
4834 if ((*p & 0x00ffffff) != background) {
4836 *(ypc + ((x-1) >> 3)) |= (1 << ((x-1) & 7));
4838 *(ypc + ((x+1) >> 3)) |= (1 << ((x+1) & 7));
4840 *(ypp + (x >> 3)) |= (1 << (x & 7));
4842 *(ypn + (x >> 3)) |= (1 << (x & 7));
4853 #endif //QT_NO_IMAGE_HEURISTIC_MASK 4874 if (
depth() == 32) {
4875 for (
int h = 0; h <
d->
height; h++) {
4877 for (
int w = 0; w <
d->
width; w++) {
4879 *(s + (w >> 3)) |= (1 << (w & 7));
4884 for (
int h = 0; h <
d->
height; h++) {
4885 for (
int w = 0; w <
d->
width; w++) {
4887 *(s + (w >> 3)) |= (1 << (w & 7));
4927 if ((
d->
width <= 1 &&
d->
height <= 1) || (!horizontal && !vertical))
4945 int dxi = horizontal ? -1 : 1;
4946 int dxs = horizontal ? w-1 : 0;
4947 int dyi = vertical ? -1 : 1;
4948 int dy = vertical ? h-1: 0;
4952 for (
int sy = 0; sy < h; sy++, dy += dyi) {
4956 for (
int sx = 0; sx < w; sx++, dx += dxi)
4961 else if (
d->
depth == 16) {
4962 for (
int sy = 0; sy < h; sy++, dy += dyi) {
4966 for (
int sx = 0; sx < w; sx++, dx += dxi)
4971 else if (
d->
depth == 24) {
4972 for (
int sy = 0; sy < h; sy++, dy += dyi) {
4976 for (
int sx = 0; sx < w; sx++, dx += dxi)
4981 else if (
d->
depth == 32) {
4982 for (
int sy = 0; sy < h; sy++, dy += dyi) {
4986 for (
int sx = 0; sx < w; sx++, dx += dxi)
4992 if (horizontal &&
d->
depth == 1) {
4994 for (
int y = h-1; y >= 0; y--) {
5009 *a = (*a >> (8-
shift)) |
c;
5016 *a = (*a << (8-
shift)) |
c;
5069 res.
d->
colortable[i] =
QRgb(((c << 16) & 0xff0000) | ((c >> 16) & 0xff) | (c & 0xff00ff00));
5077 for (
int i = 0; i <
d->
height; i++) {
5082 *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | (*p & 0xff00ff00);
5091 for (
int i = 0; i <
d->
height; i++) {
5096 *q = ((*p << 11) & 0xf800) | ((*p >> 11) & 0x1f) | (*p & 0x07e0);
5105 for (
int i = 0; i <
d->
height; i++) {
5111 q[1] = (p[1] & 0xe0) | (p[2] >> 3);
5112 q[2] = (p[2] & 0x07) | (p[1] << 3);
5121 for (
int i = 0; i <
d->
height; i++) {
5134 for (
int i = 0; i <
d->
height; i++) {
5139 q[0] = (p[1] >> 4) | ((p[2] & 0x3) << 4) | (p[0] & 0xc0);
5140 q[1] = (p[1] & 0xf) | (p[0] << 4);
5141 q[2] = (p[2] & 0xfc) | ((p[0] >> 4) & 0x3);
5150 for (
int i = 0; i <
d->
height; i++) {
5155 *q = ((*p << 10) & 0x7c00) | ((*p >> 10) & 0x1f) | (*p & 0x3e0);
5164 for (
int i = 0; i <
d->
height; i++) {
5170 q[1] = (p[1] & 0xe0) | (p[2] >> 2);
5171 q[2] = (p[2] & 0x03) | ((p[1] << 2) & 0x7f);
5180 for (
int i = 0; i <
d->
height; i++) {
5197 for (
int i = 0; i <
d->
height; i++) {
5202 *q = (*p & 0xf0f0) | ((*p & 0x0f) << 8) | ((*p & 0xf00) >> 8);
5381 if (quality > 100 || quality < -1)
5382 qWarning(
"QPixmap::save: Quality out of range [-1, 100]");
5385 return writer->
write(*image);
5391 #if !defined(QT_NO_DATASTREAM) 5418 writer.
write(image);
5448 #endif // QT_NO_DATASTREAM 5474 QImage QImage::convertDepthWithPalette(
int d,
QRgb* palette,
int palette_count, Qt::ImageConversionFlags flags)
const 5476 Format f = formatFor(d, QImage::LittleEndian);
5478 for (
int i = 0; i < palette_count; ++i)
5479 colortable.
append(palette[i]);
5505 void bitBlt(
QImage *dst,
int dx,
int dy,
const QImage *src,
int sx,
int sy,
int sw,
int sh,
5506 Qt::ImageConversionFlags flags)
5545 const int n = d->width * d->depth / 8;
5547 if (memcmp(
bits(), i.
bits(), d->nbytes))
5550 for (
int y = 0; y < d->height; ++y) {
5556 const int w =
width();
5560 for (
int y=0; y<h; ++y) {
5561 for (
int x=0; x<w; ++x) {
5569 for(
int l = 0;
l < d->height;
l++) {
5574 if ((*p1++ & 0x00ffffff) != (*p2++ & 0x00ffffff))
5601 return !(*
this == i);
5617 return d ?
qRound(d->dpmx) : 0;
5630 return d ?
qRound(d->dpmy) : 0;
5690 return d ? d->offset :
QPoint();
5714 #ifndef QT_NO_IMAGE_TEXT 5742 return d->text.value(key);
5745 foreach (
const QString &key, d->text.keys()) {
5748 tmp += key +
QLatin1String(
": ") + d->text.value(key).simplified();
5787 d->text.insert(key, value);
5809 return d->text.value(k);
5834 return d->text.value(k);
5856 for (
int i = 0; i < keys.
size(); ++i) {
5859 languages += keys.
at(i).
mid(index+1);
5883 return imageTextKeys;
5885 for (
int i = 0; i < keys.
size(); ++i) {
5891 imageTextKeys += tkl;
5895 return imageTextKeys;
5933 d->text.insert(k, s);
5936 #endif // QT_NO_IMAGE_TEXT 5975 if (!d->paintEngine) {
5977 d->paintEngine =
new QSymbianRasterPaintEngine(const_cast<QImage *>(
this));
5983 return d->paintEngine;
6010 return qRound(d->width * 1000 / d->dpmx);
6014 return qRound(d->height * 1000 / d->dpmy);
6018 return d->colortable.size();
6026 return qRound(d->dpmx * 0.0254);
6030 return qRound(d->dpmy * 0.0254);
6034 return qRound(d->dpmx * 0.0254);
6038 return qRound(d->dpmy * 0.0254);
6042 qWarning(
"QImage::metric(): Unhandled metric type %d", metric);
6074 #define IWX_MSB(b) if (trigx < maxws && trigy < maxhs) { \ 6075 if (*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \ 6076 (1 << (7-((trigx>>12)&7)))) \ 6083 #define IWX_LSB(b) if (trigx < maxws && trigy < maxhs) { \ 6084 if (*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \ 6085 (1 << ((trigx>>12)&7))) \ 6092 #define IWX_PIX(b) if (trigx < maxws && trigy < maxhs) { \ 6093 if ((*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \ 6094 (1 << (7-((trigx>>12)&7)))) == 0) \ 6101 uchar *dptr,
int dbpl,
int p_inc,
int dHeight,
6102 const uchar *sptr,
int sbpl,
int sWidth,
int sHeight)
6104 int m11 = int(trueMat.
m11()*
qreal(4096.0));
6105 int m12 = int(trueMat.
m12()*
qreal(4096.0));
6106 int m21 = int(trueMat.
m21()*
qreal(4096.0));
6107 int m22 = int(trueMat.
m22()*
qreal(4096.0));
6111 int m21ydx = dx + (xoffset<<16) + (m11 + m21) / 2;
6112 int m22ydy = dy + (m12 + m22) / 2;
6115 uint maxws = sWidth<<12;
6116 uint maxhs = sHeight<<12;
6118 for (
int y=0; y<dHeight; y++) {
6121 uchar *maxp = dptr + dbpl;
6125 while (dptr < maxp) {
6126 if (trigx < maxws && trigy < maxhs)
6127 *dptr = *(sptr+sbpl*(trigy>>12)+(trigx>>12));
6135 while (dptr < maxp) {
6136 if (trigx < maxws && trigy < maxhs)
6137 *((
ushort*)dptr) = *((
ushort *)(sptr+sbpl*(trigy>>12) +
6147 while (dptr < maxp) {
6148 if (trigx < maxws && trigy < maxhs) {
6149 const uchar *p2 = sptr+sbpl*(trigy>>12) + ((trigx>>12)*3);
6161 while (dptr < maxp) {
6162 if (trigx < maxws && trigy < maxhs)
6163 *((
uint*)dptr) = *((
uint *)(sptr+sbpl*(trigy>>12) +
6178 while (dptr < maxp) {
6191 while (dptr < maxp) {
6203 # if defined(Q_WS_WIN) 6205 while (dptr < maxp) {
6287 return (((
qint64) d->ser_no) << 32) | ((
qint64) d->detach_no);
6303 return d && d->ref == 1;
6337 if (w != alphaChannel.
d->
width || h != alphaChannel.
d->
height) {
6338 qWarning(
"QImage::setAlphaChannel: " 6339 "Alpha channel must have same dimensions as the target image");
6343 if (d->paintEngine && d->paintEngine->isActive()) {
6344 qWarning(
"QImage::setAlphaChannel: " 6345 "Unable to set alpha channel while image is being painted on");
6359 const uchar *src_data = alphaChannel.
d->
data;
6360 const uchar *dest_data = d->data;
6361 for (
int y=0; y<h; ++y) {
6362 const uchar *src = src_data;
6364 for (
int x=0; x<w; ++x) {
6367 *dest = ((destAlpha << 24)
6375 dest_data += d->bytes_per_line;
6380 if (sourceImage.
isNull()) {
6381 qWarning(
"QImage::setAlphaChannel: out of memory");
6385 const uchar *dest_data = d->data;
6386 for (
int y=0; y<h; ++y) {
6387 const QRgb *src = (
const QRgb *) src_data;
6389 for (
int x=0; x<w; ++x) {
6390 int alpha =
qGray(*src);
6392 *dest = ((destAlpha << 24)
6400 dest_data += d->bytes_per_line;
6443 for (
int i=0; i<256; ++i)
6452 const uchar *src_data = d->data;
6454 for (
int y=0; y<h; ++y) {
6455 const uchar *src = src_data;
6456 uchar *dest = dest_data;
6457 for (
int x=0; x<w; ++x) {
6458 *dest =
qAlpha(d->colortable.at(*src));
6462 src_data += d->bytes_per_line;
6473 for (
int y=0; y<h; ++y) {
6474 const QRgb *src = (
const QRgb *) src_data;
6475 uchar *dest = dest_data;
6476 for (
int x=0; x<w; ++x) {
6528 switch (d->format) {
6555 #if defined(Q_WS_X11) 6557 #include <private/qt_x11_p.h> 6563 #if defined(Q_WS_X11) 6564 return BitmapBitOrder(
X11->display) == MSBFirst ? BigEndian : LittleEndian;
6615 else if (src.
depth() < 32) {
6631 int w = image.
width();
6633 switch (image.
format()) {
6639 reinterpret_cast<quint32*
>(out.bits()),
6640 out.bytesPerLine());
6649 reinterpret_cast<quint24*
>(out.bits()),
6650 out.bytesPerLine());
6657 reinterpret_cast<quint16*
>(out.bits()),
6658 out.bytesPerLine());
6663 reinterpret_cast<quint8*
>(out.bits()),
6664 out.bytesPerLine());
6667 for (
int y=0; y<h; ++y) {
6669 for (
int x=0; x<w; ++x)
6670 out.setPixel(h-y-1, x, image.
pixelIndex(x, y));
6672 for (
int x=0; x<w; ++x)
6673 out.setPixel(h-y-1, x, image.
pixel(x, y));
6691 int w = image.
width();
6693 switch (image.
format()) {
6699 reinterpret_cast<quint32*
>(out.bits()),
6700 out.bytesPerLine());
6709 reinterpret_cast<quint24*
>(out.bits()),
6710 out.bytesPerLine());
6717 reinterpret_cast<quint16*
>(out.bits()),
6718 out.bytesPerLine());
6723 reinterpret_cast<quint8*
>(out.bits()),
6724 out.bytesPerLine());
6727 for (
int y=0; y<h; ++y) {
6729 for (
int x=0; x<w; ++x)
6730 out.setPixel(y, w-x-1, image.
pixelIndex(x, y));
6732 for (
int x=0; x<w; ++x)
6733 out.setPixel(y, w-x-1, image.
pixel(x, y));
6772 bool complex_xform =
false;
6773 bool scale_xform =
false;
6777 else if (mat.
m11() == -1. && mat.
m22() == -1.)
6784 hd = int(
qAbs(mat.
m22()) * hs + 0.9999);
6785 wd = int(
qAbs(mat.
m11()) * ws + 0.9999);
6790 if (mat.
m12() == 1. && mat.
m21() == -1.)
6792 else if (mat.
m12() == -1. && mat.
m21() == 1.)
6801 complex_xform =
true;
6804 if (wd == 0 || hd == 0)
6809 if (mat.
m11() < 0.0F && mat.
m22() < 0.0F) {
6811 }
else if (mat.
m11() < 0.0F) {
6813 }
else if (mat.
m22() < 0.0F) {
6849 QImage dImage(wd, hd, target_format);
6898 qt_xForm_helper(mat, 0, type, bpp, dImage.
bits(), dbpl, 0, hd, sptr, sbpl,
ws, hs);
6947 return converter(
this, flags);
The QVariant class acts like a union for the most common Qt data types.
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
QRect toAlignedRect() const
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle...
static uint hash(const uchar *p, int n)
QDataStream & operator>>(QDataStream &stream, QImage &image)
Reads an image from the given stream and stores it in the given image.
static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
Format
The following image formats are available in Qt.
static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
static QVector< QRgb > fix_color_table(const QVector< QRgb > &ctbl, QImage::Format format)
const uchar * qt_get_bitflip_array()
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
void setColor(int i, QRgb c)
Sets the color at the given index in the color table, to the given to colorValue. ...
#define CONVERT_PTR(DST, SRC)
static bool convert_ARGB_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags)
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
static void convert_ARGB_PM_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
#define QT_END_NAMESPACE
This macro expands to.
static void convert_ARGB_to_ARGB_PM(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
Q_CORE_EXPORT QTextStream & ws(QTextStream &s)
uchar qt_pow_rgb_gamma[256]
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
static QImage rotated180(const QImage &src)
QT_DEPRECATED void setNumColors(int)
Resizes the color table to contain numColors entries.
T * data() const
Returns the value of the pointer referenced by this object.
void setColorTable(const QVector< QRgb > colors)
Sets the color table used to translate color indexes to QRgb values, to the specified colors...
The QMatrix class specifies 2D transformations of a coordinate system.
static void convert_Mono_to_Indexed8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
Q_GUI_EXPORT_INLINE int qAlpha(QRgb rgb)
void setData(const QByteArray &data)
Sets the contents of the internal buffer to be data.
static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags)
Q_GUI_EXPORT int qt_defaultDpiY()
static void convert_RGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
bool open(OpenMode openMode)
Reimplemented Function
bool isNull() const
Returns true if it is a null image, otherwise returns false.
void fill(uint pixel)
Fills the entire image with the given pixelValue.
The QByteArray class provides an array of bytes.
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
Q_GUI_EXPORT int qt_defaultDpiX()
T * take()
Returns the value of the pointer referenced by this object.
InvertMode
This enum type is used to describe how pixel values should be inverted in the invertPixels() function...
virtual int metric(PaintDeviceMetric metric) const
Returns the size for the specified metric on the device.
QT_DEPRECATED QStringList textLanguages() const
Returns the language identifiers for which some texts are recorded.
bool save(const QString &fileName, const char *format=0, int quality=-1) const
Saves the image to the file with the given fileName, using the given image file format and quality fa...
int byteCount() const
Returns the number of bytes occupied by the image data.
void setQuality(int quality)
This is an image format specific function that sets the quality level of the image to quality...
int width() const
Returns the width of the rectangle.
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int bytesPerLine() const
Returns the number of bytes per image scanline.
long ASN1_INTEGER_get ASN1_INTEGER * a
void qGamma_correct_back_to_linear_cs(QImage *image)
int dotsPerMeterY() const
Returns the number of pixels that fit vertically in a physical meter.
bool ref()
Atomically increments the value of this QAtomicInt.
The QBuffer class provides a QIODevice interface for a QByteArray.
int height() const
Returns the height of the rectangle.
static void convert_ARGB_PM_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
The QString class provides a Unicode character string.
static void swap_bit_order(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
The QHash class is a template class that provides a hash-table-based dictionary.
QImage rgbSwapped() const
Returns a QImage in which the values of the red and blue components of all pixels have been swapped...
Q_DECL_CONSTEXPR T qAbs(const T &t)
QRectF boundingRect() const
Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty...
QVector< QRgb > colortable
#define Q_BASIC_ATOMIC_INITIALIZER(a)
void Q_GUI_EXPORT qt_memrotate90(const quint32 *, int, int, int, quint32 *, int)
QRgb pixel(int x, int y) const
Returns the color of the pixel at coordinates (x, y).
void qInitImageConversions()
QPoint offset() const
Returns the number of pixels by which the image is intended to be offset by when positioning relative...
Format format() const
Returns the format of the image.
const T value(const Key &key) const
Returns the value associated with the key.
bool load(QIODevice *device, const char *format)
This function reads a QImage from the given device.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
QImage()
Constructs a null image.
bool paintingActive() const
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
void resize(int size)
Sets the size of the vector to size.
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
static QImageData * create(const QSize &size, QImage::Format format, int numColors=0)
QFuture< T > mapped(const Sequence &sequence, MapFunction function)
int pixelIndex(int x, int y) const
Returns the pixel index at (x, y).
static void dither_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags, bool fromalpha)
void setOffset(const QPoint &)
Sets the number of pixels by which the image is intended to be offset by when positioning relative to...
int width() const
Returns the width.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
static void executeImageHooks(qint64 key)
static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversionFlags)
void setColorCount(int)
Resizes the color table to contain colorCount entries.
static int pixel_distance(QRgb p1, QRgb p2)
static void convert_ARGB_PM_to_ARGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QT_DEPRECATED int numBytes() const
Returns the number of bytes occupied by the image data.
The QRectF class defines a rectangle in the plane using floating point precision. ...
static bool checkPixelSize(const QImage::Format format)
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void setText(const QString &key, const QString &value)
Sets the image text to the given text and associate it with the given key.
The QImageWriter class provides a format independent interface for writing images to files or other d...
Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x)
static void mask_alpha_converter(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
#define CONVERT_DECL(DST, SRC)
const T & at(int i) const
Returns the item at index position i in the list.
bool deref()
Atomically decrements the value of this QAtomicInt.
The QStringList class provides a list of strings.
QString text(const QString &key=QString()) const
Returns the image text associated with the given key.
static QByteArray fromRawData(const char *, int size)
Constructs a QByteArray that uses the first size bytes of the data array.
bool operator!=(const QImage &) const
Returns true if this image and the given image have different contents; otherwise returns false...
The QPolygonF class provides a vector of points using floating point precision.
void detach()
If multiple images share common data, this image makes a copy of the data and detaches itself from th...
QPaintEngine * paintEngine
void append(const T &t)
Inserts value at the end of the vector.
QBasicAtomicInt qimage_serial_number
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
static const char * data(const QByteArray &arr)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QT_DEPRECATED int numColors() const
Returns the size of the color table for the image.
QImage createAlphaMask(Qt::ImageConversionFlags flags=Qt::AutoColor) const
Builds and returns a 1-bpp mask from the alpha buffer in this image.
#define QT_XFORM_TYPE_MSBFIRST
bool isGrayscale() const
For 32-bit images, this function is equivalent to allGray().
static QImage rotated90(const QImage &src)
void setDotsPerMeterY(int)
Sets the number of pixels that fit vertically in a physical meter, to y.
int depth() const
Returns the depth of the image.
QImage & operator=(const QImage &)
Assigns a shallow copy of the given image to this image and returns a reference to this image...
bool operator==(const QImage &) const
Returns true if this image and the given image have the same contents; otherwise returns false...
QImage transformed(const QMatrix &matrix, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a copy of the image that is transformed using the given transformation matrix and transformat...
const uchar * constBits() const
Returns a pointer to the first pixel data.
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
QImage mirrored(bool horizontally=false, bool vertically=true) const
Returns a mirror of the image, mirrored in the horizontal and/or the vertical direction depending on ...
The QScopedArrayPointer class stores a pointer to a dynamically allocated array of objects...
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
#define QT_XFORM_TYPE_LSBFIRST
static void convert_Mono_to_X32(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
QImage alphaChannel() const
Returns the alpha channel of the image as a new grayscale QImage in which each pixel's red...
The QImageReader class provides a format independent interface for reading images from files or other...
const T & at(int i) const
Returns the item at index position i in the vector.
QSize size() const
Returns the size of the image, i.
bool valid(int x, int y) const
Returns true if QPoint(x, y) is a valid coordinate pair within the image; otherwise returns false...
const uchar * constScanLine(int) const
Returns a pointer to the pixel data at the scanline with index i.
int version() const
Returns the version number of the data serialization format.
static void convert_ARGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags)
const uint qt_bayer_matrix[16][16]
QDataStream & operator<<(QDataStream &stream, const QImage &image)
Writes the given image to the given stream as a PNG image, or as a BMP image if the stream's version ...
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
void insert(int i, const T &t)
Inserts value at index position i in the vector.
Q_GUI_EXPORT_INLINE int qGray(int r, int g, int b)
static QImage rotated270(const QImage &src)
uchar * bits()
Returns a pointer to the first pixel data.
void setPixel(int x, int y, uint index_or_rgb)
Sets the pixel index or color at (x, y) to index_or_rgb.
int serialNumber() const
Returns a number that identifies the contents of this QImage object.
int width() const
Returns the width of the image.
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
static const uchar bitflip[256]
QIODevice * device() const
Returns the I/O device currently set, or 0 if no device is currently set.
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
void setDotsPerMeterX(int)
Sets the number of pixels that fit horizontally in a physical meter, to x.
Q_STATIC_INLINE_FUNCTION quint32p fromRawData(quint32 v)
bool checkForAlphaPixels() const
QImage scaledToHeight(int h, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a scaled copy of the image.
int bitPlaneCount() const
Returns the number of bit planes in the image.
int y() const
Returns the y-coordinate of the rectangle's top edge.
int colorCount() const
Returns the size of the color table for the image.
void qt_memconvert(DST *dest, const SRC *src, int count)
uint qDetectCPUFeatures()
void Q_GUI_QWS_EXPORT qt_memrotate270(const quint32 *, int, int, int, quint32 *, int)
static QImage convertWithPalette(const QImage &src, QImage::Format format, const QVector< QRgb > &clut)
Q_GUI_EXPORT qint64 qt_image_id(const QImage &image)
int x() const
Returns the x-coordinate of the rectangle's left edge.
static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags)
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
The QPoint class defines a point in the plane using integer precision.
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
int size() const
Returns the number of items in the list.
static QImage smoothScaled(const QImage &source, int w, int h)
bool isDetached() const
Returns true if the image is detached; otherwise returns false.
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
int & rheight()
Returns a reference to the height.
bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth, uchar *dptr, int dbpl, int p_inc, int dHeight, const uchar *sptr, int sbpl, int sWidth, int sHeight)
int height() const
Returns the height.
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
static int closestMatch(QRgb pixel, const QVector< QRgb > &clut)
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
bool(* InPlace_Image_Converter)(QImageData *data, Qt::ImageConversionFlags)
QImage scaledToWidth(int w, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a scaled copy of the image.
~QImage()
Destroys the image and cleans up.
int height() const
Returns the height of the image.
#define QIMAGE_SANITYCHECK_MEMORY(image)
int y() const
Returns the y coordinate of this point.
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
static void convert_X_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
QT_DEPRECATED QList< QImageTextKeyLang > textList() const
Returns a list of QImageTextKeyLang objects that enumerate all the texts key/language pairs set for t...
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
QImage qSmoothScaleImage(const QImage &src, int dw, int dh)
Q_STATIC_INLINE_FUNCTION int qt_div_255(int x)
void scale(int w, int h, Qt::AspectRatioMode mode)
Scales the size to a rectangle with the given width and height, according to the specified mode: ...
void(* Image_Converter)(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
static InPlace_Image_Converter inplace_converter_map[QImage::NImageFormats][QImage::NImageFormats]
static void convert_ARGB_PM_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
QImage createHeuristicMask(bool clipTight=true) const
Creates and returns a 1-bpp heuristic mask for this image.
QPaintEngine * paintEngine() const
Used by QPainter to retrieve a paint engine for the image.
int qt_depthForFormat(QImage::Format format)
const QVector< QRgb > * qt_image_colortable(const QImage &image)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
The QSize class defines the size of a two-dimensional object using integer point precision.
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
void invertPixels(InvertMode=InvertRgb)
Inverts all pixel values in the image.
The QDataStream class provides serialization of binary data to a QIODevice.
#define QT_XFORM_TYPE_WINDOWSPIXMAP
int x() const
Returns the x coordinate of this point.
The QRasterPaintEngine class enables hardware acceleration of painting operations in Qt for Embedded ...
bool convertInPlace(QImage::Format newFormat, Qt::ImageConversionFlags)
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
void setAlphaChannel(const QImage &alphaChannel)
Sets the alpha channel of this image to the given alphaChannel.
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
QImage scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
static const KeyPair *const end
The QIODevice class is the base interface class of all I/O devices in Qt.
bool qt_read_xpm_image_or_array(QIODevice *device, const char *const *source, QImage &image)
bool write(const QImage &image)
Writes the image image to the assigned device or file name.
bool doImageIO(const QImage *image, QImageWriter *io, int quality) const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static QString fileName(const QString &fileUrl)
QImage createMaskFromColor(QRgb color, Qt::MaskMode mode=Qt::MaskInColor) const
Creates and returns a mask for this image based on the given color value.
int size() const
Returns the number of items in the vector.
static QImage fromData(const uchar *data, int size, const char *format=0)
Constructs a QImage from the first size bytes of the given binary data.
int dotsPerMeterX() const
Returns the number of pixels that fit horizontally in a physical meter.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
QStringList textKeys() const
Returns the text keys for this image.
QVector< QRgb > colorTable() const
Returns a list of the colors contained in the image's color table, or an empty list if the image does...
QImage read()
Reads an image from the device.
QRgb color(int i) const
Returns the color in the color table at index i.
Q_DECL_CONSTEXPR int qRound(qreal d)
qint64 cacheKey() const
Returns a number that identifies the contents of this QImage object.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
static QMatrix trueMatrix(const QMatrix &, int w, int h)
Returns the actual matrix used for transforming an image with the given width, height and matrix...
QMap< QString, QString > text
static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormats]
int & rwidth()
Returns a reference to the width.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
bool loadFromData(const uchar *buf, int len, const char *format=0)
Loads an image from the first len bytes of the given binary data.
The QList class is a template class that provides lists.
bool allGray() const
Returns true if all the colors in the image are shades of gray (i.e.
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
Q_GUI_EXPORT_INLINE bool qIsGray(QRgb rgb)