Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/image/qimage_conversions.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
25 | ** | - | ||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
29 | ** | - | ||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||
31 | ** | - | ||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||
33 | - | |||||||||||||
34 | #include <private/qdrawhelper_p.h> | - | ||||||||||||
35 | #include <private/qguiapplication_p.h> | - | ||||||||||||
36 | #include <private/qsimd_p.h> | - | ||||||||||||
37 | #include <private/qimage_p.h> | - | ||||||||||||
38 | #include <qendian.h> | - | ||||||||||||
39 | - | |||||||||||||
40 | QT_BEGIN_NAMESPACE | - | ||||||||||||
41 | - | |||||||||||||
42 | // table to flip bits | - | ||||||||||||
43 | static const uchar bitflip[256] = { | - | ||||||||||||
44 | /* | - | ||||||||||||
45 | open OUT, "| fmt"; | - | ||||||||||||
46 | for $i (0..255) { | - | ||||||||||||
47 | print OUT (($i >> 7) & 0x01) | (($i >> 5) & 0x02) | | - | ||||||||||||
48 | (($i >> 3) & 0x04) | (($i >> 1) & 0x08) | | - | ||||||||||||
49 | (($i << 7) & 0x80) | (($i << 5) & 0x40) | | - | ||||||||||||
50 | (($i << 3) & 0x20) | (($i << 1) & 0x10), ", "; | - | ||||||||||||
51 | } | - | ||||||||||||
52 | close OUT; | - | ||||||||||||
53 | */ | - | ||||||||||||
54 | 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, | - | ||||||||||||
55 | 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, | - | ||||||||||||
56 | 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, | - | ||||||||||||
57 | 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, | - | ||||||||||||
58 | 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, | - | ||||||||||||
59 | 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, | - | ||||||||||||
60 | 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, | - | ||||||||||||
61 | 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, | - | ||||||||||||
62 | 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, | - | ||||||||||||
63 | 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, | - | ||||||||||||
64 | 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, | - | ||||||||||||
65 | 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, | - | ||||||||||||
66 | 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, | - | ||||||||||||
67 | 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, | - | ||||||||||||
68 | 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, | - | ||||||||||||
69 | 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 | - | ||||||||||||
70 | }; | - | ||||||||||||
71 | - | |||||||||||||
72 | const uchar *qt_get_bitflip_array() | - | ||||||||||||
73 | { | - | ||||||||||||
74 | return bitflip; never executed: return bitflip; | 0 | ||||||||||||
75 | } | - | ||||||||||||
76 | - | |||||||||||||
77 | void qGamma_correct_back_to_linear_cs(QImage *image) | - | ||||||||||||
78 | { | - | ||||||||||||
79 | const QDrawHelperGammaTables *tables = QGuiApplicationPrivate::instance()->gammaTables(); | - | ||||||||||||
80 | if (!tables)
| 0 | ||||||||||||
81 | return; never executed: return; | 0 | ||||||||||||
82 | const uchar *gamma = tables->qt_pow_rgb_gamma; | - | ||||||||||||
83 | // gamma correct the pixels back to linear color space... | - | ||||||||||||
84 | int h = image->height(); | - | ||||||||||||
85 | int w = image->width(); | - | ||||||||||||
86 | - | |||||||||||||
87 | for (int y=0; y<h; ++y) {
| 0 | ||||||||||||
88 | uint *pixels = (uint *) image->scanLine(y); | - | ||||||||||||
89 | for (int x=0; x<w; ++x) {
| 0 | ||||||||||||
90 | uint p = pixels[x]; | - | ||||||||||||
91 | uint r = gamma[qRed(p)]; | - | ||||||||||||
92 | uint g = gamma[qGreen(p)]; | - | ||||||||||||
93 | uint b = gamma[qBlue(p)]; | - | ||||||||||||
94 | pixels[x] = (r << 16) | (g << 8) | b | 0xff000000; | - | ||||||||||||
95 | } never executed: end of block | 0 | ||||||||||||
96 | } never executed: end of block | 0 | ||||||||||||
97 | } never executed: end of block | 0 | ||||||||||||
98 | - | |||||||||||||
99 | /***************************************************************************** | - | ||||||||||||
100 | Internal routines for converting image depth. | - | ||||||||||||
101 | *****************************************************************************/ | - | ||||||||||||
102 | - | |||||||||||||
103 | // The drawhelper conversions from/to RGB32 are passthroughs which is not always correct for general image conversion. | - | ||||||||||||
104 | static const uint *QT_FASTCALL convertRGB32FromARGB32PM(uint *buffer, const uint *src, int count, | - | ||||||||||||
105 | const QPixelLayout *, const QRgb *) | - | ||||||||||||
106 | { | - | ||||||||||||
107 | for (int i = 0; i < count; ++i)
| 0 | ||||||||||||
108 | buffer[i] = 0xff000000 | qUnpremultiply(src[i]); never executed: buffer[i] = 0xff000000 | qUnpremultiply(src[i]); | 0 | ||||||||||||
109 | return buffer; never executed: return buffer; | 0 | ||||||||||||
110 | } | - | ||||||||||||
111 | - | |||||||||||||
112 | static const uint *QT_FASTCALL convertRGB32ToARGB32PM(uint *buffer, const uint *src, int count, | - | ||||||||||||
113 | const QPixelLayout *, const QRgb *) | - | ||||||||||||
114 | { | - | ||||||||||||
115 | for (int i = 0; i < count; ++i)
| 0 | ||||||||||||
116 | buffer[i] = 0xff000000 |src[i]; never executed: buffer[i] = 0xff000000 |src[i]; | 0 | ||||||||||||
117 | return buffer; never executed: return buffer; | 0 | ||||||||||||
118 | } | - | ||||||||||||
119 | - | |||||||||||||
120 | #ifdef QT_COMPILER_SUPPORTS_SSE4_1 | - | ||||||||||||
121 | extern const uint *QT_FASTCALL convertRGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); | - | ||||||||||||
122 | #endif | - | ||||||||||||
123 | - | |||||||||||||
124 | void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
125 | { | - | ||||||||||||
126 | // Cannot be used with indexed formats. | - | ||||||||||||
127 | Q_ASSERT(dest->format > QImage::Format_Indexed8); | - | ||||||||||||
128 | Q_ASSERT(src->format > QImage::Format_Indexed8); | - | ||||||||||||
129 | const int buffer_size = 2048; | - | ||||||||||||
130 | uint buffer[buffer_size]; | - | ||||||||||||
131 | const QPixelLayout *srcLayout = &qPixelLayouts[src->format]; | - | ||||||||||||
132 | const QPixelLayout *destLayout = &qPixelLayouts[dest->format]; | - | ||||||||||||
133 | const uchar *srcData = src->data; | - | ||||||||||||
134 | uchar *destData = dest->data; | - | ||||||||||||
135 | - | |||||||||||||
136 | const FetchPixelsFunc fetch = qFetchPixels[srcLayout->bpp]; | - | ||||||||||||
137 | const StorePixelsFunc store = qStorePixels[destLayout->bpp]; | - | ||||||||||||
138 | ConvertFunc convertToARGB32PM = srcLayout->convertToARGB32PM; | - | ||||||||||||
139 | ConvertFunc convertFromARGB32PM = destLayout->convertFromARGB32PM; | - | ||||||||||||
140 | if (srcLayout->alphaWidth == 0 && destLayout->convertFromRGB32) {
| 0 | ||||||||||||
141 | // If the source doesn't have an alpha channel, we can use the faster convertFromRGB32 method. | - | ||||||||||||
142 | convertFromARGB32PM = destLayout->convertFromRGB32; | - | ||||||||||||
143 | } else { never executed: end of block | 0 | ||||||||||||
144 | if (src->format == QImage::Format_RGB32)
| 0 | ||||||||||||
145 | convertToARGB32PM = convertRGB32ToARGB32PM; never executed: convertToARGB32PM = convertRGB32ToARGB32PM; | 0 | ||||||||||||
146 | if (dest->format == QImage::Format_RGB32) {
| 0 | ||||||||||||
147 | #ifdef QT_COMPILER_SUPPORTS_SSE4_1 | - | ||||||||||||
148 | if (qCpuHasFeature(SSE4_1))
| 0 | ||||||||||||
149 | convertFromARGB32PM = convertRGB32FromARGB32PM_sse4; never executed: convertFromARGB32PM = convertRGB32FromARGB32PM_sse4; | 0 | ||||||||||||
150 | else | - | ||||||||||||
151 | #endif | - | ||||||||||||
152 | convertFromARGB32PM = convertRGB32FromARGB32PM; never executed: convertFromARGB32PM = convertRGB32FromARGB32PM; | 0 | ||||||||||||
153 | } | - | ||||||||||||
154 | } never executed: end of block | 0 | ||||||||||||
155 | - | |||||||||||||
156 | for (int y = 0; y < src->height; ++y) {
| 0 | ||||||||||||
157 | int x = 0; | - | ||||||||||||
158 | while (x < src->width) {
| 0 | ||||||||||||
159 | int l = qMin(src->width - x, buffer_size); | - | ||||||||||||
160 | const uint *ptr = fetch(buffer, srcData, x, l); | - | ||||||||||||
161 | ptr = convertToARGB32PM(buffer, ptr, l, srcLayout, 0); | - | ||||||||||||
162 | ptr = convertFromARGB32PM(buffer, ptr, l, destLayout, 0); | - | ||||||||||||
163 | store(destData, ptr, x, l); | - | ||||||||||||
164 | x += l; | - | ||||||||||||
165 | } never executed: end of block | 0 | ||||||||||||
166 | srcData += src->bytes_per_line; | - | ||||||||||||
167 | destData += dest->bytes_per_line; | - | ||||||||||||
168 | } never executed: end of block | 0 | ||||||||||||
169 | } never executed: end of block | 0 | ||||||||||||
170 | - | |||||||||||||
171 | bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::ImageConversionFlags) | - | ||||||||||||
172 | { | - | ||||||||||||
173 | // Cannot be used with indexed formats or between formats with different pixel depths. | - | ||||||||||||
174 | Q_ASSERT(dst_format > QImage::Format_Indexed8); | - | ||||||||||||
175 | Q_ASSERT(data->format > QImage::Format_Indexed8); | - | ||||||||||||
176 | if (data->depth != qt_depthForFormat(dst_format))
| 0 | ||||||||||||
177 | return false; never executed: return false; | 0 | ||||||||||||
178 | - | |||||||||||||
179 | const int buffer_size = 2048; | - | ||||||||||||
180 | uint buffer[buffer_size]; | - | ||||||||||||
181 | const QPixelLayout *srcLayout = &qPixelLayouts[data->format]; | - | ||||||||||||
182 | const QPixelLayout *destLayout = &qPixelLayouts[dst_format]; | - | ||||||||||||
183 | uchar *srcData = data->data; | - | ||||||||||||
184 | - | |||||||||||||
185 | const FetchPixelsFunc fetch = qFetchPixels[srcLayout->bpp]; | - | ||||||||||||
186 | const StorePixelsFunc store = qStorePixels[destLayout->bpp]; | - | ||||||||||||
187 | ConvertFunc convertToARGB32PM = srcLayout->convertToARGB32PM; | - | ||||||||||||
188 | ConvertFunc convertFromARGB32PM = destLayout->convertFromARGB32PM; | - | ||||||||||||
189 | if (srcLayout->alphaWidth == 0 && destLayout->convertFromRGB32) {
| 0 | ||||||||||||
190 | // If the source doesn't have an alpha channel, we can use the faster convertFromRGB32 method. | - | ||||||||||||
191 | convertFromARGB32PM = destLayout->convertFromRGB32; | - | ||||||||||||
192 | } else { never executed: end of block | 0 | ||||||||||||
193 | if (data->format == QImage::Format_RGB32)
| 0 | ||||||||||||
194 | convertToARGB32PM = convertRGB32ToARGB32PM; never executed: convertToARGB32PM = convertRGB32ToARGB32PM; | 0 | ||||||||||||
195 | if (dst_format == QImage::Format_RGB32) {
| 0 | ||||||||||||
196 | #ifdef QT_COMPILER_SUPPORTS_SSE4_1 | - | ||||||||||||
197 | if (qCpuHasFeature(SSE4_1))
| 0 | ||||||||||||
198 | convertFromARGB32PM = convertRGB32FromARGB32PM_sse4; never executed: convertFromARGB32PM = convertRGB32FromARGB32PM_sse4; | 0 | ||||||||||||
199 | else | - | ||||||||||||
200 | #endif | - | ||||||||||||
201 | convertFromARGB32PM = convertRGB32FromARGB32PM; never executed: convertFromARGB32PM = convertRGB32FromARGB32PM; | 0 | ||||||||||||
202 | } | - | ||||||||||||
203 | } never executed: end of block | 0 | ||||||||||||
204 | - | |||||||||||||
205 | for (int y = 0; y < data->height; ++y) {
| 0 | ||||||||||||
206 | int x = 0; | - | ||||||||||||
207 | while (x < data->width) {
| 0 | ||||||||||||
208 | int l = qMin(data->width - x, buffer_size); | - | ||||||||||||
209 | const uint *ptr = fetch(buffer, srcData, x, l); | - | ||||||||||||
210 | ptr = convertToARGB32PM(buffer, ptr, l, srcLayout, 0); | - | ||||||||||||
211 | ptr = convertFromARGB32PM(buffer, ptr, l, destLayout, 0); | - | ||||||||||||
212 | // The conversions might be passthrough and not use the buffer, in that case we are already done. | - | ||||||||||||
213 | if (srcData != (const uchar*)ptr)
| 0 | ||||||||||||
214 | store(srcData, ptr, x, l); never executed: store(srcData, ptr, x, l); | 0 | ||||||||||||
215 | x += l; | - | ||||||||||||
216 | } never executed: end of block | 0 | ||||||||||||
217 | srcData += data->bytes_per_line; | - | ||||||||||||
218 | } never executed: end of block | 0 | ||||||||||||
219 | data->format = dst_format; | - | ||||||||||||
220 | return true; never executed: return true; | 0 | ||||||||||||
221 | } | - | ||||||||||||
222 | - | |||||||||||||
223 | static void convert_passthrough(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
224 | { | - | ||||||||||||
225 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
226 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
227 | - | |||||||||||||
228 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
229 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
230 | const quint32 *src_data = (quint32 *) src->data; | - | ||||||||||||
231 | quint32 *dest_data = (quint32 *) dest->data; | - | ||||||||||||
232 | - | |||||||||||||
233 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
234 | const quint32 *end = src_data + src->width; | - | ||||||||||||
235 | while (src_data < end) {
| 0 | ||||||||||||
236 | *dest_data = *src_data; | - | ||||||||||||
237 | ++src_data; | - | ||||||||||||
238 | ++dest_data; | - | ||||||||||||
239 | } never executed: end of block | 0 | ||||||||||||
240 | src_data += src_pad; | - | ||||||||||||
241 | dest_data += dest_pad; | - | ||||||||||||
242 | } never executed: end of block | 0 | ||||||||||||
243 | } never executed: end of block | 0 | ||||||||||||
244 | - | |||||||||||||
245 | template<QImage::Format Format> | - | ||||||||||||
246 | static bool convert_passthrough_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
247 | { | - | ||||||||||||
248 | data->format = Format; | - | ||||||||||||
249 | return true; never executed: return true; | 0 | ||||||||||||
250 | } | - | ||||||||||||
251 | - | |||||||||||||
252 | static void convert_ARGB_to_ARGB_PM(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
253 | { | - | ||||||||||||
254 | Q_ASSERT(src->format == QImage::Format_ARGB32 || src->format == QImage::Format_RGBA8888); | - | ||||||||||||
255 | Q_ASSERT(dest->format == QImage::Format_ARGB32_Premultiplied || dest->format == QImage::Format_RGBA8888_Premultiplied); | - | ||||||||||||
256 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
257 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
258 | - | |||||||||||||
259 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
260 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
261 | const QRgb *src_data = (QRgb *) src->data; | - | ||||||||||||
262 | QRgb *dest_data = (QRgb *) dest->data; | - | ||||||||||||
263 | - | |||||||||||||
264 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
265 | const QRgb *end = src_data + src->width; | - | ||||||||||||
266 | while (src_data < end) {
| 0 | ||||||||||||
267 | *dest_data = qPremultiply(*src_data); | - | ||||||||||||
268 | ++src_data; | - | ||||||||||||
269 | ++dest_data; | - | ||||||||||||
270 | } never executed: end of block | 0 | ||||||||||||
271 | src_data += src_pad; | - | ||||||||||||
272 | dest_data += dest_pad; | - | ||||||||||||
273 | } never executed: end of block | 0 | ||||||||||||
274 | } never executed: end of block | 0 | ||||||||||||
275 | - | |||||||||||||
276 | Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32(quint32 *dest_data, const uchar *src_data, int len) | - | ||||||||||||
277 | { | - | ||||||||||||
278 | int pixel = 0; | - | ||||||||||||
279 | // prolog: align input to 32bit | - | ||||||||||||
280 | while ((quintptr(src_data) & 0x3) && pixel < len) {
| 0 | ||||||||||||
281 | *dest_data = 0xff000000 | (src_data[0] << 16) | (src_data[1] << 8) | (src_data[2]); | - | ||||||||||||
282 | src_data += 3; | - | ||||||||||||
283 | ++dest_data; | - | ||||||||||||
284 | ++pixel; | - | ||||||||||||
285 | } never executed: end of block | 0 | ||||||||||||
286 | - | |||||||||||||
287 | // Handle 4 pixels at a time 12 bytes input to 16 bytes output. | - | ||||||||||||
288 | for (; pixel + 3 < len; pixel += 4) {
| 0 | ||||||||||||
289 | const quint32 *src_packed = (const quint32 *) src_data; | - | ||||||||||||
290 | const quint32 src1 = qFromBigEndian(src_packed[0]); | - | ||||||||||||
291 | const quint32 src2 = qFromBigEndian(src_packed[1]); | - | ||||||||||||
292 | const quint32 src3 = qFromBigEndian(src_packed[2]); | - | ||||||||||||
293 | - | |||||||||||||
294 | dest_data[0] = 0xff000000 | (src1 >> 8); | - | ||||||||||||
295 | dest_data[1] = 0xff000000 | (src1 << 16) | (src2 >> 16); | - | ||||||||||||
296 | dest_data[2] = 0xff000000 | (src2 << 8) | (src3 >> 24); | - | ||||||||||||
297 | dest_data[3] = 0xff000000 | src3; | - | ||||||||||||
298 | - | |||||||||||||
299 | src_data += 12; | - | ||||||||||||
300 | dest_data += 4; | - | ||||||||||||
301 | } never executed: end of block | 0 | ||||||||||||
302 | - | |||||||||||||
303 | // epilog: handle left over pixels | - | ||||||||||||
304 | for (; pixel < len; ++pixel) {
| 0 | ||||||||||||
305 | *dest_data = 0xff000000 | (src_data[0] << 16) | (src_data[1] << 8) | (src_data[2]); | - | ||||||||||||
306 | src_data += 3; | - | ||||||||||||
307 | ++dest_data; | - | ||||||||||||
308 | } never executed: end of block | 0 | ||||||||||||
309 | } never executed: end of block | 0 | ||||||||||||
310 | - | |||||||||||||
311 | Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgbx8888(quint32 *dest_data, const uchar *src_data, int len) | - | ||||||||||||
312 | { | - | ||||||||||||
313 | int pixel = 0; | - | ||||||||||||
314 | // prolog: align input to 32bit | - | ||||||||||||
315 | while ((quintptr(src_data) & 0x3) && pixel < len) {
| 0 | ||||||||||||
316 | *dest_data = ARGB2RGBA(0xff000000 | (src_data[0] << 16) | (src_data[1] << 8) | (src_data[2])); | - | ||||||||||||
317 | src_data += 3; | - | ||||||||||||
318 | ++dest_data; | - | ||||||||||||
319 | ++pixel; | - | ||||||||||||
320 | } never executed: end of block | 0 | ||||||||||||
321 | - | |||||||||||||
322 | // Handle 4 pixels at a time 12 bytes input to 16 bytes output. | - | ||||||||||||
323 | for (; pixel + 3 < len; pixel += 4) {
| 0 | ||||||||||||
324 | const quint32 *src_packed = (const quint32 *) src_data; | - | ||||||||||||
325 | const quint32 src1 = src_packed[0]; | - | ||||||||||||
326 | const quint32 src2 = src_packed[1]; | - | ||||||||||||
327 | const quint32 src3 = src_packed[2]; | - | ||||||||||||
328 | - | |||||||||||||
329 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN | - | ||||||||||||
330 | dest_data[0] = 0xff000000 | src1; | - | ||||||||||||
331 | dest_data[1] = 0xff000000 | (src1 >> 24) | (src2 << 8); | - | ||||||||||||
332 | dest_data[2] = 0xff000000 | (src2 >> 16) | (src3 << 16); | - | ||||||||||||
333 | dest_data[3] = 0xff000000 | (src3 >> 8); | - | ||||||||||||
334 | #else | - | ||||||||||||
335 | dest_data[0] = 0xff | src1; | - | ||||||||||||
336 | dest_data[1] = 0xff | (src1 << 24) | (src2 >> 8); | - | ||||||||||||
337 | dest_data[2] = 0xff | (src2 << 16) | (src3 >> 16); | - | ||||||||||||
338 | dest_data[3] = 0xff | (src3 << 8); | - | ||||||||||||
339 | #endif | - | ||||||||||||
340 | - | |||||||||||||
341 | src_data += 12; | - | ||||||||||||
342 | dest_data += 4; | - | ||||||||||||
343 | } never executed: end of block | 0 | ||||||||||||
344 | - | |||||||||||||
345 | // epilog: handle left over pixels | - | ||||||||||||
346 | for (; pixel < len; ++pixel) {
| 0 | ||||||||||||
347 | *dest_data = ARGB2RGBA(0xff000000 | (src_data[0] << 16) | (src_data[1] << 8) | (src_data[2])); | - | ||||||||||||
348 | src_data += 3; | - | ||||||||||||
349 | ++dest_data; | - | ||||||||||||
350 | } never executed: end of block | 0 | ||||||||||||
351 | } never executed: end of block | 0 | ||||||||||||
352 | - | |||||||||||||
353 | typedef void (QT_FASTCALL *Rgb888ToRgbConverter)(quint32 *dst, const uchar *src, int len); | - | ||||||||||||
354 | - | |||||||||||||
355 | template <bool rgbx> | - | ||||||||||||
356 | static void convert_RGB888_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
357 | { | - | ||||||||||||
358 | Q_ASSERT(src->format == QImage::Format_RGB888); | - | ||||||||||||
359 | if (rgbx)
| 0 | ||||||||||||
360 | Q_ASSERT(dest->format == QImage::Format_RGBX8888 || dest->format == QImage::Format_RGBA8888 || dest->format == QImage::Format_RGBA8888_Premultiplied); never executed: ((!(dest->format == QImage::Format_RGBX8888 || dest->format == QImage::Format_RGBA8888 || dest->format == QImage::Format_RGBA8888_Premultiplied)) ? qt_assert("dest->format == QImage::Format_RGBX8888 || dest->format == QImage::Format_RGBA8888 || dest->format == QImage::Format_RGBA8888_Premultiplied",__FILE__,360) : qt_noop()); | 0 | ||||||||||||
361 | else | - | ||||||||||||
362 | Q_ASSERT(dest->format == QImage::Format_RGB32 || dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_ARGB32_Premultiplied); never executed: ((!(dest->format == QImage::Format_RGB32 || dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_ARGB32_Premultiplied)) ? qt_assert("dest->format == QImage::Format_RGB32 || dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_ARGB32_Premultiplied",__FILE__,362) : qt_noop()); | 0 | ||||||||||||
363 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
364 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
365 | - | |||||||||||||
366 | const uchar *src_data = (uchar *) src->data; | - | ||||||||||||
367 | quint32 *dest_data = (quint32 *) dest->data; | - | ||||||||||||
368 | - | |||||||||||||
369 | Rgb888ToRgbConverter line_converter= rgbx ? qt_convert_rgb888_to_rgbx8888 : qt_convert_rgb888_to_rgb32;
| 0 | ||||||||||||
370 | - | |||||||||||||
371 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
372 | line_converter(dest_data, src_data, src->width); | - | ||||||||||||
373 | src_data += src->bytes_per_line; | - | ||||||||||||
374 | dest_data = (quint32 *)((uchar*)dest_data + dest->bytes_per_line); | - | ||||||||||||
375 | } never executed: end of block | 0 | ||||||||||||
376 | } never executed: end of block | 0 | ||||||||||||
377 | - | |||||||||||||
378 | #ifdef __SSE2__ | - | ||||||||||||
379 | extern bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags); | - | ||||||||||||
380 | #else | - | ||||||||||||
381 | static bool convert_ARGB_to_ARGB_PM_inplace(QImageData *data,Qt::ImageConversionFlags) | - | ||||||||||||
382 | { | - | ||||||||||||
383 | Q_ASSERT(data->format == QImage::Format_ARGB32 || data->format == QImage::Format_RGBA8888); | - | ||||||||||||
384 | - | |||||||||||||
385 | const int pad = (data->bytes_per_line >> 2) - data->width; | - | ||||||||||||
386 | QRgb *rgb_data = (QRgb *) data->data; | - | ||||||||||||
387 | - | |||||||||||||
388 | for (int i = 0; i < data->height; ++i) { | - | ||||||||||||
389 | const QRgb *end = rgb_data + data->width; | - | ||||||||||||
390 | while (rgb_data < end) { | - | ||||||||||||
391 | *rgb_data = qPremultiply(*rgb_data); | - | ||||||||||||
392 | ++rgb_data; | - | ||||||||||||
393 | } | - | ||||||||||||
394 | rgb_data += pad; | - | ||||||||||||
395 | } | - | ||||||||||||
396 | - | |||||||||||||
397 | if (data->format == QImage::Format_ARGB32) | - | ||||||||||||
398 | data->format = QImage::Format_ARGB32_Premultiplied; | - | ||||||||||||
399 | else | - | ||||||||||||
400 | data->format = QImage::Format_RGBA8888_Premultiplied; | - | ||||||||||||
401 | return true; | - | ||||||||||||
402 | } | - | ||||||||||||
403 | #endif | - | ||||||||||||
404 | - | |||||||||||||
405 | static void convert_ARGB_to_RGBx(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
406 | { | - | ||||||||||||
407 | Q_ASSERT(src->format == QImage::Format_ARGB32); | - | ||||||||||||
408 | Q_ASSERT(dest->format == QImage::Format_RGBX8888); | - | ||||||||||||
409 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
410 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
411 | - | |||||||||||||
412 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
413 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
414 | const quint32 *src_data = (quint32 *) src->data; | - | ||||||||||||
415 | quint32 *dest_data = (quint32 *) dest->data; | - | ||||||||||||
416 | - | |||||||||||||
417 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
418 | const quint32 *end = src_data + src->width; | - | ||||||||||||
419 | while (src_data < end) {
| 0 | ||||||||||||
420 | *dest_data = ARGB2RGBA(0xff000000 | *src_data); | - | ||||||||||||
421 | ++src_data; | - | ||||||||||||
422 | ++dest_data; | - | ||||||||||||
423 | } never executed: end of block | 0 | ||||||||||||
424 | src_data += src_pad; | - | ||||||||||||
425 | dest_data += dest_pad; | - | ||||||||||||
426 | } never executed: end of block | 0 | ||||||||||||
427 | } never executed: end of block | 0 | ||||||||||||
428 | - | |||||||||||||
429 | static void convert_ARGB_to_RGBA(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
430 | { | - | ||||||||||||
431 | Q_ASSERT(src->format == QImage::Format_ARGB32 || src->format == QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||
432 | Q_ASSERT(dest->format == QImage::Format_RGBA8888 || dest->format == QImage::Format_RGBA8888_Premultiplied); | - | ||||||||||||
433 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
434 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
435 | - | |||||||||||||
436 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
437 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
438 | const quint32 *src_data = (quint32 *) src->data; | - | ||||||||||||
439 | quint32 *dest_data = (quint32 *) dest->data; | - | ||||||||||||
440 | - | |||||||||||||
441 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
442 | const quint32 *end = src_data + src->width; | - | ||||||||||||
443 | while (src_data < end) {
| 0 | ||||||||||||
444 | *dest_data = ARGB2RGBA(*src_data); | - | ||||||||||||
445 | ++src_data; | - | ||||||||||||
446 | ++dest_data; | - | ||||||||||||
447 | } never executed: end of block | 0 | ||||||||||||
448 | src_data += src_pad; | - | ||||||||||||
449 | dest_data += dest_pad; | - | ||||||||||||
450 | } never executed: end of block | 0 | ||||||||||||
451 | } never executed: end of block | 0 | ||||||||||||
452 | - | |||||||||||||
453 | template<QImage::Format DestFormat> | - | ||||||||||||
454 | static bool convert_ARGB_to_RGBA_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
455 | { | - | ||||||||||||
456 | Q_ASSERT(data->format == QImage::Format_ARGB32 || data->format == QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||
457 | - | |||||||||||||
458 | const int pad = (data->bytes_per_line >> 2) - data->width; | - | ||||||||||||
459 | quint32 *rgb_data = (quint32 *) data->data; | - | ||||||||||||
460 | Q_CONSTEXPR uint mask = (DestFormat == QImage::Format_RGBX8888) ? 0xff000000 : 0; | - | ||||||||||||
461 | - | |||||||||||||
462 | for (int i = 0; i < data->height; ++i) {
| 0 | ||||||||||||
463 | const quint32 *end = rgb_data + data->width; | - | ||||||||||||
464 | while (rgb_data < end) {
| 0 | ||||||||||||
465 | *rgb_data = ARGB2RGBA(*rgb_data | mask); | - | ||||||||||||
466 | ++rgb_data; | - | ||||||||||||
467 | } never executed: end of block | 0 | ||||||||||||
468 | rgb_data += pad; | - | ||||||||||||
469 | } never executed: end of block | 0 | ||||||||||||
470 | - | |||||||||||||
471 | data->format = DestFormat; | - | ||||||||||||
472 | return true; never executed: return true; | 0 | ||||||||||||
473 | } | - | ||||||||||||
474 | - | |||||||||||||
475 | static void convert_RGBA_to_ARGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
476 | { | - | ||||||||||||
477 | Q_ASSERT(src->format == QImage::Format_RGBX8888 || src->format == QImage::Format_RGBA8888 || src->format == QImage::Format_RGBA8888_Premultiplied); | - | ||||||||||||
478 | Q_ASSERT(dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||
479 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
480 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
481 | - | |||||||||||||
482 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
483 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
484 | const quint32 *src_data = (quint32 *) src->data; | - | ||||||||||||
485 | quint32 *dest_data = (quint32 *) dest->data; | - | ||||||||||||
486 | - | |||||||||||||
487 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
488 | const quint32 *end = src_data + src->width; | - | ||||||||||||
489 | while (src_data < end) {
| 0 | ||||||||||||
490 | *dest_data = RGBA2ARGB(*src_data); | - | ||||||||||||
491 | ++src_data; | - | ||||||||||||
492 | ++dest_data; | - | ||||||||||||
493 | } never executed: end of block | 0 | ||||||||||||
494 | src_data += src_pad; | - | ||||||||||||
495 | dest_data += dest_pad; | - | ||||||||||||
496 | } never executed: end of block | 0 | ||||||||||||
497 | } never executed: end of block | 0 | ||||||||||||
498 | - | |||||||||||||
499 | template<QImage::Format DestFormat> | - | ||||||||||||
500 | static bool convert_RGBA_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
501 | { | - | ||||||||||||
502 | Q_ASSERT(data->format == QImage::Format_RGBX8888 || data->format == QImage::Format_RGBA8888 || data->format == QImage::Format_RGBA8888_Premultiplied); | - | ||||||||||||
503 | - | |||||||||||||
504 | const int pad = (data->bytes_per_line >> 2) - data->width; | - | ||||||||||||
505 | QRgb *rgb_data = (QRgb *) data->data; | - | ||||||||||||
506 | Q_CONSTEXPR uint mask = (DestFormat == QImage::Format_RGB32) ? 0xff000000 : 0; | - | ||||||||||||
507 | - | |||||||||||||
508 | for (int i = 0; i < data->height; ++i) {
| 0 | ||||||||||||
509 | const QRgb *end = rgb_data + data->width; | - | ||||||||||||
510 | while (rgb_data < end) {
| 0 | ||||||||||||
511 | *rgb_data = mask | RGBA2ARGB(*rgb_data); | - | ||||||||||||
512 | ++rgb_data; | - | ||||||||||||
513 | } never executed: end of block | 0 | ||||||||||||
514 | rgb_data += pad; | - | ||||||||||||
515 | } never executed: end of block | 0 | ||||||||||||
516 | data->format = DestFormat; | - | ||||||||||||
517 | return true; never executed: return true; | 0 | ||||||||||||
518 | } | - | ||||||||||||
519 | - | |||||||||||||
520 | template<QtPixelOrder PixelOrder> | - | ||||||||||||
521 | static void convert_RGB_to_RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
522 | { | - | ||||||||||||
523 | - | |||||||||||||
524 | Q_ASSERT(src->format == QImage::Format_RGB32 || src->format == QImage::Format_ARGB32); | - | ||||||||||||
525 | Q_ASSERT(dest->format == QImage::Format_BGR30 || dest->format == QImage::Format_RGB30); | - | ||||||||||||
526 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
527 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
528 | - | |||||||||||||
529 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
530 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
531 | const quint32 *src_data = (quint32 *) src->data; | - | ||||||||||||
532 | quint32 *dest_data = (quint32 *) dest->data; | - | ||||||||||||
533 | - | |||||||||||||
534 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
535 | const quint32 *end = src_data + src->width; | - | ||||||||||||
536 | while (src_data < end) {
| 0 | ||||||||||||
537 | *dest_data = qConvertRgb32ToRgb30<PixelOrder>(*src_data); | - | ||||||||||||
538 | ++src_data; | - | ||||||||||||
539 | ++dest_data; | - | ||||||||||||
540 | } never executed: end of block | 0 | ||||||||||||
541 | src_data += src_pad; | - | ||||||||||||
542 | dest_data += dest_pad; | - | ||||||||||||
543 | } never executed: end of block | 0 | ||||||||||||
544 | } never executed: end of block | 0 | ||||||||||||
545 | - | |||||||||||||
546 | template<QtPixelOrder PixelOrder> | - | ||||||||||||
547 | static bool convert_RGB_to_RGB30_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
548 | { | - | ||||||||||||
549 | Q_ASSERT(data->format == QImage::Format_RGB32 || data->format == QImage::Format_ARGB32); | - | ||||||||||||
550 | - | |||||||||||||
551 | const int pad = (data->bytes_per_line >> 2) - data->width; | - | ||||||||||||
552 | QRgb *rgb_data = (QRgb *) data->data; | - | ||||||||||||
553 | - | |||||||||||||
554 | for (int i = 0; i < data->height; ++i) {
| 0 | ||||||||||||
555 | const QRgb *end = rgb_data + data->width; | - | ||||||||||||
556 | while (rgb_data < end) {
| 0 | ||||||||||||
557 | *rgb_data = qConvertRgb32ToRgb30<PixelOrder>(*rgb_data); | - | ||||||||||||
558 | ++rgb_data; | - | ||||||||||||
559 | } never executed: end of block | 0 | ||||||||||||
560 | rgb_data += pad; | - | ||||||||||||
561 | } never executed: end of block | 0 | ||||||||||||
562 | - | |||||||||||||
563 | data->format = (PixelOrder == PixelOrderRGB) ? QImage::Format_RGB30 : QImage::Format_BGR30;
| 0 | ||||||||||||
564 | return true; never executed: return true; | 0 | ||||||||||||
565 | } | - | ||||||||||||
566 | - | |||||||||||||
567 | static inline uint qUnpremultiplyRgb30(uint rgb30) | - | ||||||||||||
568 | { | - | ||||||||||||
569 | const uint a = rgb30 >> 30; | - | ||||||||||||
570 | switch (a) { | - | ||||||||||||
571 | case 0: never executed: case 0: | 0 | ||||||||||||
572 | return 0; never executed: return 0; | 0 | ||||||||||||
573 | case 1: { never executed: case 1: | 0 | ||||||||||||
574 | uint rgb = rgb30 & 0x3fffffff; | - | ||||||||||||
575 | rgb *= 3; | - | ||||||||||||
576 | return (a << 30) | rgb; never executed: return (a << 30) | rgb; | 0 | ||||||||||||
577 | } | - | ||||||||||||
578 | case 2: { never executed: case 2: | 0 | ||||||||||||
579 | uint rgb = rgb30 & 0x3fffffff; | - | ||||||||||||
580 | rgb += (rgb >> 1) & 0x5ff7fdff; | - | ||||||||||||
581 | return (a << 30) | rgb; never executed: return (a << 30) | rgb; | 0 | ||||||||||||
582 | } | - | ||||||||||||
583 | case 3: never executed: case 3: | 0 | ||||||||||||
584 | return rgb30; never executed: return rgb30; | 0 | ||||||||||||
585 | } | - | ||||||||||||
586 | Q_UNREACHABLE(); | - | ||||||||||||
587 | return 0; never executed: return 0; | 0 | ||||||||||||
588 | } | - | ||||||||||||
589 | - | |||||||||||||
590 | template<bool rgbswap> | - | ||||||||||||
591 | static void convert_A2RGB30_PM_to_RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
592 | { | - | ||||||||||||
593 | Q_ASSERT(src->format == QImage::Format_A2RGB30_Premultiplied || src->format == QImage::Format_A2BGR30_Premultiplied); | - | ||||||||||||
594 | Q_ASSERT(dest->format == QImage::Format_RGB30 || dest->format == QImage::Format_BGR30); | - | ||||||||||||
595 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
596 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
597 | - | |||||||||||||
598 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
599 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
600 | const quint32 *src_data = (quint32 *) src->data; | - | ||||||||||||
601 | quint32 *dest_data = (quint32 *) dest->data; | - | ||||||||||||
602 | - | |||||||||||||
603 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
604 | const quint32 *end = src_data + src->width; | - | ||||||||||||
605 | while (src_data < end) {
| 0 | ||||||||||||
606 | const uint p = 0xc0000000 | qUnpremultiplyRgb30(*src_data); | - | ||||||||||||
607 | *dest_data = (rgbswap) ? qRgbSwapRgb30(p) : p;
| 0 | ||||||||||||
608 | ++src_data; | - | ||||||||||||
609 | ++dest_data; | - | ||||||||||||
610 | } never executed: end of block | 0 | ||||||||||||
611 | src_data += src_pad; | - | ||||||||||||
612 | dest_data += dest_pad; | - | ||||||||||||
613 | } never executed: end of block | 0 | ||||||||||||
614 | } never executed: end of block | 0 | ||||||||||||
615 | - | |||||||||||||
616 | template<bool rgbswap> | - | ||||||||||||
617 | static bool convert_A2RGB30_PM_to_RGB30_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
618 | { | - | ||||||||||||
619 | Q_ASSERT(data->format == QImage::Format_A2RGB30_Premultiplied || data->format == QImage::Format_A2BGR30_Premultiplied); | - | ||||||||||||
620 | - | |||||||||||||
621 | const int pad = (data->bytes_per_line >> 2) - data->width; | - | ||||||||||||
622 | uint *rgb_data = (uint *) data->data; | - | ||||||||||||
623 | - | |||||||||||||
624 | for (int i = 0; i < data->height; ++i) {
| 0 | ||||||||||||
625 | const uint *end = rgb_data + data->width; | - | ||||||||||||
626 | while (rgb_data < end) {
| 0 | ||||||||||||
627 | const uint p = 0xc0000000 | qUnpremultiplyRgb30(*rgb_data); | - | ||||||||||||
628 | *rgb_data = (rgbswap) ? qRgbSwapRgb30(p) : p;
| 0 | ||||||||||||
629 | ++rgb_data; | - | ||||||||||||
630 | } never executed: end of block | 0 | ||||||||||||
631 | rgb_data += pad; | - | ||||||||||||
632 | } never executed: end of block | 0 | ||||||||||||
633 | - | |||||||||||||
634 | if (data->format == QImage::Format_A2RGB30_Premultiplied)
| 0 | ||||||||||||
635 | data->format = (rgbswap) ? QImage::Format_BGR30 : QImage::Format_RGB30; never executed: data->format = (rgbswap) ? QImage::Format_BGR30 : QImage::Format_RGB30;
| 0 | ||||||||||||
636 | else | - | ||||||||||||
637 | data->format = (rgbswap) ? QImage::Format_RGB30 : QImage::Format_BGR30; never executed: data->format = (rgbswap) ? QImage::Format_RGB30 : QImage::Format_BGR30;
| 0 | ||||||||||||
638 | return true; never executed: return true; | 0 | ||||||||||||
639 | } | - | ||||||||||||
640 | - | |||||||||||||
641 | static void convert_BGR30_to_RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
642 | { | - | ||||||||||||
643 | Q_ASSERT(src->format == QImage::Format_RGB30 || src->format == QImage::Format_BGR30 || | - | ||||||||||||
644 | src->format == QImage::Format_A2RGB30_Premultiplied || src->format == QImage::Format_A2BGR30_Premultiplied); | - | ||||||||||||
645 | Q_ASSERT(dest->format == QImage::Format_RGB30 || dest->format == QImage::Format_BGR30 || | - | ||||||||||||
646 | dest->format == QImage::Format_A2RGB30_Premultiplied || dest->format == QImage::Format_A2BGR30_Premultiplied); | - | ||||||||||||
647 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
648 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
649 | - | |||||||||||||
650 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
651 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
652 | const quint32 *src_data = (quint32 *) src->data; | - | ||||||||||||
653 | quint32 *dest_data = (quint32 *) dest->data; | - | ||||||||||||
654 | - | |||||||||||||
655 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
656 | const quint32 *end = src_data + src->width; | - | ||||||||||||
657 | while (src_data < end) {
| 0 | ||||||||||||
658 | *dest_data = qRgbSwapRgb30(*src_data); | - | ||||||||||||
659 | ++src_data; | - | ||||||||||||
660 | ++dest_data; | - | ||||||||||||
661 | } never executed: end of block | 0 | ||||||||||||
662 | src_data += src_pad; | - | ||||||||||||
663 | dest_data += dest_pad; | - | ||||||||||||
664 | } never executed: end of block | 0 | ||||||||||||
665 | } never executed: end of block | 0 | ||||||||||||
666 | - | |||||||||||||
667 | static bool convert_BGR30_to_RGB30_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
668 | { | - | ||||||||||||
669 | Q_ASSERT(data->format == QImage::Format_RGB30 || data->format == QImage::Format_BGR30 || | - | ||||||||||||
670 | data->format == QImage::Format_A2RGB30_Premultiplied || data->format == QImage::Format_A2BGR30_Premultiplied); | - | ||||||||||||
671 | - | |||||||||||||
672 | const int pad = (data->bytes_per_line >> 2) - data->width; | - | ||||||||||||
673 | uint *rgb_data = (uint *) data->data; | - | ||||||||||||
674 | - | |||||||||||||
675 | for (int i = 0; i < data->height; ++i) {
| 0 | ||||||||||||
676 | const uint *end = rgb_data + data->width; | - | ||||||||||||
677 | while (rgb_data < end) {
| 0 | ||||||||||||
678 | *rgb_data = qRgbSwapRgb30(*rgb_data); | - | ||||||||||||
679 | ++rgb_data; | - | ||||||||||||
680 | } never executed: end of block | 0 | ||||||||||||
681 | rgb_data += pad; | - | ||||||||||||
682 | } never executed: end of block | 0 | ||||||||||||
683 | - | |||||||||||||
684 | switch (data->format) { | - | ||||||||||||
685 | case QImage::Format_BGR30: never executed: case QImage::Format_BGR30: | 0 | ||||||||||||
686 | data->format = QImage::Format_RGB30; | - | ||||||||||||
687 | break; never executed: break; | 0 | ||||||||||||
688 | case QImage::Format_A2BGR30_Premultiplied: never executed: case QImage::Format_A2BGR30_Premultiplied: | 0 | ||||||||||||
689 | data->format = QImage::Format_A2RGB30_Premultiplied; | - | ||||||||||||
690 | break; never executed: break; | 0 | ||||||||||||
691 | case QImage::Format_RGB30: never executed: case QImage::Format_RGB30: | 0 | ||||||||||||
692 | data->format = QImage::Format_BGR30; | - | ||||||||||||
693 | break; never executed: break; | 0 | ||||||||||||
694 | case QImage::Format_A2RGB30_Premultiplied: never executed: case QImage::Format_A2RGB30_Premultiplied: | 0 | ||||||||||||
695 | data->format = QImage::Format_A2BGR30_Premultiplied; | - | ||||||||||||
696 | break; never executed: break; | 0 | ||||||||||||
697 | default: never executed: default: | 0 | ||||||||||||
698 | Q_UNREACHABLE(); | - | ||||||||||||
699 | data->format = QImage::Format_Invalid; | - | ||||||||||||
700 | return false; never executed: return false; | 0 | ||||||||||||
701 | } | - | ||||||||||||
702 | return true; never executed: return true; | 0 | ||||||||||||
703 | } | - | ||||||||||||
704 | - | |||||||||||||
705 | static bool convert_BGR30_to_A2RGB30_inplace(QImageData *data, Qt::ImageConversionFlags flags) | - | ||||||||||||
706 | { | - | ||||||||||||
707 | Q_ASSERT(data->format == QImage::Format_RGB30 || data->format == QImage::Format_BGR30); | - | ||||||||||||
708 | if (!convert_BGR30_to_RGB30_inplace(data, flags))
| 0 | ||||||||||||
709 | return false; never executed: return false; | 0 | ||||||||||||
710 | - | |||||||||||||
711 | if (data->format == QImage::Format_RGB30)
| 0 | ||||||||||||
712 | data->format = QImage::Format_A2RGB30_Premultiplied; never executed: data->format = QImage::Format_A2RGB30_Premultiplied; | 0 | ||||||||||||
713 | else | - | ||||||||||||
714 | data->format = QImage::Format_A2BGR30_Premultiplied; never executed: data->format = QImage::Format_A2BGR30_Premultiplied; | 0 | ||||||||||||
715 | return true; never executed: return true; | 0 | ||||||||||||
716 | } | - | ||||||||||||
717 | - | |||||||||||||
718 | template<QtPixelOrder PixelOrder> | - | ||||||||||||
719 | static void convert_A2RGB30_PM_to_ARGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
720 | { | - | ||||||||||||
721 | Q_ASSERT(src->format == QImage::Format_A2RGB30_Premultiplied || src->format == QImage::Format_A2BGR30_Premultiplied); | - | ||||||||||||
722 | Q_ASSERT(dest->format == QImage::Format_ARGB32); | - | ||||||||||||
723 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
724 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
725 | - | |||||||||||||
726 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
727 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
728 | const quint32 *src_data = (quint32 *) src->data; | - | ||||||||||||
729 | quint32 *dest_data = (quint32 *) dest->data; | - | ||||||||||||
730 | - | |||||||||||||
731 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
732 | const quint32 *end = src_data + src->width; | - | ||||||||||||
733 | while (src_data < end) {
| 0 | ||||||||||||
734 | *dest_data = qConvertA2rgb30ToArgb32<PixelOrder>(qUnpremultiplyRgb30(*src_data)); | - | ||||||||||||
735 | ++src_data; | - | ||||||||||||
736 | ++dest_data; | - | ||||||||||||
737 | } never executed: end of block | 0 | ||||||||||||
738 | src_data += src_pad; | - | ||||||||||||
739 | dest_data += dest_pad; | - | ||||||||||||
740 | } never executed: end of block | 0 | ||||||||||||
741 | } never executed: end of block | 0 | ||||||||||||
742 | - | |||||||||||||
743 | template<QtPixelOrder PixelOrder> | - | ||||||||||||
744 | static bool convert_A2RGB30_PM_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
745 | { | - | ||||||||||||
746 | Q_ASSERT(data->format == QImage::Format_A2RGB30_Premultiplied || data->format == QImage::Format_A2BGR30_Premultiplied); | - | ||||||||||||
747 | - | |||||||||||||
748 | const int pad = (data->bytes_per_line >> 2) - data->width; | - | ||||||||||||
749 | uint *rgb_data = (uint *) data->data; | - | ||||||||||||
750 | - | |||||||||||||
751 | for (int i = 0; i < data->height; ++i) {
| 0 | ||||||||||||
752 | const uint *end = rgb_data + data->width; | - | ||||||||||||
753 | while (rgb_data < end) {
| 0 | ||||||||||||
754 | *rgb_data = qConvertA2rgb30ToArgb32<PixelOrder>(qUnpremultiplyRgb30(*rgb_data)); | - | ||||||||||||
755 | ++rgb_data; | - | ||||||||||||
756 | } never executed: end of block | 0 | ||||||||||||
757 | rgb_data += pad; | - | ||||||||||||
758 | } never executed: end of block | 0 | ||||||||||||
759 | data->format = QImage::Format_ARGB32; | - | ||||||||||||
760 | return true; never executed: return true; | 0 | ||||||||||||
761 | } | - | ||||||||||||
762 | - | |||||||||||||
763 | static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
764 | { | - | ||||||||||||
765 | Q_ASSERT(data->format == QImage::Format_Indexed8); | - | ||||||||||||
766 | Q_ASSERT(data->own_data); | - | ||||||||||||
767 | - | |||||||||||||
768 | const int depth = 32; | - | ||||||||||||
769 | - | |||||||||||||
770 | const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; | - | ||||||||||||
771 | const int nbytes = dst_bytes_per_line * data->height; | - | ||||||||||||
772 | uchar *const newData = (uchar *)realloc(data->data, nbytes); | - | ||||||||||||
773 | if (!newData)
| 0 | ||||||||||||
774 | return false; never executed: return false; | 0 | ||||||||||||
775 | - | |||||||||||||
776 | data->data = newData; | - | ||||||||||||
777 | - | |||||||||||||
778 | // start converting from the end because the end image is bigger than the source | - | ||||||||||||
779 | uchar *src_data = newData + data->nbytes; // end of src | - | ||||||||||||
780 | quint32 *dest_data = (quint32 *) (newData + nbytes); // end of dest > end of src | - | ||||||||||||
781 | const int width = data->width; | - | ||||||||||||
782 | const int src_pad = data->bytes_per_line - width; | - | ||||||||||||
783 | const int dest_pad = (dst_bytes_per_line >> 2) - width; | - | ||||||||||||
784 | if (data->colortable.size() == 0) {
| 0 | ||||||||||||
785 | data->colortable.resize(256); | - | ||||||||||||
786 | for (int i = 0; i < 256; ++i)
| 0 | ||||||||||||
787 | data->colortable[i] = qRgb(i, i, i); never executed: data->colortable[i] = qRgb(i, i, i); | 0 | ||||||||||||
788 | } else { never executed: end of block | 0 | ||||||||||||
789 | for (int i = 0; i < data->colortable.size(); ++i)
| 0 | ||||||||||||
790 | data->colortable[i] = qPremultiply(data->colortable.at(i)); never executed: data->colortable[i] = qPremultiply(data->colortable.at(i)); | 0 | ||||||||||||
791 | - | |||||||||||||
792 | // Fill the rest of the table in case src_data > colortable.size() | - | ||||||||||||
793 | const int oldSize = data->colortable.size(); | - | ||||||||||||
794 | const QRgb lastColor = data->colortable.at(oldSize - 1); | - | ||||||||||||
795 | data->colortable.insert(oldSize, 256 - oldSize, lastColor); | - | ||||||||||||
796 | } never executed: end of block | 0 | ||||||||||||
797 | - | |||||||||||||
798 | for (int i = 0; i < data->height; ++i) {
| 0 | ||||||||||||
799 | src_data -= src_pad; | - | ||||||||||||
800 | dest_data -= dest_pad; | - | ||||||||||||
801 | for (int pixI = 0; pixI < width; ++pixI) {
| 0 | ||||||||||||
802 | --src_data; | - | ||||||||||||
803 | --dest_data; | - | ||||||||||||
804 | *dest_data = data->colortable.at(*src_data); | - | ||||||||||||
805 | } never executed: end of block | 0 | ||||||||||||
806 | } never executed: end of block | 0 | ||||||||||||
807 | - | |||||||||||||
808 | data->colortable = QVector<QRgb>(); | - | ||||||||||||
809 | data->format = QImage::Format_ARGB32_Premultiplied; | - | ||||||||||||
810 | data->bytes_per_line = dst_bytes_per_line; | - | ||||||||||||
811 | data->depth = depth; | - | ||||||||||||
812 | data->nbytes = nbytes; | - | ||||||||||||
813 | - | |||||||||||||
814 | return true; never executed: return true; | 0 | ||||||||||||
815 | } | - | ||||||||||||
816 | - | |||||||||||||
817 | static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
818 | { | - | ||||||||||||
819 | Q_ASSERT(data->format == QImage::Format_Indexed8); | - | ||||||||||||
820 | Q_ASSERT(data->own_data); | - | ||||||||||||
821 | - | |||||||||||||
822 | const int depth = 32; | - | ||||||||||||
823 | - | |||||||||||||
824 | const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; | - | ||||||||||||
825 | const int nbytes = dst_bytes_per_line * data->height; | - | ||||||||||||
826 | uchar *const newData = (uchar *)realloc(data->data, nbytes); | - | ||||||||||||
827 | if (!newData)
| 0 | ||||||||||||
828 | return false; never executed: return false; | 0 | ||||||||||||
829 | - | |||||||||||||
830 | data->data = newData; | - | ||||||||||||
831 | - | |||||||||||||
832 | // start converting from the end because the end image is bigger than the source | - | ||||||||||||
833 | uchar *src_data = newData + data->nbytes; | - | ||||||||||||
834 | quint32 *dest_data = (quint32 *) (newData + nbytes); | - | ||||||||||||
835 | const int width = data->width; | - | ||||||||||||
836 | const int src_pad = data->bytes_per_line - width; | - | ||||||||||||
837 | const int dest_pad = (dst_bytes_per_line >> 2) - width; | - | ||||||||||||
838 | if (data->colortable.size() == 0) {
| 0 | ||||||||||||
839 | data->colortable.resize(256); | - | ||||||||||||
840 | for (int i = 0; i < 256; ++i)
| 0 | ||||||||||||
841 | data->colortable[i] = qRgb(i, i, i); never executed: data->colortable[i] = qRgb(i, i, i); | 0 | ||||||||||||
842 | } else { never executed: end of block | 0 | ||||||||||||
843 | // Fill the rest of the table in case src_data > colortable.size() | - | ||||||||||||
844 | const int oldSize = data->colortable.size(); | - | ||||||||||||
845 | const QRgb lastColor = data->colortable.at(oldSize - 1); | - | ||||||||||||
846 | data->colortable.insert(oldSize, 256 - oldSize, lastColor); | - | ||||||||||||
847 | } never executed: end of block | 0 | ||||||||||||
848 | - | |||||||||||||
849 | for (int i = 0; i < data->height; ++i) {
| 0 | ||||||||||||
850 | src_data -= src_pad; | - | ||||||||||||
851 | dest_data -= dest_pad; | - | ||||||||||||
852 | for (int pixI = 0; pixI < width; ++pixI) {
| 0 | ||||||||||||
853 | --src_data; | - | ||||||||||||
854 | --dest_data; | - | ||||||||||||
855 | *dest_data = (quint32) data->colortable.at(*src_data); | - | ||||||||||||
856 | } never executed: end of block | 0 | ||||||||||||
857 | } never executed: end of block | 0 | ||||||||||||
858 | - | |||||||||||||
859 | data->colortable = QVector<QRgb>(); | - | ||||||||||||
860 | data->format = QImage::Format_ARGB32; | - | ||||||||||||
861 | data->bytes_per_line = dst_bytes_per_line; | - | ||||||||||||
862 | data->depth = depth; | - | ||||||||||||
863 | data->nbytes = nbytes; | - | ||||||||||||
864 | - | |||||||||||||
865 | return true; never executed: return true; | 0 | ||||||||||||
866 | } | - | ||||||||||||
867 | - | |||||||||||||
868 | static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversionFlags flags) | - | ||||||||||||
869 | { | - | ||||||||||||
870 | Q_ASSERT(data->format == QImage::Format_Indexed8); | - | ||||||||||||
871 | Q_ASSERT(data->own_data); | - | ||||||||||||
872 | - | |||||||||||||
873 | if (data->has_alpha_clut) {
| 0 | ||||||||||||
874 | for (int i = 0; i < data->colortable.size(); ++i)
| 0 | ||||||||||||
875 | data->colortable[i] |= 0xff000000; never executed: data->colortable[i] |= 0xff000000; | 0 | ||||||||||||
876 | } never executed: end of block | 0 | ||||||||||||
877 | - | |||||||||||||
878 | if (!convert_indexed8_to_ARGB_inplace(data, flags))
| 0 | ||||||||||||
879 | return false; never executed: return false; | 0 | ||||||||||||
880 | - | |||||||||||||
881 | data->format = QImage::Format_RGB32; | - | ||||||||||||
882 | return true; never executed: return true; | 0 | ||||||||||||
883 | } | - | ||||||||||||
884 | - | |||||||||||||
885 | static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
886 | { | - | ||||||||||||
887 | Q_ASSERT(data->format == QImage::Format_Indexed8); | - | ||||||||||||
888 | Q_ASSERT(data->own_data); | - | ||||||||||||
889 | - | |||||||||||||
890 | const int depth = 16; | - | ||||||||||||
891 | - | |||||||||||||
892 | const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; | - | ||||||||||||
893 | const int nbytes = dst_bytes_per_line * data->height; | - | ||||||||||||
894 | uchar *const newData = (uchar *)realloc(data->data, nbytes); | - | ||||||||||||
895 | if (!newData)
| 0 | ||||||||||||
896 | return false; never executed: return false; | 0 | ||||||||||||
897 | - | |||||||||||||
898 | data->data = newData; | - | ||||||||||||
899 | - | |||||||||||||
900 | // start converting from the end because the end image is bigger than the source | - | ||||||||||||
901 | uchar *src_data = newData + data->nbytes; | - | ||||||||||||
902 | quint16 *dest_data = (quint16 *) (newData + nbytes); | - | ||||||||||||
903 | const int width = data->width; | - | ||||||||||||
904 | const int src_pad = data->bytes_per_line - width; | - | ||||||||||||
905 | const int dest_pad = (dst_bytes_per_line >> 1) - width; | - | ||||||||||||
906 | - | |||||||||||||
907 | quint16 colorTableRGB16[256]; | - | ||||||||||||
908 | const int tableSize = data->colortable.size(); | - | ||||||||||||
909 | if (tableSize == 0) {
| 0 | ||||||||||||
910 | for (int i = 0; i < 256; ++i)
| 0 | ||||||||||||
911 | colorTableRGB16[i] = qConvertRgb32To16(qRgb(i, i, i)); never executed: colorTableRGB16[i] = qConvertRgb32To16(qRgb(i, i, i)); | 0 | ||||||||||||
912 | } else { never executed: end of block | 0 | ||||||||||||
913 | // 1) convert the existing colors to RGB16 | - | ||||||||||||
914 | for (int i = 0; i < tableSize; ++i)
| 0 | ||||||||||||
915 | colorTableRGB16[i] = qConvertRgb32To16(data->colortable.at(i)); never executed: colorTableRGB16[i] = qConvertRgb32To16(data->colortable.at(i)); | 0 | ||||||||||||
916 | data->colortable = QVector<QRgb>(); | - | ||||||||||||
917 | - | |||||||||||||
918 | // 2) fill the rest of the table in case src_data > colortable.size() | - | ||||||||||||
919 | const quint16 lastColor = colorTableRGB16[tableSize - 1]; | - | ||||||||||||
920 | for (int i = tableSize; i < 256; ++i)
| 0 | ||||||||||||
921 | colorTableRGB16[i] = lastColor; never executed: colorTableRGB16[i] = lastColor; | 0 | ||||||||||||
922 | } never executed: end of block | 0 | ||||||||||||
923 | - | |||||||||||||
924 | for (int i = 0; i < data->height; ++i) {
| 0 | ||||||||||||
925 | src_data -= src_pad; | - | ||||||||||||
926 | dest_data -= dest_pad; | - | ||||||||||||
927 | for (int pixI = 0; pixI < width; ++pixI) {
| 0 | ||||||||||||
928 | --src_data; | - | ||||||||||||
929 | --dest_data; | - | ||||||||||||
930 | *dest_data = colorTableRGB16[*src_data]; | - | ||||||||||||
931 | } never executed: end of block | 0 | ||||||||||||
932 | } never executed: end of block | 0 | ||||||||||||
933 | - | |||||||||||||
934 | data->format = QImage::Format_RGB16; | - | ||||||||||||
935 | data->bytes_per_line = dst_bytes_per_line; | - | ||||||||||||
936 | data->depth = depth; | - | ||||||||||||
937 | data->nbytes = nbytes; | - | ||||||||||||
938 | - | |||||||||||||
939 | return true; never executed: return true; | 0 | ||||||||||||
940 | } | - | ||||||||||||
941 | - | |||||||||||||
942 | static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
943 | { | - | ||||||||||||
944 | Q_ASSERT(data->format == QImage::Format_RGB32); | - | ||||||||||||
945 | Q_ASSERT(data->own_data); | - | ||||||||||||
946 | - | |||||||||||||
947 | const int depth = 16; | - | ||||||||||||
948 | - | |||||||||||||
949 | const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; | - | ||||||||||||
950 | const int src_bytes_per_line = data->bytes_per_line; | - | ||||||||||||
951 | quint32 *src_data = (quint32 *) data->data; | - | ||||||||||||
952 | quint16 *dst_data = (quint16 *) data->data; | - | ||||||||||||
953 | - | |||||||||||||
954 | for (int i = 0; i < data->height; ++i) {
| 0 | ||||||||||||
955 | for (int j = 0; j < data->width; ++j)
| 0 | ||||||||||||
956 | dst_data[j] = qConvertRgb32To16(src_data[j]); never executed: dst_data[j] = qConvertRgb32To16(src_data[j]); | 0 | ||||||||||||
957 | src_data = (quint32 *) (((char*)src_data) + src_bytes_per_line); | - | ||||||||||||
958 | dst_data = (quint16 *) (((char*)dst_data) + dst_bytes_per_line); | - | ||||||||||||
959 | } never executed: end of block | 0 | ||||||||||||
960 | data->format = QImage::Format_RGB16; | - | ||||||||||||
961 | data->bytes_per_line = dst_bytes_per_line; | - | ||||||||||||
962 | data->depth = depth; | - | ||||||||||||
963 | data->nbytes = dst_bytes_per_line * data->height; | - | ||||||||||||
964 | uchar *const newData = (uchar *)realloc(data->data, data->nbytes); | - | ||||||||||||
965 | if (newData) {
| 0 | ||||||||||||
966 | data->data = newData; | - | ||||||||||||
967 | return true; never executed: return true; | 0 | ||||||||||||
968 | } else { | - | ||||||||||||
969 | return false; never executed: return false; | 0 | ||||||||||||
970 | } | - | ||||||||||||
971 | } | - | ||||||||||||
972 | - | |||||||||||||
973 | static void convert_ARGB_PM_to_ARGB(QImageData *dest, const QImageData *src) | - | ||||||||||||
974 | { | - | ||||||||||||
975 | Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied || src->format == QImage::Format_RGBA8888_Premultiplied); | - | ||||||||||||
976 | Q_ASSERT(dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_RGBA8888); | - | ||||||||||||
977 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
978 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
979 | - | |||||||||||||
980 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
981 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
982 | const QRgb *src_data = (QRgb *) src->data; | - | ||||||||||||
983 | QRgb *dest_data = (QRgb *) dest->data; | - | ||||||||||||
984 | - | |||||||||||||
985 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
986 | const QRgb *end = src_data + src->width; | - | ||||||||||||
987 | while (src_data < end) {
| 0 | ||||||||||||
988 | *dest_data = qUnpremultiply(*src_data); | - | ||||||||||||
989 | ++src_data; | - | ||||||||||||
990 | ++dest_data; | - | ||||||||||||
991 | } never executed: end of block | 0 | ||||||||||||
992 | src_data += src_pad; | - | ||||||||||||
993 | dest_data += dest_pad; | - | ||||||||||||
994 | } never executed: end of block | 0 | ||||||||||||
995 | } never executed: end of block | 0 | ||||||||||||
996 | - | |||||||||||||
997 | static void convert_RGBA_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
998 | { | - | ||||||||||||
999 | Q_ASSERT(src->format == QImage::Format_RGBA8888 || src->format == QImage::Format_RGBX8888); | - | ||||||||||||
1000 | Q_ASSERT(dest->format == QImage::Format_RGB32); | - | ||||||||||||
1001 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
1002 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
1003 | - | |||||||||||||
1004 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
1005 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
1006 | const uint *src_data = (const uint *)src->data; | - | ||||||||||||
1007 | uint *dest_data = (uint *)dest->data; | - | ||||||||||||
1008 | - | |||||||||||||
1009 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
1010 | const uint *end = src_data + src->width; | - | ||||||||||||
1011 | while (src_data < end) {
| 0 | ||||||||||||
1012 | *dest_data = RGBA2ARGB(*src_data) | 0xff000000; | - | ||||||||||||
1013 | ++src_data; | - | ||||||||||||
1014 | ++dest_data; | - | ||||||||||||
1015 | } never executed: end of block | 0 | ||||||||||||
1016 | src_data += src_pad; | - | ||||||||||||
1017 | dest_data += dest_pad; | - | ||||||||||||
1018 | } never executed: end of block | 0 | ||||||||||||
1019 | } never executed: end of block | 0 | ||||||||||||
1020 | - | |||||||||||||
1021 | static void swap_bit_order(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
1022 | { | - | ||||||||||||
1023 | Q_ASSERT(src->format == QImage::Format_Mono || src->format == QImage::Format_MonoLSB); | - | ||||||||||||
1024 | Q_ASSERT(dest->format == QImage::Format_Mono || dest->format == QImage::Format_MonoLSB); | - | ||||||||||||
1025 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
1026 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
1027 | Q_ASSERT(src->nbytes == dest->nbytes); | - | ||||||||||||
1028 | Q_ASSERT(src->bytes_per_line == dest->bytes_per_line); | - | ||||||||||||
1029 | - | |||||||||||||
1030 | dest->colortable = src->colortable; | - | ||||||||||||
1031 | - | |||||||||||||
1032 | const uchar *src_data = src->data; | - | ||||||||||||
1033 | const uchar *end = src->data + src->nbytes; | - | ||||||||||||
1034 | uchar *dest_data = dest->data; | - | ||||||||||||
1035 | while (src_data < end) {
| 0 | ||||||||||||
1036 | *dest_data = bitflip[*src_data]; | - | ||||||||||||
1037 | ++src_data; | - | ||||||||||||
1038 | ++dest_data; | - | ||||||||||||
1039 | } never executed: end of block | 0 | ||||||||||||
1040 | } never executed: end of block | 0 | ||||||||||||
1041 | - | |||||||||||||
1042 | static void mask_alpha_converter(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
1043 | { | - | ||||||||||||
1044 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
1045 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
1046 | - | |||||||||||||
1047 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
1048 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
1049 | const uint *src_data = (const uint *)src->data; | - | ||||||||||||
1050 | uint *dest_data = (uint *)dest->data; | - | ||||||||||||
1051 | - | |||||||||||||
1052 | for (int i = 0; i < src->height; ++i) {
| 0 | ||||||||||||
1053 | const uint *end = src_data + src->width; | - | ||||||||||||
1054 | while (src_data < end) {
| 0 | ||||||||||||
1055 | *dest_data = *src_data | 0xff000000; | - | ||||||||||||
1056 | ++src_data; | - | ||||||||||||
1057 | ++dest_data; | - | ||||||||||||
1058 | } never executed: end of block | 0 | ||||||||||||
1059 | src_data += src_pad; | - | ||||||||||||
1060 | dest_data += dest_pad; | - | ||||||||||||
1061 | } never executed: end of block | 0 | ||||||||||||
1062 | } never executed: end of block | 0 | ||||||||||||
1063 | - | |||||||||||||
1064 | template<QImage::Format DestFormat> | - | ||||||||||||
1065 | static bool mask_alpha_converter_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
1066 | { | - | ||||||||||||
1067 | Q_ASSERT(data->format == QImage::Format_RGB32 | - | ||||||||||||
1068 | || DestFormat == QImage::Format_RGB32 | - | ||||||||||||
1069 | || DestFormat == QImage::Format_RGBX8888); | - | ||||||||||||
1070 | const int pad = (data->bytes_per_line >> 2) - data->width; | - | ||||||||||||
1071 | QRgb *rgb_data = (QRgb *) data->data; | - | ||||||||||||
1072 | - | |||||||||||||
1073 | for (int i = 0; i < data->height; ++i) {
| 0 | ||||||||||||
1074 | const QRgb *end = rgb_data + data->width; | - | ||||||||||||
1075 | while (rgb_data < end) {
| 0 | ||||||||||||
1076 | *rgb_data = *rgb_data | 0xff000000; | - | ||||||||||||
1077 | ++rgb_data; | - | ||||||||||||
1078 | } never executed: end of block | 0 | ||||||||||||
1079 | rgb_data += pad; | - | ||||||||||||
1080 | } never executed: end of block | 0 | ||||||||||||
1081 | data->format = DestFormat; | - | ||||||||||||
1082 | return true; never executed: return true; | 0 | ||||||||||||
1083 | } | - | ||||||||||||
1084 | - | |||||||||||||
1085 | static void mask_alpha_converter_RGBx(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags flags) | - | ||||||||||||
1086 | { | - | ||||||||||||
1087 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN | - | ||||||||||||
1088 | return mask_alpha_converter(dest, src, flags); never executed: return mask_alpha_converter(dest, src, flags); | 0 | ||||||||||||
1089 | #else | - | ||||||||||||
1090 | Q_UNUSED(flags); | - | ||||||||||||
1091 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
1092 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
1093 | - | |||||||||||||
1094 | const int src_pad = (src->bytes_per_line >> 2) - src->width; | - | ||||||||||||
1095 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - | ||||||||||||
1096 | const uint *src_data = (const uint *)src->data; | - | ||||||||||||
1097 | uint *dest_data = (uint *)dest->data; | - | ||||||||||||
1098 | - | |||||||||||||
1099 | for (int i = 0; i < src->height; ++i) { | - | ||||||||||||
1100 | const uint *end = src_data + src->width; | - | ||||||||||||
1101 | while (src_data < end) { | - | ||||||||||||
1102 | *dest_data = *src_data | 0x000000ff; | - | ||||||||||||
1103 | ++src_data; | - | ||||||||||||
1104 | ++dest_data; | - | ||||||||||||
1105 | } | - | ||||||||||||
1106 | src_data += src_pad; | - | ||||||||||||
1107 | dest_data += dest_pad; | - | ||||||||||||
1108 | } | - | ||||||||||||
1109 | #endif | - | ||||||||||||
1110 | } | - | ||||||||||||
1111 | - | |||||||||||||
1112 | static bool mask_alpha_converter_rgbx_inplace(QImageData *data, Qt::ImageConversionFlags flags) | - | ||||||||||||
1113 | { | - | ||||||||||||
1114 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN | - | ||||||||||||
1115 | return mask_alpha_converter_inplace<QImage::Format_RGBX8888>(data, flags); never executed: return mask_alpha_converter_inplace<QImage::Format_RGBX8888>(data, flags); | 0 | ||||||||||||
1116 | #else | - | ||||||||||||
1117 | Q_UNUSED(flags); | - | ||||||||||||
1118 | - | |||||||||||||
1119 | const int pad = (data->bytes_per_line >> 2) - data->width; | - | ||||||||||||
1120 | QRgb *rgb_data = (QRgb *) data->data; | - | ||||||||||||
1121 | - | |||||||||||||
1122 | for (int i = 0; i < data->height; ++i) { | - | ||||||||||||
1123 | const QRgb *end = rgb_data + data->width; | - | ||||||||||||
1124 | while (rgb_data < end) { | - | ||||||||||||
1125 | *rgb_data = *rgb_data | 0x000000fff; | - | ||||||||||||
1126 | ++rgb_data; | - | ||||||||||||
1127 | } | - | ||||||||||||
1128 | rgb_data += pad; | - | ||||||||||||
1129 | } | - | ||||||||||||
1130 | data->format = QImage::Format_RGBX8888; | - | ||||||||||||
1131 | return true; | - | ||||||||||||
1132 | #endif | - | ||||||||||||
1133 | } | - | ||||||||||||
1134 | - | |||||||||||||
1135 | static QVector<QRgb> fix_color_table(const QVector<QRgb> &ctbl, QImage::Format format) | - | ||||||||||||
1136 | { | - | ||||||||||||
1137 | QVector<QRgb> colorTable = ctbl; | - | ||||||||||||
1138 | if (format == QImage::Format_RGB32) {
| 0 | ||||||||||||
1139 | // check if the color table has alpha | - | ||||||||||||
1140 | for (int i = 0; i < colorTable.size(); ++i)
| 0 | ||||||||||||
1141 | if (qAlpha(colorTable.at(i) != 0xff))
| 0 | ||||||||||||
1142 | colorTable[i] = colorTable.at(i) | 0xff000000; never executed: colorTable[i] = colorTable.at(i) | 0xff000000; | 0 | ||||||||||||
1143 | } else if (format == QImage::Format_ARGB32_Premultiplied) { never executed: end of block
| 0 | ||||||||||||
1144 | // check if the color table has alpha | - | ||||||||||||
1145 | for (int i = 0; i < colorTable.size(); ++i)
| 0 | ||||||||||||
1146 | colorTable[i] = qPremultiply(colorTable.at(i)); never executed: colorTable[i] = qPremultiply(colorTable.at(i)); | 0 | ||||||||||||
1147 | } never executed: end of block | 0 | ||||||||||||
1148 | return colorTable; never executed: return colorTable; | 0 | ||||||||||||
1149 | } | - | ||||||||||||
1150 | - | |||||||||||||
1151 | // | - | ||||||||||||
1152 | // dither_to_1: Uses selected dithering algorithm. | - | ||||||||||||
1153 | // | - | ||||||||||||
1154 | - | |||||||||||||
1155 | void dither_to_Mono(QImageData *dst, const QImageData *src, | - | ||||||||||||
1156 | Qt::ImageConversionFlags flags, bool fromalpha) | - | ||||||||||||
1157 | { | - | ||||||||||||
1158 | Q_ASSERT(src->width == dst->width); | - | ||||||||||||
1159 | Q_ASSERT(src->height == dst->height); | - | ||||||||||||
1160 | Q_ASSERT(dst->format == QImage::Format_Mono || dst->format == QImage::Format_MonoLSB); | - | ||||||||||||
1161 | - | |||||||||||||
1162 | dst->colortable.clear(); | - | ||||||||||||
1163 | dst->colortable.append(0xffffffff); | - | ||||||||||||
1164 | dst->colortable.append(0xff000000); | - | ||||||||||||
1165 | - | |||||||||||||
1166 | enum { Threshold, Ordered, Diffuse } dithermode; | - | ||||||||||||
1167 | - | |||||||||||||
1168 | if (fromalpha) {
| 0 | ||||||||||||
1169 | if ((flags & Qt::AlphaDither_Mask) == Qt::DiffuseAlphaDither)
| 0 | ||||||||||||
1170 | dithermode = Diffuse; never executed: dithermode = Diffuse; | 0 | ||||||||||||
1171 | else if ((flags & Qt::AlphaDither_Mask) == Qt::OrderedAlphaDither)
| 0 | ||||||||||||
1172 | dithermode = Ordered; never executed: dithermode = Ordered; | 0 | ||||||||||||
1173 | else | - | ||||||||||||
1174 | dithermode = Threshold; never executed: dithermode = Threshold; | 0 | ||||||||||||
1175 | } else { | - | ||||||||||||
1176 | if ((flags & Qt::Dither_Mask) == Qt::ThresholdDither)
| 0 | ||||||||||||
1177 | dithermode = Threshold; never executed: dithermode = Threshold; | 0 | ||||||||||||
1178 | else if ((flags & Qt::Dither_Mask) == Qt::OrderedDither)
| 0 | ||||||||||||
1179 | dithermode = Ordered; never executed: dithermode = Ordered; | 0 | ||||||||||||
1180 | else | - | ||||||||||||
1181 | dithermode = Diffuse; never executed: dithermode = Diffuse; | 0 | ||||||||||||
1182 | } | - | ||||||||||||
1183 | - | |||||||||||||
1184 | int w = src->width; | - | ||||||||||||
1185 | int h = src->height; | - | ||||||||||||
1186 | int d = src->depth; | - | ||||||||||||
1187 | uchar gray[256]; // gray map for 8 bit images | - | ||||||||||||
1188 | bool use_gray = (d == 8); | - | ||||||||||||
1189 | if (use_gray) { // make gray map
| 0 | ||||||||||||
1190 | if (fromalpha) {
| 0 | ||||||||||||
1191 | // Alpha 0x00 -> 0 pixels (white) | - | ||||||||||||
1192 | // Alpha 0xFF -> 1 pixels (black) | - | ||||||||||||
1193 | for (int i = 0; i < src->colortable.size(); i++)
| 0 | ||||||||||||
1194 | gray[i] = (255 - (src->colortable.at(i) >> 24)); never executed: gray[i] = (255 - (src->colortable.at(i) >> 24)); | 0 | ||||||||||||
1195 | } else { never executed: end of block | 0 | ||||||||||||
1196 | // Pixel 0x00 -> 1 pixels (black) | - | ||||||||||||
1197 | // Pixel 0xFF -> 0 pixels (white) | - | ||||||||||||
1198 | for (int i = 0; i < src->colortable.size(); i++)
| 0 | ||||||||||||
1199 | gray[i] = qGray(src->colortable.at(i)); never executed: gray[i] = qGray(src->colortable.at(i)); | 0 | ||||||||||||
1200 | } never executed: end of block | 0 | ||||||||||||
1201 | } | - | ||||||||||||
1202 | - | |||||||||||||
1203 | uchar *dst_data = dst->data; | - | ||||||||||||
1204 | int dst_bpl = dst->bytes_per_line; | - | ||||||||||||
1205 | const uchar *src_data = src->data; | - | ||||||||||||
1206 | int src_bpl = src->bytes_per_line; | - | ||||||||||||
1207 | - | |||||||||||||
1208 | switch (dithermode) { | - | ||||||||||||
1209 | case Diffuse: { never executed: case Diffuse: | 0 | ||||||||||||
1210 | QScopedArrayPointer<int> lineBuffer(new int[w * 2]); | - | ||||||||||||
1211 | int *line1 = lineBuffer.data(); | - | ||||||||||||
1212 | int *line2 = lineBuffer.data() + w; | - | ||||||||||||
1213 | int bmwidth = (w+7)/8; | - | ||||||||||||
1214 | - | |||||||||||||
1215 | int *b1, *b2; | - | ||||||||||||
1216 | int wbytes = w * (d/8); | - | ||||||||||||
1217 | const uchar *p = src->data; | - | ||||||||||||
1218 | const uchar *end = p + wbytes; | - | ||||||||||||
1219 | b2 = line2; | - | ||||||||||||
1220 | if (use_gray) { // 8 bit image
| 0 | ||||||||||||
1221 | while (p < end)
| 0 | ||||||||||||
1222 | *b2++ = gray[*p++]; never executed: *b2++ = gray[*p++]; | 0 | ||||||||||||
1223 | } else { // 32 bit image never executed: end of block | 0 | ||||||||||||
1224 | if (fromalpha) {
| 0 | ||||||||||||
1225 | while (p < end) {
| 0 | ||||||||||||
1226 | *b2++ = 255 - (*(const uint*)p >> 24); | - | ||||||||||||
1227 | p += 4; | - | ||||||||||||
1228 | } never executed: end of block | 0 | ||||||||||||
1229 | } else { never executed: end of block | 0 | ||||||||||||
1230 | while (p < end) {
| 0 | ||||||||||||
1231 | *b2++ = qGray(*(const uint*)p); | - | ||||||||||||
1232 | p += 4; | - | ||||||||||||
1233 | } never executed: end of block | 0 | ||||||||||||
1234 | } never executed: end of block | 0 | ||||||||||||
1235 | } | - | ||||||||||||
1236 | for (int y=0; y<h; y++) { // for each scan line...
| 0 | ||||||||||||
1237 | int *tmp = line1; line1 = line2; line2 = tmp; | - | ||||||||||||
1238 | bool not_last_line = y < h - 1; | - | ||||||||||||
1239 | if (not_last_line) { // calc. grayvals for next line
| 0 | ||||||||||||
1240 | p = src->data + (y+1)*src->bytes_per_line; | - | ||||||||||||
1241 | end = p + wbytes; | - | ||||||||||||
1242 | b2 = line2; | - | ||||||||||||
1243 | if (use_gray) { // 8 bit image
| 0 | ||||||||||||
1244 | while (p < end)
| 0 | ||||||||||||
1245 | *b2++ = gray[*p++]; never executed: *b2++ = gray[*p++]; | 0 | ||||||||||||
1246 | } else { // 24 bit image never executed: end of block | 0 | ||||||||||||
1247 | if (fromalpha) {
| 0 | ||||||||||||
1248 | while (p < end) {
| 0 | ||||||||||||
1249 | *b2++ = 255 - (*(const uint*)p >> 24); | - | ||||||||||||
1250 | p += 4; | - | ||||||||||||
1251 | } never executed: end of block | 0 | ||||||||||||
1252 | } else { never executed: end of block | 0 | ||||||||||||
1253 | while (p < end) {
| 0 | ||||||||||||
1254 | *b2++ = qGray(*(const uint*)p); | - | ||||||||||||
1255 | p += 4; | - | ||||||||||||
1256 | } never executed: end of block | 0 | ||||||||||||
1257 | } never executed: end of block | 0 | ||||||||||||
1258 | } | - | ||||||||||||
1259 | } | - | ||||||||||||
1260 | - | |||||||||||||
1261 | int err; | - | ||||||||||||
1262 | uchar *p = dst->data + y*dst->bytes_per_line; | - | ||||||||||||
1263 | memset(p, 0, bmwidth); | - | ||||||||||||
1264 | b1 = line1; | - | ||||||||||||
1265 | b2 = line2; | - | ||||||||||||
1266 | int bit = 7; | - | ||||||||||||
1267 | for (int x=1; x<=w; x++) {
| 0 | ||||||||||||
1268 | if (*b1 < 128) { // black pixel
| 0 | ||||||||||||
1269 | err = *b1++; | - | ||||||||||||
1270 | *p |= 1 << bit; | - | ||||||||||||
1271 | } else { // white pixel never executed: end of block | 0 | ||||||||||||
1272 | err = *b1++ - 255; | - | ||||||||||||
1273 | } never executed: end of block | 0 | ||||||||||||
1274 | if (bit == 0) {
| 0 | ||||||||||||
1275 | p++; | - | ||||||||||||
1276 | bit = 7; | - | ||||||||||||
1277 | } else { never executed: end of block | 0 | ||||||||||||
1278 | bit--; | - | ||||||||||||
1279 | } never executed: end of block | 0 | ||||||||||||
1280 | if (x < w)
| 0 | ||||||||||||
1281 | *b1 += (err*7)>>4; // spread error to right pixel never executed: *b1 += (err*7)>>4; | 0 | ||||||||||||
1282 | if (not_last_line) {
| 0 | ||||||||||||
1283 | b2[0] += (err*5)>>4; // pixel below | - | ||||||||||||
1284 | if (x > 1)
| 0 | ||||||||||||
1285 | b2[-1] += (err*3)>>4; // pixel below left never executed: b2[-1] += (err*3)>>4; | 0 | ||||||||||||
1286 | if (x < w)
| 0 | ||||||||||||
1287 | b2[1] += err>>4; // pixel below right never executed: b2[1] += err>>4; | 0 | ||||||||||||
1288 | } never executed: end of block | 0 | ||||||||||||
1289 | b2++; | - | ||||||||||||
1290 | } never executed: end of block | 0 | ||||||||||||
1291 | } never executed: end of block | 0 | ||||||||||||
1292 | } break; never executed: break; | 0 | ||||||||||||
1293 | case Ordered: { never executed: case Ordered: | 0 | ||||||||||||
1294 | - | |||||||||||||
1295 | memset(dst->data, 0, dst->nbytes); | - | ||||||||||||
1296 | if (d == 32) {
| 0 | ||||||||||||
1297 | for (int i=0; i<h; i++) {
| 0 | ||||||||||||
1298 | const uint *p = (const uint *)src_data; | - | ||||||||||||
1299 | const uint *end = p + w; | - | ||||||||||||
1300 | uchar *m = dst_data; | - | ||||||||||||
1301 | int bit = 7; | - | ||||||||||||
1302 | int j = 0; | - | ||||||||||||
1303 | if (fromalpha) {
| 0 | ||||||||||||
1304 | while (p < end) {
| 0 | ||||||||||||
1305 | if ((*p++ >> 24) >= qt_bayer_matrix[j++&15][i&15])
| 0 | ||||||||||||
1306 | *m |= 1 << bit; never executed: *m |= 1 << bit; | 0 | ||||||||||||
1307 | if (bit == 0) {
| 0 | ||||||||||||
1308 | m++; | - | ||||||||||||
1309 | bit = 7; | - | ||||||||||||
1310 | } else { never executed: end of block | 0 | ||||||||||||
1311 | bit--; | - | ||||||||||||
1312 | } never executed: end of block | 0 | ||||||||||||
1313 | } | - | ||||||||||||
1314 | } else { never executed: end of block | 0 | ||||||||||||
1315 | while (p < end) {
| 0 | ||||||||||||
1316 | if ((uint)qGray(*p++) < qt_bayer_matrix[j++&15][i&15])
| 0 | ||||||||||||
1317 | *m |= 1 << bit; never executed: *m |= 1 << bit; | 0 | ||||||||||||
1318 | if (bit == 0) {
| 0 | ||||||||||||
1319 | m++; | - | ||||||||||||
1320 | bit = 7; | - | ||||||||||||
1321 | } else { never executed: end of block | 0 | ||||||||||||
1322 | bit--; | - | ||||||||||||
1323 | } never executed: end of block | 0 | ||||||||||||
1324 | } | - | ||||||||||||
1325 | } never executed: end of block | 0 | ||||||||||||
1326 | dst_data += dst_bpl; | - | ||||||||||||
1327 | src_data += src_bpl; | - | ||||||||||||
1328 | } never executed: end of block | 0 | ||||||||||||
1329 | } else if (d == 8) { never executed: end of block
| 0 | ||||||||||||
1330 | for (int i=0; i<h; i++) {
| 0 | ||||||||||||
1331 | const uchar *p = src_data; | - | ||||||||||||
1332 | const uchar *end = p + w; | - | ||||||||||||
1333 | uchar *m = dst_data; | - | ||||||||||||
1334 | int bit = 7; | - | ||||||||||||
1335 | int j = 0; | - | ||||||||||||
1336 | while (p < end) {
| 0 | ||||||||||||
1337 | if ((uint)gray[*p++] < qt_bayer_matrix[j++&15][i&15])
| 0 | ||||||||||||
1338 | *m |= 1 << bit; never executed: *m |= 1 << bit; | 0 | ||||||||||||
1339 | if (bit == 0) {
| 0 | ||||||||||||
1340 | m++; | - | ||||||||||||
1341 | bit = 7; | - | ||||||||||||
1342 | } else { never executed: end of block | 0 | ||||||||||||
1343 | bit--; | - | ||||||||||||
1344 | } never executed: end of block | 0 | ||||||||||||
1345 | } | - | ||||||||||||
1346 | dst_data += dst_bpl; | - | ||||||||||||
1347 | src_data += src_bpl; | - | ||||||||||||
1348 | } never executed: end of block | 0 | ||||||||||||
1349 | } never executed: end of block | 0 | ||||||||||||
1350 | } break; never executed: break; | 0 | ||||||||||||
1351 | default: { // Threshold: never executed: default: | 0 | ||||||||||||
1352 | memset(dst->data, 0, dst->nbytes); | - | ||||||||||||
1353 | if (d == 32) {
| 0 | ||||||||||||
1354 | for (int i=0; i<h; i++) {
| 0 | ||||||||||||
1355 | const uint *p = (const uint *)src_data; | - | ||||||||||||
1356 | const uint *end = p + w; | - | ||||||||||||
1357 | uchar *m = dst_data; | - | ||||||||||||
1358 | int bit = 7; | - | ||||||||||||
1359 | if (fromalpha) {
| 0 | ||||||||||||
1360 | while (p < end) {
| 0 | ||||||||||||
1361 | if ((*p++ >> 24) >= 128)
| 0 | ||||||||||||
1362 | *m |= 1 << bit; // Set mask "on" never executed: *m |= 1 << bit; | 0 | ||||||||||||
1363 | if (bit == 0) {
| 0 | ||||||||||||
1364 | m++; | - | ||||||||||||
1365 | bit = 7; | - | ||||||||||||
1366 | } else { never executed: end of block | 0 | ||||||||||||
1367 | bit--; | - | ||||||||||||
1368 | } never executed: end of block | 0 | ||||||||||||
1369 | } | - | ||||||||||||
1370 | } else { never executed: end of block | 0 | ||||||||||||
1371 | while (p < end) {
| 0 | ||||||||||||
1372 | if (qGray(*p++) < 128)
| 0 | ||||||||||||
1373 | *m |= 1 << bit; // Set pixel "black" never executed: *m |= 1 << bit; | 0 | ||||||||||||
1374 | if (bit == 0) {
| 0 | ||||||||||||
1375 | m++; | - | ||||||||||||
1376 | bit = 7; | - | ||||||||||||
1377 | } else { never executed: end of block | 0 | ||||||||||||
1378 | bit--; | - | ||||||||||||
1379 | } never executed: end of block | 0 | ||||||||||||
1380 | } | - | ||||||||||||
1381 | } never executed: end of block | 0 | ||||||||||||
1382 | dst_data += dst_bpl; | - | ||||||||||||
1383 | src_data += src_bpl; | - | ||||||||||||
1384 | } never executed: end of block | 0 | ||||||||||||
1385 | } else never executed: end of block | 0 | ||||||||||||
1386 | if (d == 8) {
| 0 | ||||||||||||
1387 | for (int i=0; i<h; i++) {
| 0 | ||||||||||||
1388 | const uchar *p = src_data; | - | ||||||||||||
1389 | const uchar *end = p + w; | - | ||||||||||||
1390 | uchar *m = dst_data; | - | ||||||||||||
1391 | int bit = 7; | - | ||||||||||||
1392 | while (p < end) {
| 0 | ||||||||||||
1393 | if (gray[*p++] < 128)
| 0 | ||||||||||||
1394 | *m |= 1 << bit; // Set mask "on"/ pixel "black" never executed: *m |= 1 << bit; | 0 | ||||||||||||
1395 | if (bit == 0) {
| 0 | ||||||||||||
1396 | m++; | - | ||||||||||||
1397 | bit = 7; | - | ||||||||||||
1398 | } else { never executed: end of block | 0 | ||||||||||||
1399 | bit--; | - | ||||||||||||
1400 | } never executed: end of block | 0 | ||||||||||||
1401 | } | - | ||||||||||||
1402 | dst_data += dst_bpl; | - | ||||||||||||
1403 | src_data += src_bpl; | - | ||||||||||||
1404 | } never executed: end of block | 0 | ||||||||||||
1405 | } never executed: end of block | 0 | ||||||||||||
1406 | } | - | ||||||||||||
1407 | } never executed: end of block | 0 | ||||||||||||
1408 | - | |||||||||||||
1409 | if (dst->format == QImage::Format_MonoLSB) {
| 0 | ||||||||||||
1410 | // need to swap bit order | - | ||||||||||||
1411 | uchar *sl = dst->data; | - | ||||||||||||
1412 | int bpl = (dst->width + 7) * dst->depth / 8; | - | ||||||||||||
1413 | int pad = dst->bytes_per_line - bpl; | - | ||||||||||||
1414 | for (int y=0; y<dst->height; ++y) {
| 0 | ||||||||||||
1415 | for (int x=0; x<bpl; ++x) {
| 0 | ||||||||||||
1416 | *sl = bitflip[*sl]; | - | ||||||||||||
1417 | ++sl; | - | ||||||||||||
1418 | } never executed: end of block | 0 | ||||||||||||
1419 | sl += pad; | - | ||||||||||||
1420 | } never executed: end of block | 0 | ||||||||||||
1421 | } never executed: end of block | 0 | ||||||||||||
1422 | } never executed: end of block | 0 | ||||||||||||
1423 | - | |||||||||||||
1424 | static void convert_X_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) | - | ||||||||||||
1425 | { | - | ||||||||||||
1426 | dither_to_Mono(dst, src, flags, false); | - | ||||||||||||
1427 | } never executed: end of block | 0 | ||||||||||||
1428 | - | |||||||||||||
1429 | static void convert_ARGB_PM_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) | - | ||||||||||||
1430 | { | - | ||||||||||||
1431 | QScopedPointer<QImageData> tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32)); | - | ||||||||||||
1432 | convert_ARGB_PM_to_ARGB(tmp.data(), src); | - | ||||||||||||
1433 | dither_to_Mono(dst, tmp.data(), flags, false); | - | ||||||||||||
1434 | } never executed: end of block | 0 | ||||||||||||
1435 | - | |||||||||||||
1436 | // | - | ||||||||||||
1437 | // convert_32_to_8: Converts a 32 bits depth (true color) to an 8 bit | - | ||||||||||||
1438 | // image with a colormap. If the 32 bit image has more than 256 colors, | - | ||||||||||||
1439 | // we convert the red,green and blue bytes into a single byte encoded | - | ||||||||||||
1440 | // as 6 shades of each of red, green and blue. | - | ||||||||||||
1441 | // | - | ||||||||||||
1442 | // if dithering is needed, only 1 color at most is available for alpha. | - | ||||||||||||
1443 | // | - | ||||||||||||
1444 | struct QRgbMap { | - | ||||||||||||
1445 | inline QRgbMap() : used(0) { } never executed: end of block | 0 | ||||||||||||
1446 | uchar pix; | - | ||||||||||||
1447 | uchar used; | - | ||||||||||||
1448 | QRgb rgb; | - | ||||||||||||
1449 | }; | - | ||||||||||||
1450 | - | |||||||||||||
1451 | static void convert_RGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) | - | ||||||||||||
1452 | { | - | ||||||||||||
1453 | Q_ASSERT(src->format == QImage::Format_RGB32 || src->format == QImage::Format_ARGB32); | - | ||||||||||||
1454 | Q_ASSERT(dst->format == QImage::Format_Indexed8); | - | ||||||||||||
1455 | Q_ASSERT(src->width == dst->width); | - | ||||||||||||
1456 | Q_ASSERT(src->height == dst->height); | - | ||||||||||||
1457 | - | |||||||||||||
1458 | bool do_quant = (flags & Qt::DitherMode_Mask) == Qt::PreferDither
| 0 | ||||||||||||
1459 | || src->format == QImage::Format_ARGB32;
| 0 | ||||||||||||
1460 | uint alpha_mask = src->format == QImage::Format_RGB32 ? 0xff000000 : 0;
| 0 | ||||||||||||
1461 | - | |||||||||||||
1462 | const int tablesize = 997; // prime | - | ||||||||||||
1463 | QRgbMap table[tablesize]; | - | ||||||||||||
1464 | int pix=0; | - | ||||||||||||
1465 | - | |||||||||||||
1466 | if (!dst->colortable.isEmpty()) {
| 0 | ||||||||||||
1467 | QVector<QRgb> ctbl = dst->colortable; | - | ||||||||||||
1468 | dst->colortable.resize(256); | - | ||||||||||||
1469 | // Preload palette into table. | - | ||||||||||||
1470 | // Almost same code as pixel insertion below | - | ||||||||||||
1471 | for (int i = 0; i < dst->colortable.size(); ++i) {
| 0 | ||||||||||||
1472 | // Find in table... | - | ||||||||||||
1473 | QRgb p = ctbl.at(i) | alpha_mask; | - | ||||||||||||
1474 | int hash = p % tablesize; | - | ||||||||||||
1475 | for (;;) { | - | ||||||||||||
1476 | if (table[hash].used) {
| 0 | ||||||||||||
1477 | if (table[hash].rgb == p) {
| 0 | ||||||||||||
1478 | // Found previous insertion - use it | - | ||||||||||||
1479 | break; never executed: break; | 0 | ||||||||||||
1480 | } else { | - | ||||||||||||
1481 | // Keep searching... | - | ||||||||||||
1482 | if (++hash == tablesize) hash = 0; never executed: hash = 0;
| 0 | ||||||||||||
1483 | } never executed: end of block | 0 | ||||||||||||
1484 | } else { | - | ||||||||||||
1485 | // Cannot be in table | - | ||||||||||||
1486 | Q_ASSERT (pix != 256); // too many colors | - | ||||||||||||
1487 | // Insert into table at this unused position | - | ||||||||||||
1488 | dst->colortable[pix] = p; | - | ||||||||||||
1489 | table[hash].pix = pix++; | - | ||||||||||||
1490 | table[hash].rgb = p; | - | ||||||||||||
1491 | table[hash].used = 1; | - | ||||||||||||
1492 | break; never executed: break; | 0 | ||||||||||||
1493 | } | - | ||||||||||||
1494 | } | - | ||||||||||||
1495 | } never executed: end of block | 0 | ||||||||||||
1496 | } never executed: end of block | 0 | ||||||||||||
1497 | - | |||||||||||||
1498 | if ((flags & Qt::DitherMode_Mask) != Qt::PreferDither) {
| 0 | ||||||||||||
1499 | dst->colortable.resize(256); | - | ||||||||||||
1500 | const uchar *src_data = src->data; | - | ||||||||||||
1501 | uchar *dest_data = dst->data; | - | ||||||||||||
1502 | for (int y = 0; y < src->height; y++) { // check if <= 256 colors
| 0 | ||||||||||||
1503 | const QRgb *s = (const QRgb *)src_data; | - | ||||||||||||
1504 | uchar *b = dest_data; | - | ||||||||||||
1505 | for (int x = 0; x < src->width; ++x) {
| 0 | ||||||||||||
1506 | QRgb p = s[x] | alpha_mask; | - | ||||||||||||
1507 | int hash = p % tablesize; | - | ||||||||||||
1508 | for (;;) { | - | ||||||||||||
1509 | if (table[hash].used) {
| 0 | ||||||||||||
1510 | if (table[hash].rgb == (p)) {
| 0 | ||||||||||||
1511 | // Found previous insertion - use it | - | ||||||||||||
1512 | break; never executed: break; | 0 | ||||||||||||
1513 | } else { | - | ||||||||||||
1514 | // Keep searching... | - | ||||||||||||
1515 | if (++hash == tablesize) hash = 0; never executed: hash = 0;
| 0 | ||||||||||||
1516 | } never executed: end of block | 0 | ||||||||||||
1517 | } else { | - | ||||||||||||
1518 | // Cannot be in table | - | ||||||||||||
1519 | if (pix == 256) { // too many colors
| 0 | ||||||||||||
1520 | do_quant = true; | - | ||||||||||||
1521 | // Break right out | - | ||||||||||||
1522 | x = src->width; | - | ||||||||||||
1523 | y = src->height; | - | ||||||||||||
1524 | } else { never executed: end of block | 0 | ||||||||||||
1525 | // Insert into table at this unused position | - | ||||||||||||
1526 | dst->colortable[pix] = p; | - | ||||||||||||
1527 | table[hash].pix = pix++; | - | ||||||||||||
1528 | table[hash].rgb = p; | - | ||||||||||||
1529 | table[hash].used = 1; | - | ||||||||||||
1530 | } never executed: end of block | 0 | ||||||||||||
1531 | break; never executed: break; | 0 | ||||||||||||
1532 | } | - | ||||||||||||
1533 | } | - | ||||||||||||
1534 | *b++ = table[hash].pix; // May occur once incorrectly | - | ||||||||||||
1535 | } never executed: end of block | 0 | ||||||||||||
1536 | src_data += src->bytes_per_line; | - | ||||||||||||
1537 | dest_data += dst->bytes_per_line; | - | ||||||||||||
1538 | } never executed: end of block | 0 | ||||||||||||
1539 | } never executed: end of block | 0 | ||||||||||||
1540 | int numColors = do_quant ? 256 : pix;
| 0 | ||||||||||||
1541 | - | |||||||||||||
1542 | dst->colortable.resize(numColors); | - | ||||||||||||
1543 | - | |||||||||||||
1544 | if (do_quant) { // quantization needed
| 0 | ||||||||||||
1545 | - | |||||||||||||
1546 | #define MAX_R 5 | - | ||||||||||||
1547 | #define MAX_G 5 | - | ||||||||||||
1548 | #define MAX_B 5 | - | ||||||||||||
1549 | #define INDEXOF(r,g,b) (((r)*(MAX_G+1)+(g))*(MAX_B+1)+(b)) | - | ||||||||||||
1550 | - | |||||||||||||
1551 | for (int rc=0; rc<=MAX_R; rc++) // build 6x6x6 color cube
| 0 | ||||||||||||
1552 | for (int gc=0; gc<=MAX_G; gc++)
| 0 | ||||||||||||
1553 | for (int bc=0; bc<=MAX_B; bc++)
| 0 | ||||||||||||
1554 | dst->colortable[INDEXOF(rc,gc,bc)] = 0xff000000 | qRgb(rc*255/MAX_R, gc*255/MAX_G, bc*255/MAX_B); never executed: dst->colortable[(((rc)*(5 +1)+(gc))*(5 +1)+(bc))] = 0xff000000 | qRgb(rc*255/5, gc*255/5, bc*255/5); | 0 | ||||||||||||
1555 | - | |||||||||||||
1556 | const uchar *src_data = src->data; | - | ||||||||||||
1557 | uchar *dest_data = dst->data; | - | ||||||||||||
1558 | if ((flags & Qt::Dither_Mask) == Qt::ThresholdDither) {
| 0 | ||||||||||||
1559 | for (int y = 0; y < src->height; y++) {
| 0 | ||||||||||||
1560 | const QRgb *p = (const QRgb *)src_data; | - | ||||||||||||
1561 | const QRgb *end = p + src->width; | - | ||||||||||||
1562 | uchar *b = dest_data; | - | ||||||||||||
1563 | - | |||||||||||||
1564 | while (p < end) {
| 0 | ||||||||||||
1565 | #define DITHER(p,m) ((uchar) ((p * (m) + 127) / 255)) | - | ||||||||||||
1566 | *b++ = | - | ||||||||||||
1567 | INDEXOF( | - | ||||||||||||
1568 | DITHER(qRed(*p), MAX_R), | - | ||||||||||||
1569 | DITHER(qGreen(*p), MAX_G), | - | ||||||||||||
1570 | DITHER(qBlue(*p), MAX_B) | - | ||||||||||||
1571 | ); | - | ||||||||||||
1572 | #undef DITHER | - | ||||||||||||
1573 | p++; | - | ||||||||||||
1574 | } never executed: end of block | 0 | ||||||||||||
1575 | src_data += src->bytes_per_line; | - | ||||||||||||
1576 | dest_data += dst->bytes_per_line; | - | ||||||||||||
1577 | } never executed: end of block | 0 | ||||||||||||
1578 | } else if ((flags & Qt::Dither_Mask) == Qt::DiffuseDither) { never executed: end of block
| 0 | ||||||||||||
1579 | int* line1[3]; | - | ||||||||||||
1580 | int* line2[3]; | - | ||||||||||||
1581 | int* pv[3]; | - | ||||||||||||
1582 | QScopedArrayPointer<int> lineBuffer(new int[src->width * 9]); | - | ||||||||||||
1583 | line1[0] = lineBuffer.data(); | - | ||||||||||||
1584 | line2[0] = lineBuffer.data() + src->width; | - | ||||||||||||
1585 | line1[1] = lineBuffer.data() + src->width * 2; | - | ||||||||||||
1586 | line2[1] = lineBuffer.data() + src->width * 3; | - | ||||||||||||
1587 | line1[2] = lineBuffer.data() + src->width * 4; | - | ||||||||||||
1588 | line2[2] = lineBuffer.data() + src->width * 5; | - | ||||||||||||
1589 | pv[0] = lineBuffer.data() + src->width * 6; | - | ||||||||||||
1590 | pv[1] = lineBuffer.data() + src->width * 7; | - | ||||||||||||
1591 | pv[2] = lineBuffer.data() + src->width * 8; | - | ||||||||||||
1592 | - | |||||||||||||
1593 | int endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian); | - | ||||||||||||
1594 | for (int y = 0; y < src->height; y++) {
| 0 | ||||||||||||
1595 | const uchar* q = src_data; | - | ||||||||||||
1596 | const uchar* q2 = y < src->height - 1 ? q + src->bytes_per_line : src->data;
| 0 | ||||||||||||
1597 | uchar *b = dest_data; | - | ||||||||||||
1598 | for (int chan = 0; chan < 3; chan++) {
| 0 | ||||||||||||
1599 | int *l1 = (y&1) ? line2[chan] : line1[chan];
| 0 | ||||||||||||
1600 | int *l2 = (y&1) ? line1[chan] : line2[chan];
| 0 | ||||||||||||
1601 | if (y == 0) {
| 0 | ||||||||||||
1602 | for (int i = 0; i < src->width; i++)
| 0 | ||||||||||||
1603 | l1[i] = q[i*4+chan+endian]; never executed: l1[i] = q[i*4+chan+endian]; | 0 | ||||||||||||
1604 | } never executed: end of block | 0 | ||||||||||||
1605 | if (y+1 < src->height) {
| 0 | ||||||||||||
1606 | for (int i = 0; i < src->width; i++)
| 0 | ||||||||||||
1607 | l2[i] = q2[i*4+chan+endian]; never executed: l2[i] = q2[i*4+chan+endian]; | 0 | ||||||||||||
1608 | } never executed: end of block | 0 | ||||||||||||
1609 | // Bi-directional error diffusion | - | ||||||||||||
1610 | if (y&1) {
| 0 | ||||||||||||
1611 | for (int x = 0; x < src->width; x++) {
| 0 | ||||||||||||
1612 | int pix = qMax(qMin(5, (l1[x] * 5 + 128)/ 255), 0); | - | ||||||||||||
1613 | int err = l1[x] - pix * 255 / 5; | - | ||||||||||||
1614 | pv[chan][x] = pix; | - | ||||||||||||
1615 | - | |||||||||||||
1616 | // Spread the error around... | - | ||||||||||||
1617 | if (x + 1< src->width) {
| 0 | ||||||||||||
1618 | l1[x+1] += (err*7)>>4; | - | ||||||||||||
1619 | l2[x+1] += err>>4; | - | ||||||||||||
1620 | } never executed: end of block | 0 | ||||||||||||
1621 | l2[x]+=(err*5)>>4; | - | ||||||||||||
1622 | if (x>1)
| 0 | ||||||||||||
1623 | l2[x-1]+=(err*3)>>4; never executed: l2[x-1]+=(err*3)>>4; | 0 | ||||||||||||
1624 | } never executed: end of block | 0 | ||||||||||||
1625 | } else { never executed: end of block | 0 | ||||||||||||
1626 | for (int x = src->width; x-- > 0;) {
| 0 | ||||||||||||
1627 | int pix = qMax(qMin(5, (l1[x] * 5 + 128)/ 255), 0); | - | ||||||||||||
1628 | int err = l1[x] - pix * 255 / 5; | - | ||||||||||||
1629 | pv[chan][x] = pix; | - | ||||||||||||
1630 | - | |||||||||||||
1631 | // Spread the error around... | - | ||||||||||||
1632 | if (x > 0) {
| 0 | ||||||||||||
1633 | l1[x-1] += (err*7)>>4; | - | ||||||||||||
1634 | l2[x-1] += err>>4; | - | ||||||||||||
1635 | } never executed: end of block | 0 | ||||||||||||
1636 | l2[x]+=(err*5)>>4; | - | ||||||||||||
1637 | if (x + 1 < src->width)
| 0 | ||||||||||||
1638 | l2[x+1]+=(err*3)>>4; never executed: l2[x+1]+=(err*3)>>4; | 0 | ||||||||||||
1639 | } never executed: end of block | 0 | ||||||||||||
1640 | } never executed: end of block | 0 | ||||||||||||
1641 | } | - | ||||||||||||
1642 | if (endian) {
| 0 | ||||||||||||
1643 | for (int x = 0; x < src->width; x++) {
| 0 | ||||||||||||
1644 | *b++ = INDEXOF(pv[0][x],pv[1][x],pv[2][x]); | - | ||||||||||||
1645 | } never executed: end of block | 0 | ||||||||||||
1646 | } else { never executed: end of block | 0 | ||||||||||||
1647 | for (int x = 0; x < src->width; x++) {
| 0 | ||||||||||||
1648 | *b++ = INDEXOF(pv[2][x],pv[1][x],pv[0][x]); | - | ||||||||||||
1649 | } never executed: end of block | 0 | ||||||||||||
1650 | } never executed: end of block | 0 | ||||||||||||
1651 | src_data += src->bytes_per_line; | - | ||||||||||||
1652 | dest_data += dst->bytes_per_line; | - | ||||||||||||
1653 | } never executed: end of block | 0 | ||||||||||||
1654 | } else { // OrderedDither never executed: end of block | 0 | ||||||||||||
1655 | for (int y = 0; y < src->height; y++) {
| 0 | ||||||||||||
1656 | const QRgb *p = (const QRgb *)src_data; | - | ||||||||||||
1657 | const QRgb *end = p + src->width; | - | ||||||||||||
1658 | uchar *b = dest_data; | - | ||||||||||||
1659 | - | |||||||||||||
1660 | int x = 0; | - | ||||||||||||
1661 | while (p < end) {
| 0 | ||||||||||||
1662 | uint d = qt_bayer_matrix[y & 15][x & 15] << 8; | - | ||||||||||||
1663 | - | |||||||||||||
1664 | #define DITHER(p, d, m) ((uchar) ((((256 * (m) + (m) + 1)) * (p) + (d)) >> 16)) | - | ||||||||||||
1665 | *b++ = | - | ||||||||||||
1666 | INDEXOF( | - | ||||||||||||
1667 | DITHER(qRed(*p), d, MAX_R), | - | ||||||||||||
1668 | DITHER(qGreen(*p), d, MAX_G), | - | ||||||||||||
1669 | DITHER(qBlue(*p), d, MAX_B) | - | ||||||||||||
1670 | ); | - | ||||||||||||
1671 | #undef DITHER | - | ||||||||||||
1672 | - | |||||||||||||
1673 | p++; | - | ||||||||||||
1674 | x++; | - | ||||||||||||
1675 | } never executed: end of block | 0 | ||||||||||||
1676 | src_data += src->bytes_per_line; | - | ||||||||||||
1677 | dest_data += dst->bytes_per_line; | - | ||||||||||||
1678 | } never executed: end of block | 0 | ||||||||||||
1679 | } never executed: end of block | 0 | ||||||||||||
1680 | - | |||||||||||||
1681 | if (src->format != QImage::Format_RGB32
| 0 | ||||||||||||
1682 | && src->format != QImage::Format_RGB16) {
| 0 | ||||||||||||
1683 | const int trans = 216; | - | ||||||||||||
1684 | Q_ASSERT(dst->colortable.size() > trans); | - | ||||||||||||
1685 | dst->colortable[trans] = 0; | - | ||||||||||||
1686 | QScopedPointer<QImageData> mask(QImageData::create(QSize(src->width, src->height), QImage::Format_Mono)); | - | ||||||||||||
1687 | dither_to_Mono(mask.data(), src, flags, true); | - | ||||||||||||
1688 | uchar *dst_data = dst->data; | - | ||||||||||||
1689 | const uchar *mask_data = mask->data; | - | ||||||||||||
1690 | for (int y = 0; y < src->height; y++) {
| 0 | ||||||||||||
1691 | for (int x = 0; x < src->width ; x++) {
| 0 | ||||||||||||
1692 | if (!(mask_data[x>>3] & (0x80 >> (x & 7))))
| 0 | ||||||||||||
1693 | dst_data[x] = trans; never executed: dst_data[x] = trans; | 0 | ||||||||||||
1694 | } never executed: end of block | 0 | ||||||||||||
1695 | mask_data += mask->bytes_per_line; | - | ||||||||||||
1696 | dst_data += dst->bytes_per_line; | - | ||||||||||||
1697 | } never executed: end of block | 0 | ||||||||||||
1698 | dst->has_alpha_clut = true; | - | ||||||||||||
1699 | } never executed: end of block | 0 | ||||||||||||
1700 | - | |||||||||||||
1701 | #undef MAX_R | - | ||||||||||||
1702 | #undef MAX_G | - | ||||||||||||
1703 | #undef MAX_B | - | ||||||||||||
1704 | #undef INDEXOF | - | ||||||||||||
1705 | - | |||||||||||||
1706 | } never executed: end of block | 0 | ||||||||||||
1707 | } never executed: end of block | 0 | ||||||||||||
1708 | - | |||||||||||||
1709 | static void convert_ARGB_PM_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) | - | ||||||||||||
1710 | { | - | ||||||||||||
1711 | QScopedPointer<QImageData> tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32)); | - | ||||||||||||
1712 | convert_ARGB_PM_to_ARGB(tmp.data(), src); | - | ||||||||||||
1713 | convert_RGB_to_Indexed8(dst, tmp.data(), flags); | - | ||||||||||||
1714 | } never executed: end of block | 0 | ||||||||||||
1715 | - | |||||||||||||
1716 | static void convert_ARGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) | - | ||||||||||||
1717 | { | - | ||||||||||||
1718 | convert_RGB_to_Indexed8(dst, src, flags); | - | ||||||||||||
1719 | } never executed: end of block | 0 | ||||||||||||
1720 | - | |||||||||||||
1721 | static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
1722 | { | - | ||||||||||||
1723 | Q_ASSERT(src->format == QImage::Format_Indexed8); | - | ||||||||||||
1724 | Q_ASSERT(dest->format == QImage::Format_RGB32 | - | ||||||||||||
1725 | || dest->format == QImage::Format_ARGB32 | - | ||||||||||||
1726 | || dest->format == QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||
1727 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
1728 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
1729 | - | |||||||||||||
1730 | QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format); | - | ||||||||||||
1731 | if (colorTable.size() == 0) {
| 0 | ||||||||||||
1732 | colorTable.resize(256); | - | ||||||||||||
1733 | for (int i=0; i<256; ++i)
| 0 | ||||||||||||
1734 | colorTable[i] = qRgb(i, i, i); never executed: colorTable[i] = qRgb(i, i, i); | 0 | ||||||||||||
1735 | } never executed: end of block | 0 | ||||||||||||
1736 | - | |||||||||||||
1737 | int w = src->width; | - | ||||||||||||
1738 | const uchar *src_data = src->data; | - | ||||||||||||
1739 | uchar *dest_data = dest->data; | - | ||||||||||||
1740 | int tableSize = colorTable.size() - 1; | - | ||||||||||||
1741 | for (int y = 0; y < src->height; y++) {
| 0 | ||||||||||||
1742 | uint *p = (uint *)dest_data; | - | ||||||||||||
1743 | const uchar *b = src_data; | - | ||||||||||||
1744 | uint *end = p + w; | - | ||||||||||||
1745 | - | |||||||||||||
1746 | while (p < end)
| 0 | ||||||||||||
1747 | *p++ = colorTable.at(qMin<int>(tableSize, *b++)); never executed: *p++ = colorTable.at(qMin<int>(tableSize, *b++)); | 0 | ||||||||||||
1748 | - | |||||||||||||
1749 | src_data += src->bytes_per_line; | - | ||||||||||||
1750 | dest_data += dest->bytes_per_line; | - | ||||||||||||
1751 | } never executed: end of block | 0 | ||||||||||||
1752 | } never executed: end of block | 0 | ||||||||||||
1753 | - | |||||||||||||
1754 | static void convert_Mono_to_X32(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
1755 | { | - | ||||||||||||
1756 | Q_ASSERT(src->format == QImage::Format_Mono || src->format == QImage::Format_MonoLSB); | - | ||||||||||||
1757 | Q_ASSERT(dest->format == QImage::Format_RGB32 | - | ||||||||||||
1758 | || dest->format == QImage::Format_ARGB32 | - | ||||||||||||
1759 | || dest->format == QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||
1760 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
1761 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
1762 | - | |||||||||||||
1763 | QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format); | - | ||||||||||||
1764 | - | |||||||||||||
1765 | // Default to black / white colors | - | ||||||||||||
1766 | if (colorTable.size() < 2) {
| 0 | ||||||||||||
1767 | if (colorTable.size() == 0)
| 0 | ||||||||||||
1768 | colorTable << 0xff000000; never executed: colorTable << 0xff000000; | 0 | ||||||||||||
1769 | colorTable << 0xffffffff; | - | ||||||||||||
1770 | } never executed: end of block | 0 | ||||||||||||
1771 | - | |||||||||||||
1772 | const uchar *src_data = src->data; | - | ||||||||||||
1773 | uchar *dest_data = dest->data; | - | ||||||||||||
1774 | if (src->format == QImage::Format_Mono) {
| 0 | ||||||||||||
1775 | for (int y = 0; y < dest->height; y++) {
| 0 | ||||||||||||
1776 | uint *p = (uint *)dest_data; | - | ||||||||||||
1777 | for (int x = 0; x < dest->width; x++)
| 0 | ||||||||||||
1778 | *p++ = colorTable.at((src_data[x>>3] >> (7 - (x & 7))) & 1); never executed: *p++ = colorTable.at((src_data[x>>3] >> (7 - (x & 7))) & 1); | 0 | ||||||||||||
1779 | - | |||||||||||||
1780 | src_data += src->bytes_per_line; | - | ||||||||||||
1781 | dest_data += dest->bytes_per_line; | - | ||||||||||||
1782 | } never executed: end of block | 0 | ||||||||||||
1783 | } else { never executed: end of block | 0 | ||||||||||||
1784 | for (int y = 0; y < dest->height; y++) {
| 0 | ||||||||||||
1785 | uint *p = (uint *)dest_data; | - | ||||||||||||
1786 | for (int x = 0; x < dest->width; x++)
| 0 | ||||||||||||
1787 | *p++ = colorTable.at((src_data[x>>3] >> (x & 7)) & 1); never executed: *p++ = colorTable.at((src_data[x>>3] >> (x & 7)) & 1); | 0 | ||||||||||||
1788 | - | |||||||||||||
1789 | src_data += src->bytes_per_line; | - | ||||||||||||
1790 | dest_data += dest->bytes_per_line; | - | ||||||||||||
1791 | } never executed: end of block | 0 | ||||||||||||
1792 | } never executed: end of block | 0 | ||||||||||||
1793 | } | - | ||||||||||||
1794 | - | |||||||||||||
1795 | - | |||||||||||||
1796 | static void convert_Mono_to_Indexed8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
1797 | { | - | ||||||||||||
1798 | Q_ASSERT(src->format == QImage::Format_Mono || src->format == QImage::Format_MonoLSB); | - | ||||||||||||
1799 | Q_ASSERT(dest->format == QImage::Format_Indexed8); | - | ||||||||||||
1800 | Q_ASSERT(src->width == dest->width); | - | ||||||||||||
1801 | Q_ASSERT(src->height == dest->height); | - | ||||||||||||
1802 | - | |||||||||||||
1803 | QVector<QRgb> ctbl = src->colortable; | - | ||||||||||||
1804 | if (ctbl.size() > 2) {
| 0 | ||||||||||||
1805 | ctbl.resize(2); | - | ||||||||||||
1806 | } else if (ctbl.size() < 2) { never executed: end of block
| 0 | ||||||||||||
1807 | if (ctbl.size() == 0)
| 0 | ||||||||||||
1808 | ctbl << 0xff000000; never executed: ctbl << 0xff000000; | 0 | ||||||||||||
1809 | ctbl << 0xffffffff; | - | ||||||||||||
1810 | } never executed: end of block | 0 | ||||||||||||
1811 | dest->colortable = ctbl; | - | ||||||||||||
1812 | dest->has_alpha_clut = src->has_alpha_clut; | - | ||||||||||||
1813 | - | |||||||||||||
1814 | - | |||||||||||||
1815 | const uchar *src_data = src->data; | - | ||||||||||||
1816 | uchar *dest_data = dest->data; | - | ||||||||||||
1817 | if (src->format == QImage::Format_Mono) {
| 0 | ||||||||||||
1818 | for (int y = 0; y < dest->height; y++) {
| 0 | ||||||||||||
1819 | uchar *p = dest_data; | - | ||||||||||||
1820 | for (int x = 0; x < dest->width; x++)
| 0 | ||||||||||||
1821 | *p++ = (src_data[x>>3] >> (7 - (x & 7))) & 1; never executed: *p++ = (src_data[x>>3] >> (7 - (x & 7))) & 1; | 0 | ||||||||||||
1822 | src_data += src->bytes_per_line; | - | ||||||||||||
1823 | dest_data += dest->bytes_per_line; | - | ||||||||||||
1824 | } never executed: end of block | 0 | ||||||||||||
1825 | } else { never executed: end of block | 0 | ||||||||||||
1826 | for (int y = 0; y < dest->height; y++) {
| 0 | ||||||||||||
1827 | uchar *p = dest_data; | - | ||||||||||||
1828 | for (int x = 0; x < dest->width; x++)
| 0 | ||||||||||||
1829 | *p++ = (src_data[x>>3] >> (x & 7)) & 1; never executed: *p++ = (src_data[x>>3] >> (x & 7)) & 1; | 0 | ||||||||||||
1830 | src_data += src->bytes_per_line; | - | ||||||||||||
1831 | dest_data += dest->bytes_per_line; | - | ||||||||||||
1832 | } never executed: end of block | 0 | ||||||||||||
1833 | } never executed: end of block | 0 | ||||||||||||
1834 | } | - | ||||||||||||
1835 | - | |||||||||||||
1836 | static void convert_Indexed8_to_Alpha8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
1837 | { | - | ||||||||||||
1838 | Q_ASSERT(src->format == QImage::Format_Indexed8); | - | ||||||||||||
1839 | Q_ASSERT(dest->format == QImage::Format_Alpha8); | - | ||||||||||||
1840 | - | |||||||||||||
1841 | uchar translate[256]; | - | ||||||||||||
1842 | const QVector<QRgb> &colors = src->colortable; | - | ||||||||||||
1843 | bool simpleCase = (colors.size() == 256); | - | ||||||||||||
1844 | for (int i = 0; i < colors.size(); ++i) {
| 0 | ||||||||||||
1845 | uchar alpha = qAlpha(colors[i]); | - | ||||||||||||
1846 | translate[i] = alpha; | - | ||||||||||||
1847 | simpleCase = simpleCase && (alpha == i);
| 0 | ||||||||||||
1848 | } never executed: end of block | 0 | ||||||||||||
1849 | - | |||||||||||||
1850 | if (simpleCase)
| 0 | ||||||||||||
1851 | memcpy(dest->data, src->data, src->bytes_per_line * src->height); never executed: memcpy(dest->data, src->data, src->bytes_per_line * src->height); | 0 | ||||||||||||
1852 | else { | - | ||||||||||||
1853 | int size = src->bytes_per_line * src->height; | - | ||||||||||||
1854 | for (int i = 0; i < size; ++i) {
| 0 | ||||||||||||
1855 | dest->data[i] = translate[src->data[i]]; | - | ||||||||||||
1856 | } never executed: end of block | 0 | ||||||||||||
1857 | } never executed: end of block | 0 | ||||||||||||
1858 | } | - | ||||||||||||
1859 | - | |||||||||||||
1860 | static void convert_Indexed8_to_Grayscale8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
1861 | { | - | ||||||||||||
1862 | Q_ASSERT(src->format == QImage::Format_Indexed8); | - | ||||||||||||
1863 | Q_ASSERT(dest->format == QImage::Format_Grayscale8); | - | ||||||||||||
1864 | - | |||||||||||||
1865 | uchar translate[256]; | - | ||||||||||||
1866 | const QVector<QRgb> &colors = src->colortable; | - | ||||||||||||
1867 | bool simpleCase = (colors.size() == 256); | - | ||||||||||||
1868 | for (int i = 0; i < colors.size(); ++i) {
| 0 | ||||||||||||
1869 | uchar gray = qGray(colors[i]); | - | ||||||||||||
1870 | translate[i] = gray; | - | ||||||||||||
1871 | simpleCase = simpleCase && (gray == i);
| 0 | ||||||||||||
1872 | } never executed: end of block | 0 | ||||||||||||
1873 | - | |||||||||||||
1874 | if (simpleCase)
| 0 | ||||||||||||
1875 | memcpy(dest->data, src->data, src->bytes_per_line * src->height); never executed: memcpy(dest->data, src->data, src->bytes_per_line * src->height); | 0 | ||||||||||||
1876 | else { | - | ||||||||||||
1877 | int size = src->bytes_per_line * src->height; | - | ||||||||||||
1878 | for (int i = 0; i < size; ++i) {
| 0 | ||||||||||||
1879 | dest->data[i] = translate[src->data[i]]; | - | ||||||||||||
1880 | } never executed: end of block | 0 | ||||||||||||
1881 | } never executed: end of block | 0 | ||||||||||||
1882 | } | - | ||||||||||||
1883 | - | |||||||||||||
1884 | static bool convert_Indexed8_to_Alpha8_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
1885 | { | - | ||||||||||||
1886 | Q_ASSERT(data->format == QImage::Format_Indexed8); | - | ||||||||||||
1887 | - | |||||||||||||
1888 | // Just check if this is an Alpha8 in Indexed8 disguise. | - | ||||||||||||
1889 | const QVector<QRgb> &colors = data->colortable; | - | ||||||||||||
1890 | if (colors.size() != 256)
| 0 | ||||||||||||
1891 | return false; never executed: return false; | 0 | ||||||||||||
1892 | for (int i = 0; i < colors.size(); ++i) {
| 0 | ||||||||||||
1893 | if (i != qAlpha(colors[i]))
| 0 | ||||||||||||
1894 | return false; never executed: return false; | 0 | ||||||||||||
1895 | } never executed: end of block | 0 | ||||||||||||
1896 | - | |||||||||||||
1897 | data->colortable.clear(); | - | ||||||||||||
1898 | data->format = QImage::Format_Alpha8; | - | ||||||||||||
1899 | - | |||||||||||||
1900 | return true; never executed: return true; | 0 | ||||||||||||
1901 | } | - | ||||||||||||
1902 | - | |||||||||||||
1903 | static bool convert_Indexed8_to_Grayscale8_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
1904 | { | - | ||||||||||||
1905 | Q_ASSERT(data->format == QImage::Format_Indexed8); | - | ||||||||||||
1906 | - | |||||||||||||
1907 | // Just check if this is a Grayscale8 in Indexed8 disguise. | - | ||||||||||||
1908 | const QVector<QRgb> &colors = data->colortable; | - | ||||||||||||
1909 | if (colors.size() != 256)
| 0 | ||||||||||||
1910 | return false; never executed: return false; | 0 | ||||||||||||
1911 | for (int i = 0; i < colors.size(); ++i) {
| 0 | ||||||||||||
1912 | if (i != qGray(colors[i]))
| 0 | ||||||||||||
1913 | return false; never executed: return false; | 0 | ||||||||||||
1914 | } never executed: end of block | 0 | ||||||||||||
1915 | - | |||||||||||||
1916 | data->colortable.clear(); | - | ||||||||||||
1917 | data->format = QImage::Format_Grayscale8; | - | ||||||||||||
1918 | - | |||||||||||||
1919 | return true; never executed: return true; | 0 | ||||||||||||
1920 | } | - | ||||||||||||
1921 | - | |||||||||||||
1922 | static void convert_Alpha8_to_Indexed8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
1923 | { | - | ||||||||||||
1924 | Q_ASSERT(src->format == QImage::Format_Alpha8); | - | ||||||||||||
1925 | Q_ASSERT(dest->format == QImage::Format_Indexed8); | - | ||||||||||||
1926 | - | |||||||||||||
1927 | memcpy(dest->data, src->data, src->bytes_per_line * src->height); | - | ||||||||||||
1928 | - | |||||||||||||
1929 | QVector<QRgb> colors(256); | - | ||||||||||||
1930 | for (int i=0; i<256; ++i)
| 0 | ||||||||||||
1931 | colors[i] = qRgba(0, 0, 0, i); never executed: colors[i] = qRgba(0, 0, 0, i); | 0 | ||||||||||||
1932 | - | |||||||||||||
1933 | dest->colortable = colors; | - | ||||||||||||
1934 | } never executed: end of block | 0 | ||||||||||||
1935 | - | |||||||||||||
1936 | static void convert_Grayscale8_to_Indexed8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - | ||||||||||||
1937 | { | - | ||||||||||||
1938 | Q_ASSERT(src->format == QImage::Format_Grayscale8); | - | ||||||||||||
1939 | Q_ASSERT(dest->format == QImage::Format_Indexed8); | - | ||||||||||||
1940 | - | |||||||||||||
1941 | memcpy(dest->data, src->data, src->bytes_per_line * src->height); | - | ||||||||||||
1942 | - | |||||||||||||
1943 | QVector<QRgb> colors(256); | - | ||||||||||||
1944 | for (int i=0; i<256; ++i)
| 0 | ||||||||||||
1945 | colors[i] = qRgb(i, i, i); never executed: colors[i] = qRgb(i, i, i); | 0 | ||||||||||||
1946 | - | |||||||||||||
1947 | dest->colortable = colors; | - | ||||||||||||
1948 | } never executed: end of block | 0 | ||||||||||||
1949 | - | |||||||||||||
1950 | static bool convert_Alpha8_to_Indexed8_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
1951 | { | - | ||||||||||||
1952 | Q_ASSERT(data->format == QImage::Format_Alpha8); | - | ||||||||||||
1953 | - | |||||||||||||
1954 | QVector<QRgb> colors(256); | - | ||||||||||||
1955 | for (int i=0; i<256; ++i)
| 0 | ||||||||||||
1956 | colors[i] = qRgba(0, 0, 0, i); never executed: colors[i] = qRgba(0, 0, 0, i); | 0 | ||||||||||||
1957 | - | |||||||||||||
1958 | data->colortable = colors; | - | ||||||||||||
1959 | data->format = QImage::Format_Indexed8; | - | ||||||||||||
1960 | - | |||||||||||||
1961 | return true; never executed: return true; | 0 | ||||||||||||
1962 | } | - | ||||||||||||
1963 | - | |||||||||||||
1964 | static bool convert_Grayscale8_to_Indexed8_inplace(QImageData *data, Qt::ImageConversionFlags) | - | ||||||||||||
1965 | { | - | ||||||||||||
1966 | Q_ASSERT(data->format == QImage::Format_Grayscale8); | - | ||||||||||||
1967 | - | |||||||||||||
1968 | QVector<QRgb> colors(256); | - | ||||||||||||
1969 | for (int i=0; i<256; ++i)
| 0 | ||||||||||||
1970 | colors[i] = qRgb(i, i, i); never executed: colors[i] = qRgb(i, i, i); | 0 | ||||||||||||
1971 | - | |||||||||||||
1972 | data->colortable = colors; | - | ||||||||||||
1973 | data->format = QImage::Format_Indexed8; | - | ||||||||||||
1974 | - | |||||||||||||
1975 | return true; never executed: return true; | 0 | ||||||||||||
1976 | } | - | ||||||||||||
1977 | - | |||||||||||||
1978 | - | |||||||||||||
1979 | // first index source, second dest | - | ||||||||||||
1980 | Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormats] = | - | ||||||||||||
1981 | { | - | ||||||||||||
1982 | { | - | ||||||||||||
1983 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
1984 | }, | - | ||||||||||||
1985 | { | - | ||||||||||||
1986 | 0, | - | ||||||||||||
1987 | 0, | - | ||||||||||||
1988 | swap_bit_order, | - | ||||||||||||
1989 | convert_Mono_to_Indexed8, | - | ||||||||||||
1990 | convert_Mono_to_X32, | - | ||||||||||||
1991 | convert_Mono_to_X32, | - | ||||||||||||
1992 | convert_Mono_to_X32, | - | ||||||||||||
1993 | 0, | - | ||||||||||||
1994 | 0, | - | ||||||||||||
1995 | 0, | - | ||||||||||||
1996 | 0, | - | ||||||||||||
1997 | 0, | - | ||||||||||||
1998 | 0, | - | ||||||||||||
1999 | 0, | - | ||||||||||||
2000 | 0, | - | ||||||||||||
2001 | 0, | - | ||||||||||||
2002 | 0, | - | ||||||||||||
2003 | 0, | - | ||||||||||||
2004 | 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2005 | }, // Format_Mono | - | ||||||||||||
2006 | - | |||||||||||||
2007 | { | - | ||||||||||||
2008 | 0, | - | ||||||||||||
2009 | swap_bit_order, | - | ||||||||||||
2010 | 0, | - | ||||||||||||
2011 | convert_Mono_to_Indexed8, | - | ||||||||||||
2012 | convert_Mono_to_X32, | - | ||||||||||||
2013 | convert_Mono_to_X32, | - | ||||||||||||
2014 | convert_Mono_to_X32, | - | ||||||||||||
2015 | 0, | - | ||||||||||||
2016 | 0, | - | ||||||||||||
2017 | 0, | - | ||||||||||||
2018 | 0, | - | ||||||||||||
2019 | 0, | - | ||||||||||||
2020 | 0, | - | ||||||||||||
2021 | 0, | - | ||||||||||||
2022 | 0, | - | ||||||||||||
2023 | 0, | - | ||||||||||||
2024 | 0, | - | ||||||||||||
2025 | 0, | - | ||||||||||||
2026 | 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2027 | }, // Format_MonoLSB | - | ||||||||||||
2028 | - | |||||||||||||
2029 | { | - | ||||||||||||
2030 | 0, | - | ||||||||||||
2031 | convert_X_to_Mono, | - | ||||||||||||
2032 | convert_X_to_Mono, | - | ||||||||||||
2033 | 0, | - | ||||||||||||
2034 | convert_Indexed8_to_X32, | - | ||||||||||||
2035 | convert_Indexed8_to_X32, | - | ||||||||||||
2036 | convert_Indexed8_to_X32, | - | ||||||||||||
2037 | 0, | - | ||||||||||||
2038 | 0, | - | ||||||||||||
2039 | 0, | - | ||||||||||||
2040 | 0, | - | ||||||||||||
2041 | 0, | - | ||||||||||||
2042 | 0, | - | ||||||||||||
2043 | 0, | - | ||||||||||||
2044 | 0, | - | ||||||||||||
2045 | 0, | - | ||||||||||||
2046 | 0, | - | ||||||||||||
2047 | 0, | - | ||||||||||||
2048 | 0, 0, 0, 0, 0, | - | ||||||||||||
2049 | convert_Indexed8_to_Alpha8, | - | ||||||||||||
2050 | convert_Indexed8_to_Grayscale8, | - | ||||||||||||
2051 | }, // Format_Indexed8 | - | ||||||||||||
2052 | - | |||||||||||||
2053 | { | - | ||||||||||||
2054 | 0, | - | ||||||||||||
2055 | convert_X_to_Mono, | - | ||||||||||||
2056 | convert_X_to_Mono, | - | ||||||||||||
2057 | convert_RGB_to_Indexed8, | - | ||||||||||||
2058 | 0, | - | ||||||||||||
2059 | mask_alpha_converter, | - | ||||||||||||
2060 | mask_alpha_converter, | - | ||||||||||||
2061 | 0, | - | ||||||||||||
2062 | 0, | - | ||||||||||||
2063 | 0, | - | ||||||||||||
2064 | 0, | - | ||||||||||||
2065 | 0, | - | ||||||||||||
2066 | 0, | - | ||||||||||||
2067 | 0, | - | ||||||||||||
2068 | 0, | - | ||||||||||||
2069 | 0, | - | ||||||||||||
2070 | 0, | - | ||||||||||||
2071 | 0, | - | ||||||||||||
2072 | 0, | - | ||||||||||||
2073 | convert_RGB_to_RGB30<PixelOrderBGR>, | - | ||||||||||||
2074 | 0, | - | ||||||||||||
2075 | convert_RGB_to_RGB30<PixelOrderRGB>, | - | ||||||||||||
2076 | 0, | - | ||||||||||||
2077 | 0, 0 | - | ||||||||||||
2078 | }, // Format_RGB32 | - | ||||||||||||
2079 | - | |||||||||||||
2080 | { | - | ||||||||||||
2081 | 0, | - | ||||||||||||
2082 | convert_X_to_Mono, | - | ||||||||||||
2083 | convert_X_to_Mono, | - | ||||||||||||
2084 | convert_ARGB_to_Indexed8, | - | ||||||||||||
2085 | mask_alpha_converter, | - | ||||||||||||
2086 | 0, | - | ||||||||||||
2087 | convert_ARGB_to_ARGB_PM, | - | ||||||||||||
2088 | 0, | - | ||||||||||||
2089 | 0, | - | ||||||||||||
2090 | 0, | - | ||||||||||||
2091 | 0, | - | ||||||||||||
2092 | 0, | - | ||||||||||||
2093 | 0, | - | ||||||||||||
2094 | 0, | - | ||||||||||||
2095 | 0, | - | ||||||||||||
2096 | 0, | - | ||||||||||||
2097 | convert_ARGB_to_RGBx, | - | ||||||||||||
2098 | convert_ARGB_to_RGBA, | - | ||||||||||||
2099 | 0, | - | ||||||||||||
2100 | convert_RGB_to_RGB30<PixelOrderBGR>, | - | ||||||||||||
2101 | 0, | - | ||||||||||||
2102 | convert_RGB_to_RGB30<PixelOrderRGB>, | - | ||||||||||||
2103 | 0, | - | ||||||||||||
2104 | 0, 0 | - | ||||||||||||
2105 | }, // Format_ARGB32 | - | ||||||||||||
2106 | - | |||||||||||||
2107 | { | - | ||||||||||||
2108 | 0, | - | ||||||||||||
2109 | convert_ARGB_PM_to_Mono, | - | ||||||||||||
2110 | convert_ARGB_PM_to_Mono, | - | ||||||||||||
2111 | convert_ARGB_PM_to_Indexed8, | - | ||||||||||||
2112 | 0, | - | ||||||||||||
2113 | 0, | - | ||||||||||||
2114 | 0, | - | ||||||||||||
2115 | 0, | - | ||||||||||||
2116 | 0, | - | ||||||||||||
2117 | 0, | - | ||||||||||||
2118 | 0, | - | ||||||||||||
2119 | 0, | - | ||||||||||||
2120 | 0, | - | ||||||||||||
2121 | 0, | - | ||||||||||||
2122 | 0, | - | ||||||||||||
2123 | 0, | - | ||||||||||||
2124 | 0, | - | ||||||||||||
2125 | 0, | - | ||||||||||||
2126 | convert_ARGB_to_RGBA, | - | ||||||||||||
2127 | 0, | - | ||||||||||||
2128 | 0, | - | ||||||||||||
2129 | 0, | - | ||||||||||||
2130 | 0, | - | ||||||||||||
2131 | 0, 0 | - | ||||||||||||
2132 | }, // Format_ARGB32_Premultiplied | - | ||||||||||||
2133 | - | |||||||||||||
2134 | { | - | ||||||||||||
2135 | 0, | - | ||||||||||||
2136 | 0, | - | ||||||||||||
2137 | 0, | - | ||||||||||||
2138 | 0, | - | ||||||||||||
2139 | 0, | - | ||||||||||||
2140 | 0, | - | ||||||||||||
2141 | 0, | - | ||||||||||||
2142 | 0, | - | ||||||||||||
2143 | 0, | - | ||||||||||||
2144 | 0, | - | ||||||||||||
2145 | 0, | - | ||||||||||||
2146 | 0, | - | ||||||||||||
2147 | 0, | - | ||||||||||||
2148 | 0, | - | ||||||||||||
2149 | 0, | - | ||||||||||||
2150 | 0, | - | ||||||||||||
2151 | 0, | - | ||||||||||||
2152 | 0, | - | ||||||||||||
2153 | 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2154 | }, // Format_RGB16 | - | ||||||||||||
2155 | - | |||||||||||||
2156 | { | - | ||||||||||||
2157 | 0, | - | ||||||||||||
2158 | 0, | - | ||||||||||||
2159 | 0, | - | ||||||||||||
2160 | 0, | - | ||||||||||||
2161 | 0, | - | ||||||||||||
2162 | 0, | - | ||||||||||||
2163 | 0, | - | ||||||||||||
2164 | 0, | - | ||||||||||||
2165 | 0, | - | ||||||||||||
2166 | 0, | - | ||||||||||||
2167 | 0, | - | ||||||||||||
2168 | 0, | - | ||||||||||||
2169 | 0, | - | ||||||||||||
2170 | 0, | - | ||||||||||||
2171 | 0, | - | ||||||||||||
2172 | 0, | - | ||||||||||||
2173 | 0, | - | ||||||||||||
2174 | 0, | - | ||||||||||||
2175 | 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2176 | }, // Format_ARGB8565_Premultiplied | - | ||||||||||||
2177 | - | |||||||||||||
2178 | { | - | ||||||||||||
2179 | 0, | - | ||||||||||||
2180 | 0, | - | ||||||||||||
2181 | 0, | - | ||||||||||||
2182 | 0, | - | ||||||||||||
2183 | 0, | - | ||||||||||||
2184 | 0, | - | ||||||||||||
2185 | 0, | - | ||||||||||||
2186 | 0, | - | ||||||||||||
2187 | 0, | - | ||||||||||||
2188 | 0, | - | ||||||||||||
2189 | 0, | - | ||||||||||||
2190 | 0, | - | ||||||||||||
2191 | 0, | - | ||||||||||||
2192 | 0, | - | ||||||||||||
2193 | 0, | - | ||||||||||||
2194 | 0, | - | ||||||||||||
2195 | 0, | - | ||||||||||||
2196 | 0, | - | ||||||||||||
2197 | 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2198 | }, // Format_RGB666 | - | ||||||||||||
2199 | - | |||||||||||||
2200 | { | - | ||||||||||||
2201 | 0, | - | ||||||||||||
2202 | 0, | - | ||||||||||||
2203 | 0, | - | ||||||||||||
2204 | 0, | - | ||||||||||||
2205 | 0, | - | ||||||||||||
2206 | 0, | - | ||||||||||||
2207 | 0, | - | ||||||||||||
2208 | 0, | - | ||||||||||||
2209 | 0, | - | ||||||||||||
2210 | 0, | - | ||||||||||||
2211 | 0, | - | ||||||||||||
2212 | 0, | - | ||||||||||||
2213 | 0, | - | ||||||||||||
2214 | 0, | - | ||||||||||||
2215 | 0, | - | ||||||||||||
2216 | 0, | - | ||||||||||||
2217 | 0, | - | ||||||||||||
2218 | 0, | - | ||||||||||||
2219 | 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2220 | }, // Format_ARGB6666_Premultiplied | - | ||||||||||||
2221 | - | |||||||||||||
2222 | { | - | ||||||||||||
2223 | 0, | - | ||||||||||||
2224 | 0, | - | ||||||||||||
2225 | 0, | - | ||||||||||||
2226 | 0, | - | ||||||||||||
2227 | 0, | - | ||||||||||||
2228 | 0, | - | ||||||||||||
2229 | 0, | - | ||||||||||||
2230 | 0, | - | ||||||||||||
2231 | 0, | - | ||||||||||||
2232 | 0, | - | ||||||||||||
2233 | 0, | - | ||||||||||||
2234 | 0, | - | ||||||||||||
2235 | 0, | - | ||||||||||||
2236 | 0, | - | ||||||||||||
2237 | 0, | - | ||||||||||||
2238 | 0, | - | ||||||||||||
2239 | 0, | - | ||||||||||||
2240 | 0, | - | ||||||||||||
2241 | 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2242 | }, // Format_RGB555 | - | ||||||||||||
2243 | - | |||||||||||||
2244 | { | - | ||||||||||||
2245 | 0, | - | ||||||||||||
2246 | 0, | - | ||||||||||||
2247 | 0, | - | ||||||||||||
2248 | 0, | - | ||||||||||||
2249 | 0, | - | ||||||||||||
2250 | 0, | - | ||||||||||||
2251 | 0, | - | ||||||||||||
2252 | 0, | - | ||||||||||||
2253 | 0, | - | ||||||||||||
2254 | 0, | - | ||||||||||||
2255 | 0, | - | ||||||||||||
2256 | 0, | - | ||||||||||||
2257 | 0, | - | ||||||||||||
2258 | 0, | - | ||||||||||||
2259 | 0, | - | ||||||||||||
2260 | 0, | - | ||||||||||||
2261 | 0, | - | ||||||||||||
2262 | 0, | - | ||||||||||||
2263 | 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2264 | }, // Format_ARGB8555_Premultiplied | - | ||||||||||||
2265 | - | |||||||||||||
2266 | { | - | ||||||||||||
2267 | 0, | - | ||||||||||||
2268 | 0, | - | ||||||||||||
2269 | 0, | - | ||||||||||||
2270 | 0, | - | ||||||||||||
2271 | convert_RGB888_to_RGB<false>, | - | ||||||||||||
2272 | convert_RGB888_to_RGB<false>, | - | ||||||||||||
2273 | convert_RGB888_to_RGB<false>, | - | ||||||||||||
2274 | 0, | - | ||||||||||||
2275 | 0, | - | ||||||||||||
2276 | 0, | - | ||||||||||||
2277 | 0, | - | ||||||||||||
2278 | 0, | - | ||||||||||||
2279 | 0, | - | ||||||||||||
2280 | 0, | - | ||||||||||||
2281 | 0, | - | ||||||||||||
2282 | 0, | - | ||||||||||||
2283 | convert_RGB888_to_RGB<true>, | - | ||||||||||||
2284 | convert_RGB888_to_RGB<true>, | - | ||||||||||||
2285 | convert_RGB888_to_RGB<true>, | - | ||||||||||||
2286 | 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2287 | }, // Format_RGB888 | - | ||||||||||||
2288 | - | |||||||||||||
2289 | { | - | ||||||||||||
2290 | 0, | - | ||||||||||||
2291 | 0, | - | ||||||||||||
2292 | 0, | - | ||||||||||||
2293 | 0, | - | ||||||||||||
2294 | 0, | - | ||||||||||||
2295 | 0, | - | ||||||||||||
2296 | 0, | - | ||||||||||||
2297 | 0, | - | ||||||||||||
2298 | 0, | - | ||||||||||||
2299 | 0, | - | ||||||||||||
2300 | 0, | - | ||||||||||||
2301 | 0, | - | ||||||||||||
2302 | 0, | - | ||||||||||||
2303 | 0, | - | ||||||||||||
2304 | 0, | - | ||||||||||||
2305 | 0, | - | ||||||||||||
2306 | 0, | - | ||||||||||||
2307 | 0, | - | ||||||||||||
2308 | 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2309 | }, // Format_RGB444 | - | ||||||||||||
2310 | - | |||||||||||||
2311 | { | - | ||||||||||||
2312 | 0, | - | ||||||||||||
2313 | 0, | - | ||||||||||||
2314 | 0, | - | ||||||||||||
2315 | 0, | - | ||||||||||||
2316 | 0, | - | ||||||||||||
2317 | 0, | - | ||||||||||||
2318 | 0, | - | ||||||||||||
2319 | 0, | - | ||||||||||||
2320 | 0, | - | ||||||||||||
2321 | 0, | - | ||||||||||||
2322 | 0, | - | ||||||||||||
2323 | 0, | - | ||||||||||||
2324 | 0, | - | ||||||||||||
2325 | 0, | - | ||||||||||||
2326 | 0, | - | ||||||||||||
2327 | 0, | - | ||||||||||||
2328 | 0, | - | ||||||||||||
2329 | 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2330 | }, // Format_ARGB4444_Premultiplied | - | ||||||||||||
2331 | { | - | ||||||||||||
2332 | 0, | - | ||||||||||||
2333 | 0, | - | ||||||||||||
2334 | 0, | - | ||||||||||||
2335 | 0, | - | ||||||||||||
2336 | convert_RGBA_to_RGB, | - | ||||||||||||
2337 | convert_RGBA_to_ARGB, | - | ||||||||||||
2338 | convert_RGBA_to_ARGB, | - | ||||||||||||
2339 | 0, | - | ||||||||||||
2340 | 0, | - | ||||||||||||
2341 | 0, | - | ||||||||||||
2342 | 0, | - | ||||||||||||
2343 | 0, | - | ||||||||||||
2344 | 0, | - | ||||||||||||
2345 | 0, | - | ||||||||||||
2346 | 0, | - | ||||||||||||
2347 | 0, | - | ||||||||||||
2348 | 0, | - | ||||||||||||
2349 | mask_alpha_converter_RGBx, | - | ||||||||||||
2350 | mask_alpha_converter_RGBx, | - | ||||||||||||
2351 | 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2352 | }, // Format_RGBX8888 | - | ||||||||||||
2353 | { | - | ||||||||||||
2354 | 0, | - | ||||||||||||
2355 | 0, | - | ||||||||||||
2356 | 0, | - | ||||||||||||
2357 | 0, | - | ||||||||||||
2358 | convert_RGBA_to_RGB, | - | ||||||||||||
2359 | convert_RGBA_to_ARGB, | - | ||||||||||||
2360 | 0, | - | ||||||||||||
2361 | 0, | - | ||||||||||||
2362 | 0, | - | ||||||||||||
2363 | 0, | - | ||||||||||||
2364 | 0, | - | ||||||||||||
2365 | 0, | - | ||||||||||||
2366 | 0, | - | ||||||||||||
2367 | 0, | - | ||||||||||||
2368 | 0, | - | ||||||||||||
2369 | 0, | - | ||||||||||||
2370 | mask_alpha_converter_RGBx, | - | ||||||||||||
2371 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN | - | ||||||||||||
2372 | 0, | - | ||||||||||||
2373 | convert_ARGB_to_ARGB_PM, | - | ||||||||||||
2374 | #else | - | ||||||||||||
2375 | 0, | - | ||||||||||||
2376 | 0, | - | ||||||||||||
2377 | #endif | - | ||||||||||||
2378 | 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2379 | }, // Format_RGBA8888 | - | ||||||||||||
2380 | - | |||||||||||||
2381 | { | - | ||||||||||||
2382 | 0, | - | ||||||||||||
2383 | 0, | - | ||||||||||||
2384 | 0, | - | ||||||||||||
2385 | 0, | - | ||||||||||||
2386 | 0, | - | ||||||||||||
2387 | 0, | - | ||||||||||||
2388 | convert_RGBA_to_ARGB, | - | ||||||||||||
2389 | 0, | - | ||||||||||||
2390 | 0, | - | ||||||||||||
2391 | 0, | - | ||||||||||||
2392 | 0, | - | ||||||||||||
2393 | 0, | - | ||||||||||||
2394 | 0, | - | ||||||||||||
2395 | 0, | - | ||||||||||||
2396 | 0, | - | ||||||||||||
2397 | 0, | - | ||||||||||||
2398 | 0, | - | ||||||||||||
2399 | 0, | - | ||||||||||||
2400 | 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2401 | }, // Format_RGBA8888_Premultiplied | - | ||||||||||||
2402 | - | |||||||||||||
2403 | { | - | ||||||||||||
2404 | 0, | - | ||||||||||||
2405 | 0, | - | ||||||||||||
2406 | 0, | - | ||||||||||||
2407 | 0, | - | ||||||||||||
2408 | 0, | - | ||||||||||||
2409 | 0, | - | ||||||||||||
2410 | 0, | - | ||||||||||||
2411 | 0, | - | ||||||||||||
2412 | 0, | - | ||||||||||||
2413 | 0, | - | ||||||||||||
2414 | 0, | - | ||||||||||||
2415 | 0, | - | ||||||||||||
2416 | 0, | - | ||||||||||||
2417 | 0, | - | ||||||||||||
2418 | 0, | - | ||||||||||||
2419 | 0, | - | ||||||||||||
2420 | 0, | - | ||||||||||||
2421 | 0, | - | ||||||||||||
2422 | 0, | - | ||||||||||||
2423 | 0, | - | ||||||||||||
2424 | convert_passthrough, | - | ||||||||||||
2425 | convert_BGR30_to_RGB30, | - | ||||||||||||
2426 | convert_BGR30_to_RGB30, | - | ||||||||||||
2427 | 0, 0 | - | ||||||||||||
2428 | }, // Format_BGR30 | - | ||||||||||||
2429 | { | - | ||||||||||||
2430 | 0, | - | ||||||||||||
2431 | 0, | - | ||||||||||||
2432 | 0, | - | ||||||||||||
2433 | 0, | - | ||||||||||||
2434 | 0, | - | ||||||||||||
2435 | convert_A2RGB30_PM_to_ARGB<PixelOrderBGR>, | - | ||||||||||||
2436 | 0, | - | ||||||||||||
2437 | 0, | - | ||||||||||||
2438 | 0, | - | ||||||||||||
2439 | 0, | - | ||||||||||||
2440 | 0, | - | ||||||||||||
2441 | 0, | - | ||||||||||||
2442 | 0, | - | ||||||||||||
2443 | 0, | - | ||||||||||||
2444 | 0, | - | ||||||||||||
2445 | 0, | - | ||||||||||||
2446 | 0, | - | ||||||||||||
2447 | 0, | - | ||||||||||||
2448 | 0, | - | ||||||||||||
2449 | convert_A2RGB30_PM_to_RGB30<false>, | - | ||||||||||||
2450 | 0, | - | ||||||||||||
2451 | convert_A2RGB30_PM_to_RGB30<true>, | - | ||||||||||||
2452 | convert_BGR30_to_RGB30, | - | ||||||||||||
2453 | 0, 0 | - | ||||||||||||
2454 | }, // Format_BGR30A2_Premultiplied | - | ||||||||||||
2455 | { | - | ||||||||||||
2456 | 0, | - | ||||||||||||
2457 | 0, | - | ||||||||||||
2458 | 0, | - | ||||||||||||
2459 | 0, | - | ||||||||||||
2460 | 0, | - | ||||||||||||
2461 | 0, | - | ||||||||||||
2462 | 0, | - | ||||||||||||
2463 | 0, | - | ||||||||||||
2464 | 0, | - | ||||||||||||
2465 | 0, | - | ||||||||||||
2466 | 0, | - | ||||||||||||
2467 | 0, | - | ||||||||||||
2468 | 0, | - | ||||||||||||
2469 | 0, | - | ||||||||||||
2470 | 0, | - | ||||||||||||
2471 | 0, | - | ||||||||||||
2472 | 0, | - | ||||||||||||
2473 | 0, | - | ||||||||||||
2474 | 0, | - | ||||||||||||
2475 | convert_BGR30_to_RGB30, | - | ||||||||||||
2476 | convert_BGR30_to_RGB30, | - | ||||||||||||
2477 | 0, | - | ||||||||||||
2478 | convert_passthrough, | - | ||||||||||||
2479 | 0, 0 | - | ||||||||||||
2480 | }, // Format_RGB30 | - | ||||||||||||
2481 | { | - | ||||||||||||
2482 | 0, | - | ||||||||||||
2483 | 0, | - | ||||||||||||
2484 | 0, | - | ||||||||||||
2485 | 0, | - | ||||||||||||
2486 | 0, | - | ||||||||||||
2487 | convert_A2RGB30_PM_to_ARGB<PixelOrderRGB>, | - | ||||||||||||
2488 | 0, | - | ||||||||||||
2489 | 0, | - | ||||||||||||
2490 | 0, | - | ||||||||||||
2491 | 0, | - | ||||||||||||
2492 | 0, | - | ||||||||||||
2493 | 0, | - | ||||||||||||
2494 | 0, | - | ||||||||||||
2495 | 0, | - | ||||||||||||
2496 | 0, | - | ||||||||||||
2497 | 0, | - | ||||||||||||
2498 | 0, | - | ||||||||||||
2499 | 0, | - | ||||||||||||
2500 | 0, | - | ||||||||||||
2501 | convert_A2RGB30_PM_to_RGB30<true>, | - | ||||||||||||
2502 | convert_BGR30_to_RGB30, | - | ||||||||||||
2503 | convert_A2RGB30_PM_to_RGB30<false>, | - | ||||||||||||
2504 | 0, | - | ||||||||||||
2505 | 0, 0 | - | ||||||||||||
2506 | }, // Format_RGB30A2_Premultiplied | - | ||||||||||||
2507 | { | - | ||||||||||||
2508 | 0, | - | ||||||||||||
2509 | 0, | - | ||||||||||||
2510 | 0, | - | ||||||||||||
2511 | convert_Alpha8_to_Indexed8, | - | ||||||||||||
2512 | 0, | - | ||||||||||||
2513 | 0, | - | ||||||||||||
2514 | 0, | - | ||||||||||||
2515 | 0, | - | ||||||||||||
2516 | 0, | - | ||||||||||||
2517 | 0, | - | ||||||||||||
2518 | 0, | - | ||||||||||||
2519 | 0, | - | ||||||||||||
2520 | 0, | - | ||||||||||||
2521 | 0, | - | ||||||||||||
2522 | 0, | - | ||||||||||||
2523 | 0, | - | ||||||||||||
2524 | 0, | - | ||||||||||||
2525 | 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2526 | }, // Format_Alpha8 | - | ||||||||||||
2527 | { | - | ||||||||||||
2528 | 0, | - | ||||||||||||
2529 | 0, | - | ||||||||||||
2530 | 0, | - | ||||||||||||
2531 | convert_Grayscale8_to_Indexed8, | - | ||||||||||||
2532 | 0, | - | ||||||||||||
2533 | 0, | - | ||||||||||||
2534 | 0, | - | ||||||||||||
2535 | 0, | - | ||||||||||||
2536 | 0, | - | ||||||||||||
2537 | 0, | - | ||||||||||||
2538 | 0, | - | ||||||||||||
2539 | 0, | - | ||||||||||||
2540 | 0, | - | ||||||||||||
2541 | 0, | - | ||||||||||||
2542 | 0, | - | ||||||||||||
2543 | 0, | - | ||||||||||||
2544 | 0, | - | ||||||||||||
2545 | 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2546 | } // Format_Grayscale8 | - | ||||||||||||
2547 | }; | - | ||||||||||||
2548 | - | |||||||||||||
2549 | InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QImage::NImageFormats] = | - | ||||||||||||
2550 | { | - | ||||||||||||
2551 | { | - | ||||||||||||
2552 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2553 | }, | - | ||||||||||||
2554 | { | - | ||||||||||||
2555 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2556 | }, // Format_Mono | - | ||||||||||||
2557 | { | - | ||||||||||||
2558 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2559 | }, // Format_MonoLSB | - | ||||||||||||
2560 | { | - | ||||||||||||
2561 | 0, | - | ||||||||||||
2562 | 0, | - | ||||||||||||
2563 | 0, | - | ||||||||||||
2564 | 0, | - | ||||||||||||
2565 | convert_indexed8_to_RGB_inplace, | - | ||||||||||||
2566 | convert_indexed8_to_ARGB_inplace, | - | ||||||||||||
2567 | convert_indexed8_to_ARGB_PM_inplace, | - | ||||||||||||
2568 | convert_indexed8_to_RGB16_inplace, | - | ||||||||||||
2569 | 0, | - | ||||||||||||
2570 | 0, | - | ||||||||||||
2571 | 0, | - | ||||||||||||
2572 | 0, | - | ||||||||||||
2573 | 0, | - | ||||||||||||
2574 | 0, | - | ||||||||||||
2575 | 0, | - | ||||||||||||
2576 | 0, | - | ||||||||||||
2577 | 0, | - | ||||||||||||
2578 | 0, | - | ||||||||||||
2579 | 0, 0, 0, 0, 0, | - | ||||||||||||
2580 | convert_Indexed8_to_Alpha8_inplace, | - | ||||||||||||
2581 | convert_Indexed8_to_Grayscale8_inplace, | - | ||||||||||||
2582 | }, // Format_Indexed8 | - | ||||||||||||
2583 | { | - | ||||||||||||
2584 | 0, | - | ||||||||||||
2585 | 0, | - | ||||||||||||
2586 | 0, | - | ||||||||||||
2587 | 0, | - | ||||||||||||
2588 | 0, | - | ||||||||||||
2589 | mask_alpha_converter_inplace<QImage::Format_ARGB32>, | - | ||||||||||||
2590 | mask_alpha_converter_inplace<QImage::Format_ARGB32_Premultiplied>, | - | ||||||||||||
2591 | convert_RGB_to_RGB16_inplace, | - | ||||||||||||
2592 | 0, | - | ||||||||||||
2593 | 0, | - | ||||||||||||
2594 | 0, | - | ||||||||||||
2595 | 0, | - | ||||||||||||
2596 | 0, | - | ||||||||||||
2597 | 0, | - | ||||||||||||
2598 | 0, | - | ||||||||||||
2599 | 0, | - | ||||||||||||
2600 | 0, | - | ||||||||||||
2601 | 0, | - | ||||||||||||
2602 | 0, | - | ||||||||||||
2603 | convert_RGB_to_RGB30_inplace<PixelOrderBGR>, | - | ||||||||||||
2604 | 0, | - | ||||||||||||
2605 | convert_RGB_to_RGB30_inplace<PixelOrderRGB>, | - | ||||||||||||
2606 | 0, | - | ||||||||||||
2607 | 0, 0 | - | ||||||||||||
2608 | }, // Format_RGB32 | - | ||||||||||||
2609 | { | - | ||||||||||||
2610 | 0, | - | ||||||||||||
2611 | 0, | - | ||||||||||||
2612 | 0, | - | ||||||||||||
2613 | 0, | - | ||||||||||||
2614 | mask_alpha_converter_inplace<QImage::Format_RGB32>, | - | ||||||||||||
2615 | 0, | - | ||||||||||||
2616 | #ifdef __SSE2__ | - | ||||||||||||
2617 | convert_ARGB_to_ARGB_PM_inplace_sse2, | - | ||||||||||||
2618 | #else | - | ||||||||||||
2619 | convert_ARGB_to_ARGB_PM_inplace, | - | ||||||||||||
2620 | #endif | - | ||||||||||||
2621 | 0, | - | ||||||||||||
2622 | 0, | - | ||||||||||||
2623 | 0, | - | ||||||||||||
2624 | 0, | - | ||||||||||||
2625 | 0, | - | ||||||||||||
2626 | 0, | - | ||||||||||||
2627 | 0, | - | ||||||||||||
2628 | 0, | - | ||||||||||||
2629 | 0, | - | ||||||||||||
2630 | convert_ARGB_to_RGBA_inplace<QImage::Format_RGBX8888>, | - | ||||||||||||
2631 | convert_ARGB_to_RGBA_inplace<QImage::Format_RGBA8888>, | - | ||||||||||||
2632 | 0, | - | ||||||||||||
2633 | convert_RGB_to_RGB30_inplace<PixelOrderBGR>, | - | ||||||||||||
2634 | 0, | - | ||||||||||||
2635 | convert_RGB_to_RGB30_inplace<PixelOrderRGB>, | - | ||||||||||||
2636 | 0, | - | ||||||||||||
2637 | 0, 0 | - | ||||||||||||
2638 | }, // Format_ARGB32 | - | ||||||||||||
2639 | { | - | ||||||||||||
2640 | 0, | - | ||||||||||||
2641 | 0, | - | ||||||||||||
2642 | 0, | - | ||||||||||||
2643 | 0, | - | ||||||||||||
2644 | 0, | - | ||||||||||||
2645 | 0, | - | ||||||||||||
2646 | 0, | - | ||||||||||||
2647 | 0, | - | ||||||||||||
2648 | 0, | - | ||||||||||||
2649 | 0, | - | ||||||||||||
2650 | 0, | - | ||||||||||||
2651 | 0, | - | ||||||||||||
2652 | 0, | - | ||||||||||||
2653 | 0, | - | ||||||||||||
2654 | 0, | - | ||||||||||||
2655 | 0, | - | ||||||||||||
2656 | 0, | - | ||||||||||||
2657 | 0, | - | ||||||||||||
2658 | convert_ARGB_to_RGBA_inplace<QImage::Format_RGBA8888_Premultiplied>, | - | ||||||||||||
2659 | 0, | - | ||||||||||||
2660 | 0, | - | ||||||||||||
2661 | 0, | - | ||||||||||||
2662 | 0, | - | ||||||||||||
2663 | 0, 0 | - | ||||||||||||
2664 | }, // Format_ARGB32_Premultiplied | - | ||||||||||||
2665 | { | - | ||||||||||||
2666 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2667 | }, // Format_RGB16 | - | ||||||||||||
2668 | { | - | ||||||||||||
2669 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2670 | }, // Format_ARGB8565_Premultiplied | - | ||||||||||||
2671 | { | - | ||||||||||||
2672 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2673 | }, // Format_RGB666 | - | ||||||||||||
2674 | { | - | ||||||||||||
2675 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2676 | }, // Format_ARGB6666_Premultiplied | - | ||||||||||||
2677 | { | - | ||||||||||||
2678 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2679 | }, // Format_RGB555 | - | ||||||||||||
2680 | { | - | ||||||||||||
2681 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2682 | }, // Format_ARGB8555_Premultiplied | - | ||||||||||||
2683 | { | - | ||||||||||||
2684 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2685 | }, // Format_RGB888 | - | ||||||||||||
2686 | { | - | ||||||||||||
2687 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2688 | }, // Format_RGB444 | - | ||||||||||||
2689 | { | - | ||||||||||||
2690 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2691 | }, // Format_ARGB4444_Premultiplied | - | ||||||||||||
2692 | { | - | ||||||||||||
2693 | 0, | - | ||||||||||||
2694 | 0, | - | ||||||||||||
2695 | 0, | - | ||||||||||||
2696 | 0, | - | ||||||||||||
2697 | convert_RGBA_to_ARGB_inplace<QImage::Format_RGB32>, | - | ||||||||||||
2698 | convert_RGBA_to_ARGB_inplace<QImage::Format_ARGB32>, | - | ||||||||||||
2699 | convert_RGBA_to_ARGB_inplace<QImage::Format_ARGB32_Premultiplied>, | - | ||||||||||||
2700 | 0, | - | ||||||||||||
2701 | 0, | - | ||||||||||||
2702 | 0, | - | ||||||||||||
2703 | 0, | - | ||||||||||||
2704 | 0, | - | ||||||||||||
2705 | 0, | - | ||||||||||||
2706 | 0, | - | ||||||||||||
2707 | 0, | - | ||||||||||||
2708 | 0, | - | ||||||||||||
2709 | 0, | - | ||||||||||||
2710 | convert_passthrough_inplace<QImage::Format_RGBA8888>, | - | ||||||||||||
2711 | convert_passthrough_inplace<QImage::Format_RGBA8888_Premultiplied>, | - | ||||||||||||
2712 | 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2713 | }, // Format_RGBX8888 | - | ||||||||||||
2714 | { | - | ||||||||||||
2715 | 0, | - | ||||||||||||
2716 | 0, | - | ||||||||||||
2717 | 0, | - | ||||||||||||
2718 | 0, | - | ||||||||||||
2719 | convert_RGBA_to_ARGB_inplace<QImage::Format_RGB32>, | - | ||||||||||||
2720 | convert_RGBA_to_ARGB_inplace<QImage::Format_ARGB32>, | - | ||||||||||||
2721 | 0, | - | ||||||||||||
2722 | 0, | - | ||||||||||||
2723 | 0, | - | ||||||||||||
2724 | 0, | - | ||||||||||||
2725 | 0, | - | ||||||||||||
2726 | 0, | - | ||||||||||||
2727 | 0, | - | ||||||||||||
2728 | 0, | - | ||||||||||||
2729 | 0, | - | ||||||||||||
2730 | 0, | - | ||||||||||||
2731 | mask_alpha_converter_rgbx_inplace, | - | ||||||||||||
2732 | 0, | - | ||||||||||||
2733 | #ifdef __SSE2__ | - | ||||||||||||
2734 | convert_ARGB_to_ARGB_PM_inplace_sse2, | - | ||||||||||||
2735 | #elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN | - | ||||||||||||
2736 | convert_ARGB_to_ARGB_PM_inplace, | - | ||||||||||||
2737 | #else | - | ||||||||||||
2738 | 0, | - | ||||||||||||
2739 | #endif | - | ||||||||||||
2740 | 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2741 | }, // Format_RGBA8888 | - | ||||||||||||
2742 | { | - | ||||||||||||
2743 | 0, | - | ||||||||||||
2744 | 0, | - | ||||||||||||
2745 | 0, | - | ||||||||||||
2746 | 0, | - | ||||||||||||
2747 | 0, | - | ||||||||||||
2748 | 0, | - | ||||||||||||
2749 | convert_RGBA_to_ARGB_inplace<QImage::Format_ARGB32_Premultiplied>, | - | ||||||||||||
2750 | 0, | - | ||||||||||||
2751 | 0, | - | ||||||||||||
2752 | 0, | - | ||||||||||||
2753 | 0, | - | ||||||||||||
2754 | 0, | - | ||||||||||||
2755 | 0, | - | ||||||||||||
2756 | 0, | - | ||||||||||||
2757 | 0, | - | ||||||||||||
2758 | 0, | - | ||||||||||||
2759 | 0, | - | ||||||||||||
2760 | 0, | - | ||||||||||||
2761 | 0, | - | ||||||||||||
2762 | 0, 0, 0, 0, 0, 0 | - | ||||||||||||
2763 | }, // Format_RGBA8888_Premultiplied | - | ||||||||||||
2764 | { | - | ||||||||||||
2765 | 0, | - | ||||||||||||
2766 | 0, | - | ||||||||||||
2767 | 0, | - | ||||||||||||
2768 | 0, | - | ||||||||||||
2769 | 0, | - | ||||||||||||
2770 | 0, | - | ||||||||||||
2771 | 0, | - | ||||||||||||
2772 | 0, | - | ||||||||||||
2773 | 0, | - | ||||||||||||
2774 | 0, | - | ||||||||||||
2775 | 0, | - | ||||||||||||
2776 | 0, | - | ||||||||||||
2777 | 0, | - | ||||||||||||
2778 | 0, | - | ||||||||||||
2779 | 0, | - | ||||||||||||
2780 | 0, | - | ||||||||||||
2781 | 0, | - | ||||||||||||
2782 | 0, | - | ||||||||||||
2783 | 0, | - | ||||||||||||
2784 | 0, // self | - | ||||||||||||
2785 | convert_passthrough_inplace<QImage::Format_A2BGR30_Premultiplied>, | - | ||||||||||||
2786 | convert_BGR30_to_RGB30_inplace, | - | ||||||||||||
2787 | convert_BGR30_to_A2RGB30_inplace, | - | ||||||||||||
2788 | 0, 0 | - | ||||||||||||
2789 | }, // Format_BGR30 | - | ||||||||||||
2790 | { | - | ||||||||||||
2791 | 0, | - | ||||||||||||
2792 | 0, | - | ||||||||||||
2793 | 0, | - | ||||||||||||
2794 | 0, | - | ||||||||||||
2795 | 0, | - | ||||||||||||
2796 | convert_A2RGB30_PM_to_ARGB_inplace<PixelOrderBGR>, | - | ||||||||||||
2797 | 0, | - | ||||||||||||
2798 | 0, | - | ||||||||||||
2799 | 0, | - | ||||||||||||
2800 | 0, | - | ||||||||||||
2801 | 0, | - | ||||||||||||
2802 | 0, | - | ||||||||||||
2803 | 0, | - | ||||||||||||
2804 | 0, | - | ||||||||||||
2805 | 0, | - | ||||||||||||
2806 | 0, | - | ||||||||||||
2807 | 0, | - | ||||||||||||
2808 | 0, | - | ||||||||||||
2809 | 0, | - | ||||||||||||
2810 | convert_A2RGB30_PM_to_RGB30_inplace<false>, | - | ||||||||||||
2811 | 0, // self | - | ||||||||||||
2812 | convert_A2RGB30_PM_to_RGB30_inplace<true>, | - | ||||||||||||
2813 | convert_BGR30_to_RGB30_inplace, | - | ||||||||||||
2814 | 0, 0 | - | ||||||||||||
2815 | }, // Format_BGR30A2_Premultiplied | - | ||||||||||||
2816 | { | - | ||||||||||||
2817 | 0, | - | ||||||||||||
2818 | 0, | - | ||||||||||||
2819 | 0, | - | ||||||||||||
2820 | 0, | - | ||||||||||||
2821 | 0, | - | ||||||||||||
2822 | 0, | - | ||||||||||||
2823 | 0, | - | ||||||||||||
2824 | 0, | - | ||||||||||||
2825 | 0, | - | ||||||||||||
2826 | 0, | - | ||||||||||||
2827 | 0, | - | ||||||||||||
2828 | 0, | - | ||||||||||||
2829 | 0, | - | ||||||||||||
2830 | 0, | - | ||||||||||||
2831 | 0, | - | ||||||||||||
2832 | 0, | - | ||||||||||||
2833 | 0, | - | ||||||||||||
2834 | 0, | - | ||||||||||||
2835 | 0, | - | ||||||||||||
2836 | convert_BGR30_to_RGB30_inplace, | - | ||||||||||||
2837 | convert_BGR30_to_A2RGB30_inplace, | - | ||||||||||||
2838 | 0, // self | - | ||||||||||||
2839 | convert_passthrough_inplace<QImage::Format_A2RGB30_Premultiplied>, | - | ||||||||||||
2840 | 0, 0 | - | ||||||||||||
2841 | }, // Format_RGB30 | - | ||||||||||||
2842 | { | - | ||||||||||||
2843 | 0, | - | ||||||||||||
2844 | 0, | - | ||||||||||||
2845 | 0, | - | ||||||||||||
2846 | 0, | - | ||||||||||||
2847 | 0, | - | ||||||||||||
2848 | convert_A2RGB30_PM_to_ARGB_inplace<PixelOrderRGB>, | - | ||||||||||||
2849 | 0, | - | ||||||||||||
2850 | 0, | - | ||||||||||||
2851 | 0, | - | ||||||||||||
2852 | 0, | - | ||||||||||||
2853 | 0, | - | ||||||||||||
2854 | 0, | - | ||||||||||||
2855 | 0, | - | ||||||||||||
2856 | 0, | - | ||||||||||||
2857 | 0, | - | ||||||||||||
2858 | 0, | - | ||||||||||||
2859 | 0, | - | ||||||||||||
2860 | 0, | - | ||||||||||||
2861 | 0, | - | ||||||||||||
2862 | convert_A2RGB30_PM_to_RGB30_inplace<true>, | - | ||||||||||||
2863 | convert_BGR30_to_RGB30_inplace, | - | ||||||||||||
2864 | convert_A2RGB30_PM_to_RGB30_inplace<false>, | - | ||||||||||||
2865 | 0, // self | - | ||||||||||||
2866 | 0, 0 | - | ||||||||||||
2867 | }, // Format_RGB30A2_Premultiplied | - | ||||||||||||
2868 | { | - | ||||||||||||
2869 | 0, | - | ||||||||||||
2870 | 0, | - | ||||||||||||
2871 | 0, | - | ||||||||||||
2872 | convert_Alpha8_to_Indexed8_inplace, | - | ||||||||||||
2873 | 0, | - | ||||||||||||
2874 | 0, | - | ||||||||||||
2875 | 0, | - | ||||||||||||
2876 | 0, | - | ||||||||||||
2877 | 0, | - | ||||||||||||
2878 | 0, | - | ||||||||||||
2879 | 0, | - | ||||||||||||
2880 | 0, | - | ||||||||||||
2881 | 0, | - | ||||||||||||
2882 | 0, | - | ||||||||||||
2883 | 0, | - | ||||||||||||
2884 | 0, | - | ||||||||||||
2885 | 0, | - | ||||||||||||
2886 | 0, | - | ||||||||||||
2887 | 0, | - | ||||||||||||
2888 | 0, | - | ||||||||||||
2889 | 0, | - | ||||||||||||
2890 | 0, | - | ||||||||||||
2891 | 0, | - | ||||||||||||
2892 | 0, 0 | - | ||||||||||||
2893 | }, // Format_Alpha8 | - | ||||||||||||
2894 | { | - | ||||||||||||
2895 | 0, | - | ||||||||||||
2896 | 0, | - | ||||||||||||
2897 | 0, | - | ||||||||||||
2898 | convert_Grayscale8_to_Indexed8_inplace, | - | ||||||||||||
2899 | 0, | - | ||||||||||||
2900 | 0, | - | ||||||||||||
2901 | 0, | - | ||||||||||||
2902 | 0, | - | ||||||||||||
2903 | 0, | - | ||||||||||||
2904 | 0, | - | ||||||||||||
2905 | 0, | - | ||||||||||||
2906 | 0, | - | ||||||||||||
2907 | 0, | - | ||||||||||||
2908 | 0, | - | ||||||||||||
2909 | 0, | - | ||||||||||||
2910 | 0, | - | ||||||||||||
2911 | 0, | - | ||||||||||||
2912 | 0, | - | ||||||||||||
2913 | 0, | - | ||||||||||||
2914 | 0, | - | ||||||||||||
2915 | 0, | - | ||||||||||||
2916 | 0, | - | ||||||||||||
2917 | 0, | - | ||||||||||||
2918 | 0, 0 | - | ||||||||||||
2919 | } // Format_Grayscale8 | - | ||||||||||||
2920 | }; | - | ||||||||||||
2921 | - | |||||||||||||
2922 | static void qInitImageConversions() | - | ||||||||||||
2923 | { | - | ||||||||||||
2924 | #if defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSSE3) | - | ||||||||||||
2925 | if (qCpuHasFeature(SSSE3)) {
| 0 | ||||||||||||
2926 | extern void convert_RGB888_to_RGB32_ssse3(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); | - | ||||||||||||
2927 | qimage_converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_ssse3; | - | ||||||||||||
2928 | qimage_converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_ssse3; | - | ||||||||||||
2929 | qimage_converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_ssse3; | - | ||||||||||||
2930 | } never executed: end of block | 0 | ||||||||||||
2931 | #endif | - | ||||||||||||
2932 | - | |||||||||||||
2933 | #if defined(QT_COMPILER_SUPPORTS_SSE4_1) && !defined(__SSE4_1__) | - | ||||||||||||
2934 | if (qCpuHasFeature(SSE4_1)) {
| 0 | ||||||||||||
2935 | extern void convert_ARGB_to_ARGB_PM_sse4(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); | - | ||||||||||||
2936 | qimage_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_sse4; | - | ||||||||||||
2937 | qimage_converter_map[QImage::Format_RGBA8888][QImage::Format_RGBA8888_Premultiplied] = convert_ARGB_to_ARGB_PM_sse4; | - | ||||||||||||
2938 | } never executed: end of block | 0 | ||||||||||||
2939 | #endif | - | ||||||||||||
2940 | - | |||||||||||||
2941 | #if defined(QT_COMPILER_SUPPORTS_AVX2) && !defined(__AVX2__) | - | ||||||||||||
2942 | if (qCpuHasFeature(AVX2)) {
| 0 | ||||||||||||
2943 | extern void convert_ARGB_to_ARGB_PM_avx2(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); | - | ||||||||||||
2944 | qimage_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_avx2; | - | ||||||||||||
2945 | qimage_converter_map[QImage::Format_RGBA8888][QImage::Format_RGBA8888_Premultiplied] = convert_ARGB_to_ARGB_PM_avx2; | - | ||||||||||||
2946 | } never executed: end of block | 0 | ||||||||||||
2947 | #endif | - | ||||||||||||
2948 | - | |||||||||||||
2949 | #if defined(__ARM_NEON__) | - | ||||||||||||
2950 | extern void convert_RGB888_to_RGB32_neon(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); | - | ||||||||||||
2951 | qimage_converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_neon; | - | ||||||||||||
2952 | qimage_converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_neon; | - | ||||||||||||
2953 | qimage_converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_neon; | - | ||||||||||||
2954 | #endif | - | ||||||||||||
2955 | - | |||||||||||||
2956 | #ifdef QT_COMPILER_SUPPORTS_MIPS_DSPR2 | - | ||||||||||||
2957 | if (qCpuHasFeature(DSPR2)) { | - | ||||||||||||
2958 | extern bool convert_ARGB_to_ARGB_PM_inplace_mips_dspr2(QImageData *data, Qt::ImageConversionFlags); | - | ||||||||||||
2959 | qimage_inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_mips_dspr2; | - | ||||||||||||
2960 | - | |||||||||||||
2961 | extern void convert_RGB888_to_RGB32_mips_dspr2(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); | - | ||||||||||||
2962 | qimage_converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_mips_dspr2; | - | ||||||||||||
2963 | qimage_converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_mips_dspr2; | - | ||||||||||||
2964 | qimage_converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_mips_dspr2; | - | ||||||||||||
2965 | } | - | ||||||||||||
2966 | #endif | - | ||||||||||||
2967 | } never executed: end of block | 0 | ||||||||||||
2968 | - | |||||||||||||
2969 | Q_CONSTRUCTOR_FUNCTION(qInitImageConversions); never executed: end of block | 0 | ||||||||||||
2970 | - | |||||||||||||
2971 | QT_END_NAMESPACE | - | ||||||||||||
Source code | Switch to Preprocessed file |