1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at qt-info@nokia.com.
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include <qmath.h>
|
---|
43 | #include "qdrawhelper_p.h"
|
---|
44 |
|
---|
45 | QT_BEGIN_NAMESPACE
|
---|
46 |
|
---|
47 | struct SourceOnlyAlpha
|
---|
48 | {
|
---|
49 | inline uchar alpha(uchar src) const { return src; }
|
---|
50 | inline quint16 bytemul(quint16 spix) const { return spix; }
|
---|
51 | };
|
---|
52 |
|
---|
53 |
|
---|
54 | struct SourceAndConstAlpha
|
---|
55 | {
|
---|
56 | SourceAndConstAlpha(int a) : m_alpha256(a) {
|
---|
57 | m_alpha255 = (m_alpha256 * 255) >> 8;
|
---|
58 | };
|
---|
59 | inline uchar alpha(uchar src) const { return (src * m_alpha256) >> 8; }
|
---|
60 | inline quint16 bytemul(quint16 x) const {
|
---|
61 | uint t = (((x & 0x07e0)*m_alpha255) >> 8) & 0x07e0;
|
---|
62 | t |= (((x & 0xf81f)*(m_alpha255>>2)) >> 6) & 0xf81f;
|
---|
63 | return t;
|
---|
64 | }
|
---|
65 | int m_alpha255;
|
---|
66 | int m_alpha256;
|
---|
67 | };
|
---|
68 |
|
---|
69 |
|
---|
70 | /************************************************************************
|
---|
71 | RGB16 (565) format target format
|
---|
72 | ************************************************************************/
|
---|
73 |
|
---|
74 | static inline quint16 convert_argb32_to_rgb16(quint32 spix)
|
---|
75 | {
|
---|
76 | quint32 b = spix;
|
---|
77 | quint32 g = spix;
|
---|
78 | b >>= 8;
|
---|
79 | g >>= 5;
|
---|
80 | b &= 0x0000f800;
|
---|
81 | g &= 0x000007e0;
|
---|
82 | spix >>= 3;
|
---|
83 | b |= g;
|
---|
84 | spix &= 0x0000001f;
|
---|
85 | b |= spix;
|
---|
86 | return b;
|
---|
87 | }
|
---|
88 |
|
---|
89 | struct Blend_RGB16_on_RGB16_NoAlpha {
|
---|
90 | inline void write(quint16 *dst, quint16 src) { *dst = src; }
|
---|
91 | };
|
---|
92 |
|
---|
93 | struct Blend_RGB16_on_RGB16_ConstAlpha {
|
---|
94 | inline Blend_RGB16_on_RGB16_ConstAlpha(quint32 alpha) {
|
---|
95 | m_alpha = (alpha * 255) >> 8;
|
---|
96 | m_ialpha = 255 - m_alpha;
|
---|
97 | }
|
---|
98 |
|
---|
99 | inline void write(quint16 *dst, quint16 src) {
|
---|
100 | *dst = BYTE_MUL_RGB16(src, m_alpha) + BYTE_MUL_RGB16(*dst, m_ialpha);
|
---|
101 | }
|
---|
102 |
|
---|
103 | quint32 m_alpha;
|
---|
104 | quint32 m_ialpha;
|
---|
105 | };
|
---|
106 |
|
---|
107 | struct Blend_ARGB24_on_RGB16_SourceAlpha {
|
---|
108 | inline void write(quint16 *dst, const qargb8565 &src) {
|
---|
109 | const uint alpha = src.alpha();
|
---|
110 | if (alpha) {
|
---|
111 | quint16 s = src.rawValue16();
|
---|
112 | if (alpha < 255)
|
---|
113 | s += BYTE_MUL_RGB16(*dst, 255 - alpha);
|
---|
114 | *dst = s;
|
---|
115 | }
|
---|
116 | }
|
---|
117 | };
|
---|
118 |
|
---|
119 | struct Blend_ARGB24_on_RGB16_SourceAndConstAlpha {
|
---|
120 | inline Blend_ARGB24_on_RGB16_SourceAndConstAlpha(quint32 alpha) {
|
---|
121 | m_alpha = (alpha * 255) >> 8;
|
---|
122 | }
|
---|
123 |
|
---|
124 | inline void write(quint16 *dst, qargb8565 src) {
|
---|
125 | src = src.byte_mul(src.alpha(m_alpha));
|
---|
126 | const uint alpha = src.alpha();
|
---|
127 | if (alpha) {
|
---|
128 | quint16 s = src.rawValue16();
|
---|
129 | if (alpha < 255)
|
---|
130 | s += BYTE_MUL_RGB16(*dst, 255 - alpha);
|
---|
131 | *dst = s;
|
---|
132 | }
|
---|
133 | }
|
---|
134 |
|
---|
135 | quint32 m_alpha;
|
---|
136 | };
|
---|
137 |
|
---|
138 | struct Blend_ARGB32_on_RGB16_SourceAlpha {
|
---|
139 | inline void write(quint16 *dst, quint32 src) {
|
---|
140 | const quint8 alpha = qAlpha(src);
|
---|
141 | if(alpha) {
|
---|
142 | quint16 s = convert_argb32_to_rgb16(src);
|
---|
143 | if(alpha < 255)
|
---|
144 | s += BYTE_MUL_RGB16(*dst, 255 - alpha);
|
---|
145 | *dst = s;
|
---|
146 | }
|
---|
147 | }
|
---|
148 | };
|
---|
149 |
|
---|
150 | struct Blend_ARGB32_on_RGB16_SourceAndConstAlpha {
|
---|
151 | inline Blend_ARGB32_on_RGB16_SourceAndConstAlpha(quint32 alpha) {
|
---|
152 | m_alpha = (alpha * 255) >> 8;
|
---|
153 | }
|
---|
154 |
|
---|
155 | inline void write(quint16 *dst, quint32 src) {
|
---|
156 | src = BYTE_MUL(src, m_alpha);
|
---|
157 | const quint8 alpha = qAlpha(src);
|
---|
158 | if(alpha) {
|
---|
159 | quint16 s = convert_argb32_to_rgb16(src);
|
---|
160 | if(alpha < 255)
|
---|
161 | s += BYTE_MUL_RGB16(*dst, 255 - alpha);
|
---|
162 | *dst = s;
|
---|
163 | }
|
---|
164 | }
|
---|
165 |
|
---|
166 | quint32 m_alpha;
|
---|
167 | };
|
---|
168 |
|
---|
169 | template <typename SRC, typename T>
|
---|
170 | void qt_scale_image_16bit(uchar *destPixels, int dbpl,
|
---|
171 | const uchar *srcPixels, int sbpl,
|
---|
172 | const QRectF &targetRect,
|
---|
173 | const QRectF &srcRect,
|
---|
174 | const QRect &clip,
|
---|
175 | T blender)
|
---|
176 | {
|
---|
177 | qreal sx = targetRect.width() / (qreal) srcRect.width();
|
---|
178 | qreal sy = targetRect.height() / (qreal) srcRect.height();
|
---|
179 |
|
---|
180 | int ix = 0x00010000 / sx;
|
---|
181 | int iy = 0x00010000 / sy;
|
---|
182 |
|
---|
183 | // qDebug() << "scale:" << endl
|
---|
184 | // << " - target" << targetRect << endl
|
---|
185 | // << " - source" << srcRect << endl
|
---|
186 | // << " - clip" << clip << endl
|
---|
187 | // << " - sx=" << sx << " sy=" << sy << " ix=" << ix << " iy=" << iy;
|
---|
188 |
|
---|
189 | int cx1 = clip.x();
|
---|
190 | int cx2 = clip.x() + clip.width();
|
---|
191 | int cy1 = clip.top();
|
---|
192 | int cy2 = clip.y() + clip.height();
|
---|
193 |
|
---|
194 | int tx1 = qRound(targetRect.left());
|
---|
195 | int tx2 = qRound(targetRect.right());
|
---|
196 | int ty1 = qRound(targetRect.top());
|
---|
197 | int ty2 = qRound(targetRect.bottom());
|
---|
198 |
|
---|
199 | if (tx2 < tx1)
|
---|
200 | qSwap(tx2, tx1);
|
---|
201 |
|
---|
202 | if (ty2 < ty1)
|
---|
203 | qSwap(ty2, ty1);
|
---|
204 |
|
---|
205 | if (tx1 < cx1)
|
---|
206 | tx1 = cx1;
|
---|
207 |
|
---|
208 | if (tx2 >= cx2)
|
---|
209 | tx2 = cx2;
|
---|
210 |
|
---|
211 | if (tx1 >= tx2)
|
---|
212 | return;
|
---|
213 |
|
---|
214 | if (ty1 < cy1)
|
---|
215 | ty1 = cy1;
|
---|
216 |
|
---|
217 | if (ty2 >= cy2)
|
---|
218 | ty2 = cy2;
|
---|
219 |
|
---|
220 | if (ty1 >= ty2)
|
---|
221 | return;
|
---|
222 |
|
---|
223 | int h = ty2 - ty1;
|
---|
224 | int w = tx2 - tx1;
|
---|
225 |
|
---|
226 |
|
---|
227 | quint32 basex;
|
---|
228 | quint32 srcy;
|
---|
229 |
|
---|
230 | if (sx < 0) {
|
---|
231 | int dstx = qFloor((tx1 + qreal(0.5) - targetRect.right()) * ix) + 1;
|
---|
232 | basex = quint32(srcRect.right() * 65536) + dstx;
|
---|
233 | } else {
|
---|
234 | int dstx = qCeil((tx1 + qreal(0.5) - targetRect.left()) * ix) - 1;
|
---|
235 | basex = quint32(srcRect.left() * 65536) + dstx;
|
---|
236 | }
|
---|
237 | if (sy < 0) {
|
---|
238 | int dsty = qFloor((ty1 + qreal(0.5) - targetRect.bottom()) * iy) + 1;
|
---|
239 | srcy = quint32(srcRect.bottom() * 65536) + dsty;
|
---|
240 | } else {
|
---|
241 | int dsty = qCeil((ty1 + qreal(0.5) - targetRect.top()) * iy) - 1;
|
---|
242 | srcy = quint32(srcRect.top() * 65536) + dsty;
|
---|
243 | }
|
---|
244 |
|
---|
245 | quint16 *dst = ((quint16 *) (destPixels + ty1 * dbpl)) + tx1;
|
---|
246 |
|
---|
247 | while (h--) {
|
---|
248 | const SRC *src = (const SRC *) (srcPixels + (srcy >> 16) * sbpl);
|
---|
249 | int srcx = basex;
|
---|
250 | for (int x=0; x<w; ++x) {
|
---|
251 | blender.write(&dst[x], src[srcx >> 16]);
|
---|
252 | srcx += ix;
|
---|
253 | }
|
---|
254 | dst = (quint16 *)(((uchar *) dst) + dbpl);
|
---|
255 | srcy += iy;
|
---|
256 | }
|
---|
257 | }
|
---|
258 |
|
---|
259 | void qt_scale_image_rgb16_on_rgb16(uchar *destPixels, int dbpl,
|
---|
260 | const uchar *srcPixels, int sbpl,
|
---|
261 | const QRectF &targetRect,
|
---|
262 | const QRectF &sourceRect,
|
---|
263 | const QRect &clip,
|
---|
264 | int const_alpha)
|
---|
265 | {
|
---|
266 | #ifdef QT_DEBUG_DRAW
|
---|
267 | printf("qt_scale_rgb16_on_rgb16: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n",
|
---|
268 | destPixels, dbpl, srcPixels, sbpl,
|
---|
269 | targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
|
---|
270 | sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
|
---|
271 | const_alpha);
|
---|
272 | #endif
|
---|
273 | if (const_alpha == 256) {
|
---|
274 | Blend_RGB16_on_RGB16_NoAlpha noAlpha;
|
---|
275 | qt_scale_image_16bit<quint16>(destPixels, dbpl, srcPixels, sbpl,
|
---|
276 | targetRect, sourceRect, clip, noAlpha);
|
---|
277 | } else {
|
---|
278 | Blend_RGB16_on_RGB16_ConstAlpha constAlpha(const_alpha);
|
---|
279 | qt_scale_image_16bit<quint16>(destPixels, dbpl, srcPixels, sbpl,
|
---|
280 | targetRect, sourceRect, clip, constAlpha);
|
---|
281 | }
|
---|
282 | }
|
---|
283 |
|
---|
284 | void qt_scale_image_argb24_on_rgb16(uchar *destPixels, int dbpl,
|
---|
285 | const uchar *srcPixels, int sbpl,
|
---|
286 | const QRectF &targetRect,
|
---|
287 | const QRectF &sourceRect,
|
---|
288 | const QRect &clip,
|
---|
289 | int const_alpha)
|
---|
290 | {
|
---|
291 | #ifdef QT_DEBUG_DRAW
|
---|
292 | printf("qt_scale_argb24_on_rgb16: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n",
|
---|
293 | destPixels, dbpl, srcPixels, sbpl,
|
---|
294 | targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
|
---|
295 | sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
|
---|
296 | const_alpha);
|
---|
297 | #endif
|
---|
298 | if (const_alpha == 256) {
|
---|
299 | Blend_ARGB24_on_RGB16_SourceAlpha noAlpha;
|
---|
300 | qt_scale_image_16bit<qargb8565>(destPixels, dbpl, srcPixels, sbpl,
|
---|
301 | targetRect, sourceRect, clip, noAlpha);
|
---|
302 | } else {
|
---|
303 | Blend_ARGB24_on_RGB16_SourceAndConstAlpha constAlpha(const_alpha);
|
---|
304 | qt_scale_image_16bit<qargb8565>(destPixels, dbpl, srcPixels, sbpl,
|
---|
305 | targetRect, sourceRect, clip, constAlpha);
|
---|
306 | }
|
---|
307 | }
|
---|
308 |
|
---|
309 |
|
---|
310 | void qt_scale_image_argb32_on_rgb16(uchar *destPixels, int dbpl,
|
---|
311 | const uchar *srcPixels, int sbpl,
|
---|
312 | const QRectF &targetRect,
|
---|
313 | const QRectF &sourceRect,
|
---|
314 | const QRect &clip,
|
---|
315 | int const_alpha)
|
---|
316 | {
|
---|
317 | #ifdef QT_DEBUG_DRAW
|
---|
318 | printf("qt_scale_argb32_on_rgb16: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n",
|
---|
319 | destPixels, dbpl, srcPixels, sbpl,
|
---|
320 | targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
|
---|
321 | sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
|
---|
322 | const_alpha);
|
---|
323 | #endif
|
---|
324 | if (const_alpha == 256) {
|
---|
325 | Blend_ARGB32_on_RGB16_SourceAlpha noAlpha;
|
---|
326 | qt_scale_image_16bit<quint32>(destPixels, dbpl, srcPixels, sbpl,
|
---|
327 | targetRect, sourceRect, clip, noAlpha);
|
---|
328 | } else {
|
---|
329 | Blend_ARGB32_on_RGB16_SourceAndConstAlpha constAlpha(const_alpha);
|
---|
330 | qt_scale_image_16bit<quint32>(destPixels, dbpl, srcPixels, sbpl,
|
---|
331 | targetRect, sourceRect, clip, constAlpha);
|
---|
332 | }
|
---|
333 | }
|
---|
334 |
|
---|
335 | static void qt_blend_rgb16_on_rgb16(uchar *dst, int dbpl,
|
---|
336 | const uchar *src, int sbpl,
|
---|
337 | int w, int h,
|
---|
338 | int const_alpha)
|
---|
339 | {
|
---|
340 | #ifdef QT_DEBUG_DRAW
|
---|
341 | printf("qt_blend_rgb16_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
|
---|
342 | dst, dbpl, src, sbpl, w, h, const_alpha);
|
---|
343 | #endif
|
---|
344 |
|
---|
345 | if (const_alpha == 256) {
|
---|
346 | if (w <= 64) {
|
---|
347 | while (h--) {
|
---|
348 | QT_MEMCPY_USHORT(dst, src, w);
|
---|
349 | dst += dbpl;
|
---|
350 | src += sbpl;
|
---|
351 | }
|
---|
352 | } else {
|
---|
353 | int length = w << 1;
|
---|
354 | while (h--) {
|
---|
355 | memcpy(dst, src, length);
|
---|
356 | dst += dbpl;
|
---|
357 | src += sbpl;
|
---|
358 | }
|
---|
359 | }
|
---|
360 | } else if (const_alpha != 0) {
|
---|
361 | SourceAndConstAlpha alpha(const_alpha); // expects the 0-256 range
|
---|
362 | quint16 *d = (quint16 *) dst;
|
---|
363 | const quint16 *s = (const quint16 *) src;
|
---|
364 | quint8 a = (255 * const_alpha) >> 8;
|
---|
365 | quint8 ia = 255 - a;
|
---|
366 | while (h--) {
|
---|
367 | for (int x=0; x<w; ++x) {
|
---|
368 | d[x] = BYTE_MUL_RGB16(s[x], a) + BYTE_MUL_RGB16(d[x], ia);
|
---|
369 | }
|
---|
370 | d = (quint16 *)(((uchar *) d) + dbpl);
|
---|
371 | s = (const quint16 *)(((const uchar *) s) + sbpl);
|
---|
372 | }
|
---|
373 | }
|
---|
374 | }
|
---|
375 |
|
---|
376 |
|
---|
377 | template <typename T> void qt_blend_argb24_on_rgb16(uchar *destPixels, int dbpl,
|
---|
378 | const uchar *srcPixels, int sbpl,
|
---|
379 | int w, int h, const T &alphaFunc)
|
---|
380 | {
|
---|
381 | int srcOffset = w*3;
|
---|
382 | int dstJPL = dbpl / 2;
|
---|
383 | quint16 *dst = (quint16 *) destPixels;
|
---|
384 | int dstExtraStride = dstJPL - w;
|
---|
385 |
|
---|
386 | for (int y=0; y<h; ++y) {
|
---|
387 | const uchar *src = srcPixels + y * sbpl;
|
---|
388 | const uchar *srcEnd = src + srcOffset;
|
---|
389 | while (src < srcEnd) {
|
---|
390 | #if defined(QT_ARCH_ARM) || defined(QT_ARCH_POWERPC) || defined(QT_ARCH_SH) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_WINDOWSCE) && !defined(_X86_)) || (defined(QT_ARCH_SPARC) && defined(Q_CC_GNU))
|
---|
391 | // non-16-bit aligned memory access is not possible on PowerPC,
|
---|
392 | // ARM <v6 (QT_ARCH_ARMV6) & SH & AVR32 & SPARC w/GCC
|
---|
393 | quint16 spix = (quint16(src[2])<<8) + src[1];
|
---|
394 | #else
|
---|
395 | quint16 spix = *(quint16 *) (src + 1);
|
---|
396 | #endif
|
---|
397 | uchar alpha = alphaFunc.alpha(*src);
|
---|
398 |
|
---|
399 | if (alpha == 255) {
|
---|
400 | *dst = spix;
|
---|
401 | } else if (alpha != 0) {
|
---|
402 | quint16 dpix = *dst;
|
---|
403 | quint32 sia = 255 - alpha;
|
---|
404 |
|
---|
405 | quint16 dr = (dpix & 0x0000f800);
|
---|
406 | quint16 dg = (dpix & 0x000007e0);
|
---|
407 | quint16 db = (dpix & 0x0000001f);
|
---|
408 |
|
---|
409 | quint32 siar = dr * sia;
|
---|
410 | quint32 siag = dg * sia;
|
---|
411 | quint32 siab = db * sia;
|
---|
412 |
|
---|
413 | quint32 rr = ((siar + (siar>>8) + (0x80 << 8)) >> 8) & 0xf800;
|
---|
414 | quint32 rg = ((siag + (siag>>8) + (0x80 << 3)) >> 8) & 0x07e0;
|
---|
415 | quint32 rb = ((siab + (siab>>8) + (0x80 >> 3)) >> 8) & 0x001f;
|
---|
416 |
|
---|
417 | *dst = alphaFunc.bytemul(spix) + rr + rg + rb;
|
---|
418 | }
|
---|
419 |
|
---|
420 | ++dst;
|
---|
421 | src += 3;
|
---|
422 | }
|
---|
423 | dst += dstExtraStride;
|
---|
424 | }
|
---|
425 |
|
---|
426 | }
|
---|
427 |
|
---|
428 | static void qt_blend_argb24_on_rgb16(uchar *destPixels, int dbpl,
|
---|
429 | const uchar *srcPixels, int sbpl,
|
---|
430 | int w, int h,
|
---|
431 | int const_alpha)
|
---|
432 | {
|
---|
433 | #ifdef QT_DEBUG_DRAW
|
---|
434 | printf("qt_blend_argb24_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
|
---|
435 | destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
|
---|
436 | #endif
|
---|
437 |
|
---|
438 | if (const_alpha != 256) {
|
---|
439 | SourceAndConstAlpha alphaFunc(const_alpha);
|
---|
440 | qt_blend_argb24_on_rgb16(destPixels, dbpl, srcPixels, sbpl, w, h, alphaFunc);
|
---|
441 | } else {
|
---|
442 | SourceOnlyAlpha alphaFunc;
|
---|
443 | qt_blend_argb24_on_rgb16(destPixels, dbpl, srcPixels, sbpl, w, h, alphaFunc);
|
---|
444 | }
|
---|
445 | }
|
---|
446 |
|
---|
447 |
|
---|
448 |
|
---|
449 |
|
---|
450 | static void qt_blend_argb32_on_rgb16_const_alpha(uchar *destPixels, int dbpl,
|
---|
451 | const uchar *srcPixels, int sbpl,
|
---|
452 | int w, int h,
|
---|
453 | int const_alpha)
|
---|
454 | {
|
---|
455 | quint16 *dst = (quint16 *) destPixels;
|
---|
456 | const quint32 *src = (const quint32 *) srcPixels;
|
---|
457 |
|
---|
458 | const_alpha = (const_alpha * 255) >> 8;
|
---|
459 | for (int y=0; y<h; ++y) {
|
---|
460 | for (int i = 0; i < w; ++i) {
|
---|
461 | uint s = src[i];
|
---|
462 | s = BYTE_MUL(s, const_alpha);
|
---|
463 | int alpha = qAlpha(s);
|
---|
464 | s = convert_argb32_to_rgb16(s);
|
---|
465 | s += BYTE_MUL_RGB16(dst[i], 255 - alpha);
|
---|
466 | dst[i] = s;
|
---|
467 | }
|
---|
468 | dst = (quint16 *)(((uchar *) dst) + dbpl);
|
---|
469 | src = (const quint32 *)(((const uchar *) src) + sbpl);
|
---|
470 | }
|
---|
471 | }
|
---|
472 |
|
---|
473 | static void qt_blend_argb32_on_rgb16(uchar *destPixels, int dbpl,
|
---|
474 | const uchar *srcPixels, int sbpl,
|
---|
475 | int w, int h,
|
---|
476 | int const_alpha)
|
---|
477 | {
|
---|
478 | if (const_alpha != 256) {
|
---|
479 | qt_blend_argb32_on_rgb16_const_alpha(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
|
---|
480 | return;
|
---|
481 | }
|
---|
482 |
|
---|
483 | quint16 *dst = (quint16 *) destPixels;
|
---|
484 | quint32 *src = (quint32 *) srcPixels;
|
---|
485 |
|
---|
486 | for (int y=0; y<h; ++y) {
|
---|
487 | for (int x=0; x<w; ++x) {
|
---|
488 |
|
---|
489 | quint32 spix = src[x];
|
---|
490 | quint32 alpha = spix >> 24;
|
---|
491 |
|
---|
492 | if (alpha == 255) {
|
---|
493 | dst[x] = convert_argb32_to_rgb16(spix);
|
---|
494 | } else if (alpha != 0) {
|
---|
495 | quint32 dpix = dst[x];
|
---|
496 |
|
---|
497 | quint32 sia = 255 - alpha;
|
---|
498 |
|
---|
499 | quint32 sr = (spix >> 8) & 0xf800;
|
---|
500 | quint32 sg = (spix >> 5) & 0x07e0;
|
---|
501 | quint32 sb = (spix >> 3) & 0x001f;
|
---|
502 |
|
---|
503 | quint32 dr = (dpix & 0x0000f800);
|
---|
504 | quint32 dg = (dpix & 0x000007e0);
|
---|
505 | quint32 db = (dpix & 0x0000001f);
|
---|
506 |
|
---|
507 | quint32 siar = dr * sia;
|
---|
508 | quint32 siag = dg * sia;
|
---|
509 | quint32 siab = db * sia;
|
---|
510 |
|
---|
511 | quint32 rr = sr + ((siar + (siar>>8) + (0x80 << 8)) >> 8);
|
---|
512 | quint32 rg = sg + ((siag + (siag>>8) + (0x80 << 3)) >> 8);
|
---|
513 | quint32 rb = sb + ((siab + (siab>>8) + (0x80 >> 3)) >> 8);
|
---|
514 |
|
---|
515 | dst[x] = (rr & 0xf800)
|
---|
516 | | (rg & 0x07e0)
|
---|
517 | | (rb);
|
---|
518 | }
|
---|
519 | }
|
---|
520 | dst = (quint16 *) (((uchar *) dst) + dbpl);
|
---|
521 | src = (quint32 *) (((uchar *) src) + sbpl);
|
---|
522 | }
|
---|
523 | }
|
---|
524 |
|
---|
525 |
|
---|
526 | static void qt_blend_rgb32_on_rgb16(uchar *destPixels, int dbpl,
|
---|
527 | const uchar *srcPixels, int sbpl,
|
---|
528 | int w, int h,
|
---|
529 | int const_alpha)
|
---|
530 | {
|
---|
531 | #ifdef QT_DEBUG_DRAW
|
---|
532 | printf("qt_blend_rgb32_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
|
---|
533 | destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
|
---|
534 | #endif
|
---|
535 |
|
---|
536 | if (const_alpha != 256) {
|
---|
537 | qt_blend_argb32_on_rgb16(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
|
---|
538 | return;
|
---|
539 | }
|
---|
540 |
|
---|
541 | const quint32 *src = (const quint32 *) srcPixels;
|
---|
542 | int srcExtraStride = (sbpl >> 2) - w;
|
---|
543 |
|
---|
544 | int dstJPL = dbpl / 2;
|
---|
545 |
|
---|
546 | quint16 *dst = (quint16 *) destPixels;
|
---|
547 | quint16 *dstEnd = dst + dstJPL * h;
|
---|
548 |
|
---|
549 | int dstExtraStride = dstJPL - w;
|
---|
550 |
|
---|
551 | while (dst < dstEnd) {
|
---|
552 | const quint32 *srcEnd = src + w;
|
---|
553 | while (src < srcEnd) {
|
---|
554 | *dst = convert_argb32_to_rgb16(*src);
|
---|
555 | ++dst;
|
---|
556 | ++src;
|
---|
557 | }
|
---|
558 | dst += dstExtraStride;
|
---|
559 | src += srcExtraStride;
|
---|
560 | }
|
---|
561 | }
|
---|
562 |
|
---|
563 |
|
---|
564 |
|
---|
565 | /************************************************************************
|
---|
566 | RGB32 (-888) format target format
|
---|
567 | ************************************************************************/
|
---|
568 |
|
---|
569 | static void qt_blend_argb32_on_argb32(uchar *destPixels, int dbpl,
|
---|
570 | const uchar *srcPixels, int sbpl,
|
---|
571 | int w, int h,
|
---|
572 | int const_alpha)
|
---|
573 | {
|
---|
574 | #ifdef QT_DEBUG_DRAW
|
---|
575 | fprintf(stdout, "qt_blend_argb32_on_argb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
|
---|
576 | destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
|
---|
577 | fflush(stdout);
|
---|
578 | #endif
|
---|
579 |
|
---|
580 | const uint *src = (const uint *) srcPixels;
|
---|
581 | uint *dst = (uint *) destPixels;
|
---|
582 | if (const_alpha == 256) {
|
---|
583 | for (int y=0; y<h; ++y) {
|
---|
584 | for (int x=0; x<w; ++x) {
|
---|
585 | uint s = src[x];
|
---|
586 | if (s >= 0xff000000)
|
---|
587 | dst[x] = s;
|
---|
588 | else if (s != 0)
|
---|
589 | dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
|
---|
590 | }
|
---|
591 | dst = (quint32 *)(((uchar *) dst) + dbpl);
|
---|
592 | src = (const quint32 *)(((const uchar *) src) + sbpl);
|
---|
593 | }
|
---|
594 | } else if (const_alpha != 0) {
|
---|
595 | const_alpha = (const_alpha * 255) >> 8;
|
---|
596 | for (int y=0; y<h; ++y) {
|
---|
597 | for (int x=0; x<w; ++x) {
|
---|
598 | uint s = BYTE_MUL(src[x], const_alpha);
|
---|
599 | dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
|
---|
600 | }
|
---|
601 | dst = (quint32 *)(((uchar *) dst) + dbpl);
|
---|
602 | src = (const quint32 *)(((const uchar *) src) + sbpl);
|
---|
603 | }
|
---|
604 | }
|
---|
605 | }
|
---|
606 |
|
---|
607 |
|
---|
608 | void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl,
|
---|
609 | const uchar *srcPixels, int sbpl,
|
---|
610 | int w, int h,
|
---|
611 | int const_alpha)
|
---|
612 | {
|
---|
613 | #ifdef QT_DEBUG_DRAW
|
---|
614 | fprintf(stdout, "qt_blend_rgb32_on_rgb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
|
---|
615 | destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
|
---|
616 | fflush(stdout);
|
---|
617 | #endif
|
---|
618 |
|
---|
619 | if (const_alpha != 256) {
|
---|
620 | qt_blend_argb32_on_argb32(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
|
---|
621 | return;
|
---|
622 | }
|
---|
623 |
|
---|
624 | const uint *src = (const uint *) srcPixels;
|
---|
625 | uint *dst = (uint *) destPixels;
|
---|
626 | if (w <= 64) {
|
---|
627 | for (int y=0; y<h; ++y) {
|
---|
628 | qt_memconvert(dst, src, w);
|
---|
629 | dst = (quint32 *)(((uchar *) dst) + dbpl);
|
---|
630 | src = (const quint32 *)(((const uchar *) src) + sbpl);
|
---|
631 | }
|
---|
632 | } else {
|
---|
633 | int len = w * 4;
|
---|
634 | for (int y=0; y<h; ++y) {
|
---|
635 | memcpy(dst, src, len);
|
---|
636 | dst = (quint32 *)(((uchar *) dst) + dbpl);
|
---|
637 | src = (const quint32 *)(((const uchar *) src) + sbpl);
|
---|
638 | }
|
---|
639 | }
|
---|
640 | }
|
---|
641 |
|
---|
642 |
|
---|
643 |
|
---|
644 | struct Blend_RGB32_on_RGB32_NoAlpha {
|
---|
645 | inline void write(quint32 *dst, quint32 src) { *dst = src; }
|
---|
646 | };
|
---|
647 |
|
---|
648 | struct Blend_RGB32_on_RGB32_ConstAlpha {
|
---|
649 | inline Blend_RGB32_on_RGB32_ConstAlpha(quint32 alpha) {
|
---|
650 | m_alpha = (alpha * 255) >> 8;
|
---|
651 | m_ialpha = 255 - m_alpha;
|
---|
652 | }
|
---|
653 |
|
---|
654 | inline void write(quint32 *dst, quint32 src) {
|
---|
655 | *dst = BYTE_MUL(src, m_alpha) + BYTE_MUL(*dst, m_ialpha);
|
---|
656 | }
|
---|
657 |
|
---|
658 | quint32 m_alpha;
|
---|
659 | quint32 m_ialpha;
|
---|
660 | };
|
---|
661 |
|
---|
662 | struct Blend_ARGB32_on_ARGB32_SourceAlpha {
|
---|
663 | inline void write(quint32 *dst, quint32 src) {
|
---|
664 | *dst = src + BYTE_MUL(*dst, qAlpha(~src));
|
---|
665 | }
|
---|
666 | };
|
---|
667 |
|
---|
668 | struct Blend_ARGB32_on_ARGB32_SourceAndConstAlpha {
|
---|
669 | inline Blend_ARGB32_on_ARGB32_SourceAndConstAlpha(quint32 alpha) {
|
---|
670 | m_alpha = (alpha * 255) >> 8;
|
---|
671 | m_ialpha = 255 - m_alpha;
|
---|
672 | }
|
---|
673 |
|
---|
674 | inline void write(quint32 *dst, quint32 src) {
|
---|
675 | src = BYTE_MUL(src, m_alpha);
|
---|
676 | *dst = src + BYTE_MUL(*dst, qAlpha(~src));
|
---|
677 | }
|
---|
678 |
|
---|
679 | quint32 m_alpha;
|
---|
680 | quint32 m_ialpha;
|
---|
681 | };
|
---|
682 |
|
---|
683 | template <typename T> void qt_scale_image_32bit(uchar *destPixels, int dbpl,
|
---|
684 | const uchar *srcPixels, int sbpl,
|
---|
685 | const QRectF &targetRect,
|
---|
686 | const QRectF &srcRect,
|
---|
687 | const QRect &clip,
|
---|
688 | T blender)
|
---|
689 | {
|
---|
690 | qreal sx = targetRect.width() / (qreal) srcRect.width();
|
---|
691 | qreal sy = targetRect.height() / (qreal) srcRect.height();
|
---|
692 |
|
---|
693 | int ix = 0x00010000 / sx;
|
---|
694 | int iy = 0x00010000 / sy;
|
---|
695 |
|
---|
696 | // qDebug() << "scale:" << endl
|
---|
697 | // << " - target" << targetRect << endl
|
---|
698 | // << " - source" << srcRect << endl
|
---|
699 | // << " - clip" << clip << endl
|
---|
700 | // << " - sx=" << sx << " sy=" << sy << " ix=" << ix << " iy=" << iy;
|
---|
701 |
|
---|
702 | int cx1 = clip.x();
|
---|
703 | int cx2 = clip.x() + clip.width();
|
---|
704 | int cy1 = clip.top();
|
---|
705 | int cy2 = clip.y() + clip.height();
|
---|
706 |
|
---|
707 | int tx1 = qRound(targetRect.left());
|
---|
708 | int tx2 = qRound(targetRect.right());
|
---|
709 | int ty1 = qRound(targetRect.top());
|
---|
710 | int ty2 = qRound(targetRect.bottom());
|
---|
711 |
|
---|
712 | if (tx2 < tx1)
|
---|
713 | qSwap(tx2, tx1);
|
---|
714 |
|
---|
715 | if (ty2 < ty1)
|
---|
716 | qSwap(ty2, ty1);
|
---|
717 |
|
---|
718 | if (tx1 < cx1)
|
---|
719 | tx1 = cx1;
|
---|
720 |
|
---|
721 | if (tx2 >= cx2)
|
---|
722 | tx2 = cx2;
|
---|
723 |
|
---|
724 | if (tx1 >= tx2)
|
---|
725 | return;
|
---|
726 |
|
---|
727 | if (ty1 < cy1)
|
---|
728 | ty1 = cy1;
|
---|
729 |
|
---|
730 | if (ty2 >= cy2)
|
---|
731 | ty2 = cy2;
|
---|
732 |
|
---|
733 | if (ty1 >= ty2)
|
---|
734 | return;
|
---|
735 |
|
---|
736 | int h = ty2 - ty1;
|
---|
737 | int w = tx2 - tx1;
|
---|
738 |
|
---|
739 | quint32 basex;
|
---|
740 | quint32 srcy;
|
---|
741 |
|
---|
742 | if (sx < 0) {
|
---|
743 | int dstx = qFloor((tx1 + qreal(0.5) - targetRect.right()) * ix) + 1;
|
---|
744 | basex = quint32(srcRect.right() * 65536) + dstx;
|
---|
745 | } else {
|
---|
746 | int dstx = qCeil((tx1 + qreal(0.5) - targetRect.left()) * ix) - 1;
|
---|
747 | basex = quint32(srcRect.left() * 65536) + dstx;
|
---|
748 | }
|
---|
749 | if (sy < 0) {
|
---|
750 | int dsty = qFloor((ty1 + qreal(0.5) - targetRect.bottom()) * iy) + 1;
|
---|
751 | srcy = quint32(srcRect.bottom() * 65536) + dsty;
|
---|
752 | } else {
|
---|
753 | int dsty = qCeil((ty1 + qreal(0.5) - targetRect.top()) * iy) - 1;
|
---|
754 | srcy = quint32(srcRect.top() * 65536) + dsty;
|
---|
755 | }
|
---|
756 |
|
---|
757 | quint32 *dst = ((quint32 *) (destPixels + ty1 * dbpl)) + tx1;
|
---|
758 |
|
---|
759 | while (h--) {
|
---|
760 | const uint *src = (const quint32 *) (srcPixels + (srcy >> 16) * sbpl);
|
---|
761 | int srcx = basex;
|
---|
762 | for (int x=0; x<w; ++x) {
|
---|
763 | blender.write(&dst[x], src[srcx >> 16]);
|
---|
764 | srcx += ix;
|
---|
765 | }
|
---|
766 | dst = (quint32 *)(((uchar *) dst) + dbpl);
|
---|
767 | srcy += iy;
|
---|
768 | }
|
---|
769 | }
|
---|
770 |
|
---|
771 | void qt_scale_image_rgb32_on_rgb32(uchar *destPixels, int dbpl,
|
---|
772 | const uchar *srcPixels, int sbpl,
|
---|
773 | const QRectF &targetRect,
|
---|
774 | const QRectF &sourceRect,
|
---|
775 | const QRect &clip,
|
---|
776 | int const_alpha)
|
---|
777 | {
|
---|
778 | #ifdef QT_DEBUG_DRAW
|
---|
779 | printf("qt_scale_rgb32_on_rgb32: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n",
|
---|
780 | destPixels, dbpl, srcPixels, sbpl,
|
---|
781 | targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
|
---|
782 | sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
|
---|
783 | const_alpha);
|
---|
784 | #endif
|
---|
785 | if (const_alpha == 256) {
|
---|
786 | Blend_RGB32_on_RGB32_NoAlpha noAlpha;
|
---|
787 | qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl,
|
---|
788 | targetRect, sourceRect, clip, noAlpha);
|
---|
789 | } else {
|
---|
790 | Blend_RGB32_on_RGB32_ConstAlpha constAlpha(const_alpha);
|
---|
791 | qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl,
|
---|
792 | targetRect, sourceRect, clip, constAlpha);
|
---|
793 | }
|
---|
794 | }
|
---|
795 |
|
---|
796 | void qt_scale_image_argb32_on_argb32(uchar *destPixels, int dbpl,
|
---|
797 | const uchar *srcPixels, int sbpl,
|
---|
798 | const QRectF &targetRect,
|
---|
799 | const QRectF &sourceRect,
|
---|
800 | const QRect &clip,
|
---|
801 | int const_alpha)
|
---|
802 | {
|
---|
803 | #ifdef QT_DEBUG_DRAW
|
---|
804 | printf("qt_scale_argb32_on_argb32: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n",
|
---|
805 | destPixels, dbpl, srcPixels, sbpl,
|
---|
806 | targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
|
---|
807 | sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
|
---|
808 | const_alpha);
|
---|
809 | #endif
|
---|
810 | if (const_alpha == 256) {
|
---|
811 | Blend_ARGB32_on_ARGB32_SourceAlpha sourceAlpha;
|
---|
812 | qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl,
|
---|
813 | targetRect, sourceRect, clip, sourceAlpha);
|
---|
814 | } else {
|
---|
815 | Blend_ARGB32_on_ARGB32_SourceAndConstAlpha constAlpha(const_alpha);
|
---|
816 | qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl,
|
---|
817 | targetRect, sourceRect, clip, constAlpha);
|
---|
818 | }
|
---|
819 | }
|
---|
820 |
|
---|
821 | struct QTransformImageVertex
|
---|
822 | {
|
---|
823 | qreal x, y, u, v; // destination coordinates (x, y) and source coordinates (u, v)
|
---|
824 | };
|
---|
825 |
|
---|
826 | template <class SrcT, class DestT, class Blender>
|
---|
827 | void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
|
---|
828 | const SrcT *srcPixels, int sbpl,
|
---|
829 | const QTransformImageVertex &topLeft, const QTransformImageVertex &bottomLeft,
|
---|
830 | const QTransformImageVertex &topRight, const QTransformImageVertex &bottomRight,
|
---|
831 | const QRect &sourceRect,
|
---|
832 | const QRect &clip,
|
---|
833 | qreal topY, qreal bottomY,
|
---|
834 | int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
|
---|
835 | Blender blender)
|
---|
836 | {
|
---|
837 | int fromY = qMax(qRound(topY), clip.top());
|
---|
838 | int toY = qMin(qRound(bottomY), clip.top() + clip.height());
|
---|
839 | if (fromY >= toY)
|
---|
840 | return;
|
---|
841 |
|
---|
842 | qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
|
---|
843 | qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
|
---|
844 | int dx_l = int(leftSlope * 0x10000);
|
---|
845 | int dx_r = int(rightSlope * 0x10000);
|
---|
846 | int x_l = int((topLeft.x + (0.5 + fromY - topLeft.y) * leftSlope + 0.5) * 0x10000);
|
---|
847 | int x_r = int((topRight.x + (0.5 + fromY - topRight.y) * rightSlope + 0.5) * 0x10000);
|
---|
848 |
|
---|
849 | int fromX, toX, x1, x2, u, v, i, ii;
|
---|
850 | DestT *line;
|
---|
851 | for (int y = fromY; y < toY; ++y) {
|
---|
852 | line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
|
---|
853 |
|
---|
854 | fromX = qMax(x_l >> 16, clip.left());
|
---|
855 | toX = qMin(x_r >> 16, clip.left() + clip.width());
|
---|
856 | if (fromX < toX) {
|
---|
857 | // Because of rounding, we can get source coordinates outside the source image.
|
---|
858 | // Clamp these coordinates to the source rect to avoid segmentation fault and
|
---|
859 | // garbage on the screen.
|
---|
860 |
|
---|
861 | // Find the first pixel on the current scan line where the source coordinates are within the source rect.
|
---|
862 | x1 = fromX;
|
---|
863 | u = x1 * dudx + y * dudy + u0;
|
---|
864 | v = x1 * dvdx + y * dvdy + v0;
|
---|
865 | for (; x1 < toX; ++x1) {
|
---|
866 | int uu = u >> 16;
|
---|
867 | int vv = v >> 16;
|
---|
868 | if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
|
---|
869 | && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
|
---|
870 | break;
|
---|
871 | }
|
---|
872 | u += dudx;
|
---|
873 | v += dvdx;
|
---|
874 | }
|
---|
875 |
|
---|
876 | // Find the last pixel on the current scan line where the source coordinates are within the source rect.
|
---|
877 | x2 = toX;
|
---|
878 | u = (x2 - 1) * dudx + y * dudy + u0;
|
---|
879 | v = (x2 - 1) * dvdx + y * dvdy + v0;
|
---|
880 | for (; x2 > x1; --x2) {
|
---|
881 | int uu = u >> 16;
|
---|
882 | int vv = v >> 16;
|
---|
883 | if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
|
---|
884 | && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
|
---|
885 | break;
|
---|
886 | }
|
---|
887 | u -= dudx;
|
---|
888 | v -= dvdx;
|
---|
889 | }
|
---|
890 |
|
---|
891 | // Set up values at the beginning of the scan line.
|
---|
892 | u = fromX * dudx + y * dudy + u0;
|
---|
893 | v = fromX * dvdx + y * dvdy + v0;
|
---|
894 | line += fromX;
|
---|
895 |
|
---|
896 | // Beginning of the scan line, with per-pixel checks.
|
---|
897 | i = x1 - fromX;
|
---|
898 | while (i) {
|
---|
899 | int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
|
---|
900 | int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
|
---|
901 | blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
|
---|
902 | u += dudx;
|
---|
903 | v += dvdx;
|
---|
904 | ++line;
|
---|
905 | --i;
|
---|
906 | }
|
---|
907 |
|
---|
908 | // Middle of the scan line, without checks.
|
---|
909 | // Manual loop unrolling.
|
---|
910 | i = x2 - x1;
|
---|
911 | ii = i >> 3;
|
---|
912 | while (ii) {
|
---|
913 | blender.write(&line[0], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
|
---|
914 | blender.write(&line[1], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
|
---|
915 | blender.write(&line[2], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
|
---|
916 | blender.write(&line[3], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
|
---|
917 | blender.write(&line[4], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
|
---|
918 | blender.write(&line[5], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
|
---|
919 | blender.write(&line[6], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
|
---|
920 | blender.write(&line[7], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
|
---|
921 | line += 8;
|
---|
922 | --ii;
|
---|
923 | }
|
---|
924 | switch (i & 7) {
|
---|
925 | case 7: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
|
---|
926 | case 6: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
|
---|
927 | case 5: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
|
---|
928 | case 4: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
|
---|
929 | case 3: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
|
---|
930 | case 2: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
|
---|
931 | case 1: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
|
---|
932 | }
|
---|
933 |
|
---|
934 | // End of the scan line, with per-pixel checks.
|
---|
935 | i = toX - x2;
|
---|
936 | while (i) {
|
---|
937 | int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
|
---|
938 | int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
|
---|
939 | blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
|
---|
940 | u += dudx;
|
---|
941 | v += dvdx;
|
---|
942 | ++line;
|
---|
943 | --i;
|
---|
944 | }
|
---|
945 | }
|
---|
946 | x_l += dx_l;
|
---|
947 | x_r += dx_r;
|
---|
948 | }
|
---|
949 | }
|
---|
950 |
|
---|
951 | template <class SrcT, class DestT, class Blender>
|
---|
952 | void qt_transform_image(DestT *destPixels, int dbpl,
|
---|
953 | const SrcT *srcPixels, int sbpl,
|
---|
954 | const QRectF &targetRect,
|
---|
955 | const QRectF &sourceRect,
|
---|
956 | const QRect &clip,
|
---|
957 | const QTransform &targetRectTransform,
|
---|
958 | Blender blender)
|
---|
959 | {
|
---|
960 | enum Corner
|
---|
961 | {
|
---|
962 | TopLeft,
|
---|
963 | TopRight,
|
---|
964 | BottomRight,
|
---|
965 | BottomLeft
|
---|
966 | };
|
---|
967 |
|
---|
968 | // map source rectangle to destination.
|
---|
969 | QTransformImageVertex v[4];
|
---|
970 | v[TopLeft].u = v[BottomLeft].u = sourceRect.left();
|
---|
971 | v[TopLeft].v = v[TopRight].v = sourceRect.top();
|
---|
972 | v[TopRight].u = v[BottomRight].u = sourceRect.right();
|
---|
973 | v[BottomLeft].v = v[BottomRight].v = sourceRect.bottom();
|
---|
974 | targetRectTransform.map(targetRect.left(), targetRect.top(), &v[TopLeft].x, &v[TopLeft].y);
|
---|
975 | targetRectTransform.map(targetRect.right(), targetRect.top(), &v[TopRight].x, &v[TopRight].y);
|
---|
976 | targetRectTransform.map(targetRect.left(), targetRect.bottom(), &v[BottomLeft].x, &v[BottomLeft].y);
|
---|
977 | targetRectTransform.map(targetRect.right(), targetRect.bottom(), &v[BottomRight].x, &v[BottomRight].y);
|
---|
978 |
|
---|
979 | // find topmost vertex.
|
---|
980 | int topmost = 0;
|
---|
981 | for (int i = 1; i < 4; ++i) {
|
---|
982 | if (v[i].y < v[topmost].y)
|
---|
983 | topmost = i;
|
---|
984 | }
|
---|
985 | // rearrange array such that topmost vertex is at index 0.
|
---|
986 | switch (topmost) {
|
---|
987 | case 1:
|
---|
988 | {
|
---|
989 | QTransformImageVertex t = v[0];
|
---|
990 | for (int i = 0; i < 3; ++i)
|
---|
991 | v[i] = v[i+1];
|
---|
992 | v[3] = t;
|
---|
993 | }
|
---|
994 | break;
|
---|
995 | case 2:
|
---|
996 | qSwap(v[0], v[2]);
|
---|
997 | qSwap(v[1], v[3]);
|
---|
998 | break;
|
---|
999 | case 3:
|
---|
1000 | {
|
---|
1001 | QTransformImageVertex t = v[3];
|
---|
1002 | for (int i = 3; i > 0; --i)
|
---|
1003 | v[i] = v[i-1];
|
---|
1004 | v[0] = t;
|
---|
1005 | }
|
---|
1006 | break;
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 | // if necessary, swap vertex 1 and 3 such that 1 is to the left of 3.
|
---|
1010 | qreal dx1 = v[1].x - v[0].x;
|
---|
1011 | qreal dy1 = v[1].y - v[0].y;
|
---|
1012 | qreal dx2 = v[3].x - v[0].x;
|
---|
1013 | qreal dy2 = v[3].y - v[0].y;
|
---|
1014 | if (dx1 * dy2 - dx2 * dy1 > 0)
|
---|
1015 | qSwap(v[1], v[3]);
|
---|
1016 |
|
---|
1017 | QTransformImageVertex u = {v[1].x - v[0].x, v[1].y - v[0].y, v[1].u - v[0].u, v[1].v - v[0].v};
|
---|
1018 | QTransformImageVertex w = {v[2].x - v[0].x, v[2].y - v[0].y, v[2].u - v[0].u, v[2].v - v[0].v};
|
---|
1019 |
|
---|
1020 | qreal det = u.x * w.y - u.y * w.x;
|
---|
1021 | if (det == 0)
|
---|
1022 | return;
|
---|
1023 |
|
---|
1024 | qreal invDet = 1.0 / det;
|
---|
1025 | qreal m11, m12, m21, m22, mdx, mdy;
|
---|
1026 |
|
---|
1027 | m11 = (u.u * w.y - u.y * w.u) * invDet;
|
---|
1028 | m12 = (u.x * w.u - u.u * w.x) * invDet;
|
---|
1029 | m21 = (u.v * w.y - u.y * w.v) * invDet;
|
---|
1030 | m22 = (u.x * w.v - u.v * w.x) * invDet;
|
---|
1031 | mdx = v[0].u - m11 * v[0].x - m12 * v[0].y;
|
---|
1032 | mdy = v[0].v - m21 * v[0].x - m22 * v[0].y;
|
---|
1033 |
|
---|
1034 | int dudx = int(m11 * 0x10000);
|
---|
1035 | int dvdx = int(m21 * 0x10000);
|
---|
1036 | int dudy = int(m12 * 0x10000);
|
---|
1037 | int dvdy = int(m22 * 0x10000);
|
---|
1038 | int u0 = qCeil((0.5 * m11 + 0.5 * m12 + mdx) * 0x10000) - 1;
|
---|
1039 | int v0 = qCeil((0.5 * m21 + 0.5 * m22 + mdy) * 0x10000) - 1;
|
---|
1040 |
|
---|
1041 | int x1 = qFloor(sourceRect.left());
|
---|
1042 | int y1 = qFloor(sourceRect.top());
|
---|
1043 | int x2 = qCeil(sourceRect.right());
|
---|
1044 | int y2 = qCeil(sourceRect.bottom());
|
---|
1045 | QRect sourceRectI(x1, y1, x2 - x1, y2 - y1);
|
---|
1046 |
|
---|
1047 | // rasterize trapezoids.
|
---|
1048 | if (v[1].y < v[3].y) {
|
---|
1049 | qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[0], v[1], v[0], v[3], sourceRectI, clip, v[0].y, v[1].y, dudx, dvdx, dudy, dvdy, u0, v0, blender);
|
---|
1050 | qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[1], v[2], v[0], v[3], sourceRectI, clip, v[1].y, v[3].y, dudx, dvdx, dudy, dvdy, u0, v0, blender);
|
---|
1051 | qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[1], v[2], v[3], v[2], sourceRectI, clip, v[3].y, v[2].y, dudx, dvdx, dudy, dvdy, u0, v0, blender);
|
---|
1052 | } else {
|
---|
1053 | qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[0], v[1], v[0], v[3], sourceRectI, clip, v[0].y, v[3].y, dudx, dvdx, dudy, dvdy, u0, v0, blender);
|
---|
1054 | qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[0], v[1], v[3], v[2], sourceRectI, clip, v[3].y, v[1].y, dudx, dvdx, dudy, dvdy, u0, v0, blender);
|
---|
1055 | qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[1], v[2], v[3], v[2], sourceRectI, clip, v[1].y, v[2].y, dudx, dvdx, dudy, dvdy, u0, v0, blender);
|
---|
1056 | }
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 | void qt_transform_image_rgb16_on_rgb16(uchar *destPixels, int dbpl,
|
---|
1060 | const uchar *srcPixels, int sbpl,
|
---|
1061 | const QRectF &targetRect,
|
---|
1062 | const QRectF &sourceRect,
|
---|
1063 | const QRect &clip,
|
---|
1064 | const QTransform &targetRectTransform,
|
---|
1065 | int const_alpha)
|
---|
1066 | {
|
---|
1067 | if (const_alpha == 256) {
|
---|
1068 | Blend_RGB16_on_RGB16_NoAlpha noAlpha;
|
---|
1069 | qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl,
|
---|
1070 | reinterpret_cast<const quint16 *>(srcPixels), sbpl,
|
---|
1071 | targetRect, sourceRect, clip, targetRectTransform, noAlpha);
|
---|
1072 | } else {
|
---|
1073 | Blend_RGB16_on_RGB16_ConstAlpha constAlpha(const_alpha);
|
---|
1074 | qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl,
|
---|
1075 | reinterpret_cast<const quint16 *>(srcPixels), sbpl,
|
---|
1076 | targetRect, sourceRect, clip, targetRectTransform, constAlpha);
|
---|
1077 | }
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | void qt_transform_image_argb24_on_rgb16(uchar *destPixels, int dbpl,
|
---|
1081 | const uchar *srcPixels, int sbpl,
|
---|
1082 | const QRectF &targetRect,
|
---|
1083 | const QRectF &sourceRect,
|
---|
1084 | const QRect &clip,
|
---|
1085 | const QTransform &targetRectTransform,
|
---|
1086 | int const_alpha)
|
---|
1087 | {
|
---|
1088 | if (const_alpha == 256) {
|
---|
1089 | Blend_ARGB24_on_RGB16_SourceAlpha noAlpha;
|
---|
1090 | qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl,
|
---|
1091 | reinterpret_cast<const qargb8565 *>(srcPixels), sbpl,
|
---|
1092 | targetRect, sourceRect, clip, targetRectTransform, noAlpha);
|
---|
1093 | } else {
|
---|
1094 | Blend_ARGB24_on_RGB16_SourceAndConstAlpha constAlpha(const_alpha);
|
---|
1095 | qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl,
|
---|
1096 | reinterpret_cast<const qargb8565 *>(srcPixels), sbpl,
|
---|
1097 | targetRect, sourceRect, clip, targetRectTransform, constAlpha);
|
---|
1098 | }
|
---|
1099 | }
|
---|
1100 |
|
---|
1101 |
|
---|
1102 | void qt_transform_image_argb32_on_rgb16(uchar *destPixels, int dbpl,
|
---|
1103 | const uchar *srcPixels, int sbpl,
|
---|
1104 | const QRectF &targetRect,
|
---|
1105 | const QRectF &sourceRect,
|
---|
1106 | const QRect &clip,
|
---|
1107 | const QTransform &targetRectTransform,
|
---|
1108 | int const_alpha)
|
---|
1109 | {
|
---|
1110 | if (const_alpha == 256) {
|
---|
1111 | Blend_ARGB32_on_RGB16_SourceAlpha noAlpha;
|
---|
1112 | qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl,
|
---|
1113 | reinterpret_cast<const quint32 *>(srcPixels), sbpl,
|
---|
1114 | targetRect, sourceRect, clip, targetRectTransform, noAlpha);
|
---|
1115 | } else {
|
---|
1116 | Blend_ARGB32_on_RGB16_SourceAndConstAlpha constAlpha(const_alpha);
|
---|
1117 | qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl,
|
---|
1118 | reinterpret_cast<const quint32 *>(srcPixels), sbpl,
|
---|
1119 | targetRect, sourceRect, clip, targetRectTransform, constAlpha);
|
---|
1120 | }
|
---|
1121 | }
|
---|
1122 |
|
---|
1123 |
|
---|
1124 | void qt_transform_image_rgb32_on_rgb32(uchar *destPixels, int dbpl,
|
---|
1125 | const uchar *srcPixels, int sbpl,
|
---|
1126 | const QRectF &targetRect,
|
---|
1127 | const QRectF &sourceRect,
|
---|
1128 | const QRect &clip,
|
---|
1129 | const QTransform &targetRectTransform,
|
---|
1130 | int const_alpha)
|
---|
1131 | {
|
---|
1132 | if (const_alpha == 256) {
|
---|
1133 | Blend_RGB32_on_RGB32_NoAlpha noAlpha;
|
---|
1134 | qt_transform_image(reinterpret_cast<quint32 *>(destPixels), dbpl,
|
---|
1135 | reinterpret_cast<const quint32 *>(srcPixels), sbpl,
|
---|
1136 | targetRect, sourceRect, clip, targetRectTransform, noAlpha);
|
---|
1137 | } else {
|
---|
1138 | Blend_RGB32_on_RGB32_ConstAlpha constAlpha(const_alpha);
|
---|
1139 | qt_transform_image(reinterpret_cast<quint32 *>(destPixels), dbpl,
|
---|
1140 | reinterpret_cast<const quint32 *>(srcPixels), sbpl,
|
---|
1141 | targetRect, sourceRect, clip, targetRectTransform, constAlpha);
|
---|
1142 | }
|
---|
1143 | }
|
---|
1144 |
|
---|
1145 | void qt_transform_image_argb32_on_argb32(uchar *destPixels, int dbpl,
|
---|
1146 | const uchar *srcPixels, int sbpl,
|
---|
1147 | const QRectF &targetRect,
|
---|
1148 | const QRectF &sourceRect,
|
---|
1149 | const QRect &clip,
|
---|
1150 | const QTransform &targetRectTransform,
|
---|
1151 | int const_alpha)
|
---|
1152 | {
|
---|
1153 | if (const_alpha == 256) {
|
---|
1154 | Blend_ARGB32_on_ARGB32_SourceAlpha sourceAlpha;
|
---|
1155 | qt_transform_image(reinterpret_cast<quint32 *>(destPixels), dbpl,
|
---|
1156 | reinterpret_cast<const quint32 *>(srcPixels), sbpl,
|
---|
1157 | targetRect, sourceRect, clip, targetRectTransform, sourceAlpha);
|
---|
1158 | } else {
|
---|
1159 | Blend_ARGB32_on_ARGB32_SourceAndConstAlpha constAlpha(const_alpha);
|
---|
1160 | qt_transform_image(reinterpret_cast<quint32 *>(destPixels), dbpl,
|
---|
1161 | reinterpret_cast<const quint32 *>(srcPixels), sbpl,
|
---|
1162 | targetRect, sourceRect, clip, targetRectTransform, constAlpha);
|
---|
1163 | }
|
---|
1164 | }
|
---|
1165 |
|
---|
1166 | SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = {
|
---|
1167 | { // Format_Invalid
|
---|
1168 | 0, // Format_Invalid,
|
---|
1169 | 0, // Format_Mono,
|
---|
1170 | 0, // Format_MonoLSB,
|
---|
1171 | 0, // Format_Indexed8,
|
---|
1172 | 0, // Format_RGB32,
|
---|
1173 | 0, // Format_ARGB32,
|
---|
1174 | 0, // Format_ARGB32_Premultiplied,
|
---|
1175 | 0, // Format_RGB16,
|
---|
1176 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1177 | 0, // Format_RGB666,
|
---|
1178 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1179 | 0, // Format_RGB555,
|
---|
1180 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1181 | 0, // Format_RGB888,
|
---|
1182 | 0, // Format_RGB444,
|
---|
1183 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1184 | },
|
---|
1185 | { // Format_Mono
|
---|
1186 | 0, // Format_Invalid,
|
---|
1187 | 0, // Format_Mono,
|
---|
1188 | 0, // Format_MonoLSB,
|
---|
1189 | 0, // Format_Indexed8,
|
---|
1190 | 0, // Format_RGB32,
|
---|
1191 | 0, // Format_ARGB32,
|
---|
1192 | 0, // Format_ARGB32_Premultiplied,
|
---|
1193 | 0, // Format_RGB16,
|
---|
1194 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1195 | 0, // Format_RGB666,
|
---|
1196 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1197 | 0, // Format_RGB555,
|
---|
1198 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1199 | 0, // Format_RGB888,
|
---|
1200 | 0, // Format_RGB444,
|
---|
1201 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1202 | },
|
---|
1203 | { // Format_MonoLSB
|
---|
1204 | 0, // Format_Invalid,
|
---|
1205 | 0, // Format_Mono,
|
---|
1206 | 0, // Format_MonoLSB,
|
---|
1207 | 0, // Format_Indexed8,
|
---|
1208 | 0, // Format_RGB32,
|
---|
1209 | 0, // Format_ARGB32,
|
---|
1210 | 0, // Format_ARGB32_Premultiplied,
|
---|
1211 | 0, // Format_RGB16,
|
---|
1212 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1213 | 0, // Format_RGB666,
|
---|
1214 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1215 | 0, // Format_RGB555,
|
---|
1216 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1217 | 0, // Format_RGB888,
|
---|
1218 | 0, // Format_RGB444,
|
---|
1219 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1220 | },
|
---|
1221 | { // Format_Indexed8
|
---|
1222 | 0, // Format_Invalid,
|
---|
1223 | 0, // Format_Mono,
|
---|
1224 | 0, // Format_MonoLSB,
|
---|
1225 | 0, // Format_Indexed8,
|
---|
1226 | 0, // Format_RGB32,
|
---|
1227 | 0, // Format_ARGB32,
|
---|
1228 | 0, // Format_ARGB32_Premultiplied,
|
---|
1229 | 0, // Format_RGB16,
|
---|
1230 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1231 | 0, // Format_RGB666,
|
---|
1232 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1233 | 0, // Format_RGB555,
|
---|
1234 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1235 | 0, // Format_RGB888,
|
---|
1236 | 0, // Format_RGB444,
|
---|
1237 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1238 | },
|
---|
1239 | { // Format_RGB32
|
---|
1240 | 0, // Format_Invalid,
|
---|
1241 | 0, // Format_Mono,
|
---|
1242 | 0, // Format_MonoLSB,
|
---|
1243 | 0, // Format_Indexed8,
|
---|
1244 | qt_scale_image_rgb32_on_rgb32, // Format_RGB32,
|
---|
1245 | 0, // Format_ARGB32,
|
---|
1246 | qt_scale_image_argb32_on_argb32, // Format_ARGB32_Premultiplied,
|
---|
1247 | 0, // Format_RGB16,
|
---|
1248 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1249 | 0, // Format_RGB666,
|
---|
1250 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1251 | 0, // Format_RGB555,
|
---|
1252 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1253 | 0, // Format_RGB888,
|
---|
1254 | 0, // Format_RGB444,
|
---|
1255 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1256 | },
|
---|
1257 | { // Format_ARGB32
|
---|
1258 | 0, // Format_Invalid,
|
---|
1259 | 0, // Format_Mono,
|
---|
1260 | 0, // Format_MonoLSB,
|
---|
1261 | 0, // Format_Indexed8,
|
---|
1262 | 0, // Format_RGB32,
|
---|
1263 | 0, // Format_ARGB32,
|
---|
1264 | 0, // Format_ARGB32_Premultiplied,
|
---|
1265 | 0, // Format_RGB16,
|
---|
1266 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1267 | 0, // Format_RGB666,
|
---|
1268 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1269 | 0, // Format_RGB555,
|
---|
1270 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1271 | 0, // Format_RGB888,
|
---|
1272 | 0, // Format_RGB444,
|
---|
1273 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1274 | },
|
---|
1275 | { // Format_ARGB32_Premultiplied
|
---|
1276 | 0, // Format_Invalid,
|
---|
1277 | 0, // Format_Mono,
|
---|
1278 | 0, // Format_MonoLSB,
|
---|
1279 | 0, // Format_Indexed8,
|
---|
1280 | qt_scale_image_rgb32_on_rgb32, // Format_RGB32,
|
---|
1281 | 0, // Format_ARGB32,
|
---|
1282 | qt_scale_image_argb32_on_argb32, // Format_ARGB32_Premultiplied,
|
---|
1283 | 0, // Format_RGB16,
|
---|
1284 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1285 | 0, // Format_RGB666,
|
---|
1286 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1287 | 0, // Format_RGB555,
|
---|
1288 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1289 | 0, // Format_RGB888,
|
---|
1290 | 0, // Format_RGB444,
|
---|
1291 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1292 | },
|
---|
1293 | { // Format_RGB16
|
---|
1294 | 0, // Format_Invalid,
|
---|
1295 | 0, // Format_Mono,
|
---|
1296 | 0, // Format_MonoLSB,
|
---|
1297 | 0, // Format_Indexed8,
|
---|
1298 | 0, // Format_RGB32,
|
---|
1299 | 0, // Format_ARGB32,
|
---|
1300 | qt_scale_image_argb32_on_rgb16, // Format_ARGB32_Premultiplied,
|
---|
1301 | qt_scale_image_rgb16_on_rgb16, // Format_RGB16,
|
---|
1302 | qt_scale_image_argb24_on_rgb16, // Format_ARGB8565_Premultiplied,
|
---|
1303 | 0, // Format_RGB666,
|
---|
1304 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1305 | 0, // Format_RGB555,
|
---|
1306 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1307 | 0, // Format_RGB888,
|
---|
1308 | 0, // Format_RGB444,
|
---|
1309 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1310 | },
|
---|
1311 | { // Format_ARGB8565_Premultiplied
|
---|
1312 | 0, // Format_Invalid,
|
---|
1313 | 0, // Format_Mono,
|
---|
1314 | 0, // Format_MonoLSB,
|
---|
1315 | 0, // Format_Indexed8,
|
---|
1316 | 0, // Format_RGB32,
|
---|
1317 | 0, // Format_ARGB32,
|
---|
1318 | 0, // Format_ARGB32_Premultiplied,
|
---|
1319 | 0, // Format_RGB16,
|
---|
1320 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1321 | 0, // Format_RGB666,
|
---|
1322 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1323 | 0, // Format_RGB555,
|
---|
1324 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1325 | 0, // Format_RGB888,
|
---|
1326 | 0, // Format_RGB444,
|
---|
1327 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1328 | },
|
---|
1329 | { // Format_RGB666
|
---|
1330 | 0, // Format_Invalid,
|
---|
1331 | 0, // Format_Mono,
|
---|
1332 | 0, // Format_MonoLSB,
|
---|
1333 | 0, // Format_Indexed8,
|
---|
1334 | 0, // Format_RGB32,
|
---|
1335 | 0, // Format_ARGB32,
|
---|
1336 | 0, // Format_ARGB32_Premultiplied,
|
---|
1337 | 0, // Format_RGB16,
|
---|
1338 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1339 | 0, // Format_RGB666,
|
---|
1340 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1341 | 0, // Format_RGB555,
|
---|
1342 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1343 | 0, // Format_RGB888,
|
---|
1344 | 0, // Format_RGB444,
|
---|
1345 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1346 | },
|
---|
1347 | { // Format_ARGB6666_Premultiplied
|
---|
1348 | 0, // Format_Invalid,
|
---|
1349 | 0, // Format_Mono,
|
---|
1350 | 0, // Format_MonoLSB,
|
---|
1351 | 0, // Format_Indexed8,
|
---|
1352 | 0, // Format_RGB32,
|
---|
1353 | 0, // Format_ARGB32,
|
---|
1354 | 0, // Format_ARGB32_Premultiplied,
|
---|
1355 | 0, // Format_RGB16,
|
---|
1356 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1357 | 0, // Format_RGB666,
|
---|
1358 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1359 | 0, // Format_RGB555,
|
---|
1360 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1361 | 0, // Format_RGB888,
|
---|
1362 | 0, // Format_RGB444,
|
---|
1363 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1364 | },
|
---|
1365 | { // Format_RGB555
|
---|
1366 | 0, // Format_Invalid,
|
---|
1367 | 0, // Format_Mono,
|
---|
1368 | 0, // Format_MonoLSB,
|
---|
1369 | 0, // Format_Indexed8,
|
---|
1370 | 0, // Format_RGB32,
|
---|
1371 | 0, // Format_ARGB32,
|
---|
1372 | 0, // Format_ARGB32_Premultiplied,
|
---|
1373 | 0, // Format_RGB16,
|
---|
1374 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1375 | 0, // Format_RGB666,
|
---|
1376 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1377 | 0, // Format_RGB555,
|
---|
1378 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1379 | 0, // Format_RGB888,
|
---|
1380 | 0, // Format_RGB444,
|
---|
1381 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1382 | },
|
---|
1383 | { // Format_ARGB8555_Premultiplied
|
---|
1384 | 0, // Format_Invalid,
|
---|
1385 | 0, // Format_Mono,
|
---|
1386 | 0, // Format_MonoLSB,
|
---|
1387 | 0, // Format_Indexed8,
|
---|
1388 | 0, // Format_RGB32,
|
---|
1389 | 0, // Format_ARGB32,
|
---|
1390 | 0, // Format_ARGB32_Premultiplied,
|
---|
1391 | 0, // Format_RGB16,
|
---|
1392 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1393 | 0, // Format_RGB666,
|
---|
1394 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1395 | 0, // Format_RGB555,
|
---|
1396 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1397 | 0, // Format_RGB888,
|
---|
1398 | 0, // Format_RGB444,
|
---|
1399 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1400 | },
|
---|
1401 | { // Format_RGB888
|
---|
1402 | 0, // Format_Invalid,
|
---|
1403 | 0, // Format_Mono,
|
---|
1404 | 0, // Format_MonoLSB,
|
---|
1405 | 0, // Format_Indexed8,
|
---|
1406 | 0, // Format_RGB32,
|
---|
1407 | 0, // Format_ARGB32,
|
---|
1408 | 0, // Format_ARGB32_Premultiplied,
|
---|
1409 | 0, // Format_RGB16,
|
---|
1410 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1411 | 0, // Format_RGB666,
|
---|
1412 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1413 | 0, // Format_RGB555,
|
---|
1414 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1415 | 0, // Format_RGB888,
|
---|
1416 | 0, // Format_RGB444,
|
---|
1417 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1418 | },
|
---|
1419 | { // Format_RGB444
|
---|
1420 | 0, // Format_Invalid,
|
---|
1421 | 0, // Format_Mono,
|
---|
1422 | 0, // Format_MonoLSB,
|
---|
1423 | 0, // Format_Indexed8,
|
---|
1424 | 0, // Format_RGB32,
|
---|
1425 | 0, // Format_ARGB32,
|
---|
1426 | 0, // Format_ARGB32_Premultiplied,
|
---|
1427 | 0, // Format_RGB16,
|
---|
1428 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1429 | 0, // Format_RGB666,
|
---|
1430 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1431 | 0, // Format_RGB555,
|
---|
1432 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1433 | 0, // Format_RGB888,
|
---|
1434 | 0, // Format_RGB444,
|
---|
1435 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1436 | },
|
---|
1437 | { // Format_ARGB4444_Premultiplied
|
---|
1438 | 0, // Format_Invalid,
|
---|
1439 | 0, // Format_Mono,
|
---|
1440 | 0, // Format_MonoLSB,
|
---|
1441 | 0, // Format_Indexed8,
|
---|
1442 | 0, // Format_RGB32,
|
---|
1443 | 0, // Format_ARGB32,
|
---|
1444 | 0, // Format_ARGB32_Premultiplied,
|
---|
1445 | 0, // Format_RGB16,
|
---|
1446 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1447 | 0, // Format_RGB666,
|
---|
1448 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1449 | 0, // Format_RGB555,
|
---|
1450 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1451 | 0, // Format_RGB888,
|
---|
1452 | 0, // Format_RGB444,
|
---|
1453 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1454 | }
|
---|
1455 | };
|
---|
1456 |
|
---|
1457 |
|
---|
1458 | SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = {
|
---|
1459 | { // Format_Invalid
|
---|
1460 | 0, // Format_Invalid,
|
---|
1461 | 0, // Format_Mono,
|
---|
1462 | 0, // Format_MonoLSB,
|
---|
1463 | 0, // Format_Indexed8,
|
---|
1464 | 0, // Format_RGB32,
|
---|
1465 | 0, // Format_ARGB32,
|
---|
1466 | 0, // Format_ARGB32_Premultiplied,
|
---|
1467 | 0, // Format_RGB16,
|
---|
1468 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1469 | 0, // Format_RGB666,
|
---|
1470 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1471 | 0, // Format_RGB555,
|
---|
1472 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1473 | 0, // Format_RGB888,
|
---|
1474 | 0, // Format_RGB444,
|
---|
1475 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1476 | },
|
---|
1477 | { // Format_Mono
|
---|
1478 | 0, // Format_Invalid,
|
---|
1479 | 0, // Format_Mono,
|
---|
1480 | 0, // Format_MonoLSB,
|
---|
1481 | 0, // Format_Indexed8,
|
---|
1482 | 0, // Format_RGB32,
|
---|
1483 | 0, // Format_ARGB32,
|
---|
1484 | 0, // Format_ARGB32_Premultiplied,
|
---|
1485 | 0, // Format_RGB16,
|
---|
1486 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1487 | 0, // Format_RGB666,
|
---|
1488 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1489 | 0, // Format_RGB555,
|
---|
1490 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1491 | 0, // Format_RGB888,
|
---|
1492 | 0, // Format_RGB444,
|
---|
1493 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1494 | },
|
---|
1495 | { // Format_MonoLSB
|
---|
1496 | 0, // Format_Invalid,
|
---|
1497 | 0, // Format_Mono,
|
---|
1498 | 0, // Format_MonoLSB,
|
---|
1499 | 0, // Format_Indexed8,
|
---|
1500 | 0, // Format_RGB32,
|
---|
1501 | 0, // Format_ARGB32,
|
---|
1502 | 0, // Format_ARGB32_Premultiplied,
|
---|
1503 | 0, // Format_RGB16,
|
---|
1504 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1505 | 0, // Format_RGB666,
|
---|
1506 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1507 | 0, // Format_RGB555,
|
---|
1508 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1509 | 0, // Format_RGB888,
|
---|
1510 | 0, // Format_RGB444,
|
---|
1511 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1512 | },
|
---|
1513 | { // Format_Indexed8
|
---|
1514 | 0, // Format_Invalid,
|
---|
1515 | 0, // Format_Mono,
|
---|
1516 | 0, // Format_MonoLSB,
|
---|
1517 | 0, // Format_Indexed8,
|
---|
1518 | 0, // Format_RGB32,
|
---|
1519 | 0, // Format_ARGB32,
|
---|
1520 | 0, // Format_ARGB32_Premultiplied,
|
---|
1521 | 0, // Format_RGB16,
|
---|
1522 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1523 | 0, // Format_RGB666,
|
---|
1524 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1525 | 0, // Format_RGB555,
|
---|
1526 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1527 | 0, // Format_RGB888,
|
---|
1528 | 0, // Format_RGB444,
|
---|
1529 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1530 | },
|
---|
1531 | { // Format_RGB32
|
---|
1532 | 0, // Format_Invalid,
|
---|
1533 | 0, // Format_Mono,
|
---|
1534 | 0, // Format_MonoLSB,
|
---|
1535 | 0, // Format_Indexed8,
|
---|
1536 | qt_blend_rgb32_on_rgb32, // Format_RGB32,
|
---|
1537 | 0, // Format_ARGB32,
|
---|
1538 | qt_blend_argb32_on_argb32, // Format_ARGB32_Premultiplied,
|
---|
1539 | 0, // Format_RGB16,
|
---|
1540 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1541 | 0, // Format_RGB666,
|
---|
1542 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1543 | 0, // Format_RGB555,
|
---|
1544 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1545 | 0, // Format_RGB888,
|
---|
1546 | 0, // Format_RGB444,
|
---|
1547 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1548 | },
|
---|
1549 | { // Format_ARGB32
|
---|
1550 | 0, // Format_Invalid,
|
---|
1551 | 0, // Format_Mono,
|
---|
1552 | 0, // Format_MonoLSB,
|
---|
1553 | 0, // Format_Indexed8,
|
---|
1554 | 0, // Format_RGB32,
|
---|
1555 | 0, // Format_ARGB32,
|
---|
1556 | 0, // Format_ARGB32_Premultiplied,
|
---|
1557 | 0, // Format_RGB16,
|
---|
1558 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1559 | 0, // Format_RGB666,
|
---|
1560 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1561 | 0, // Format_RGB555,
|
---|
1562 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1563 | 0, // Format_RGB888,
|
---|
1564 | 0, // Format_RGB444,
|
---|
1565 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1566 | },
|
---|
1567 | { // Format_ARGB32_Premultiplied
|
---|
1568 | 0, // Format_Invalid,
|
---|
1569 | 0, // Format_Mono,
|
---|
1570 | 0, // Format_MonoLSB,
|
---|
1571 | 0, // Format_Indexed8,
|
---|
1572 | qt_blend_rgb32_on_rgb32, // Format_RGB32,
|
---|
1573 | 0, // Format_ARGB32,
|
---|
1574 | qt_blend_argb32_on_argb32, // Format_ARGB32_Premultiplied,
|
---|
1575 | 0, // Format_RGB16,
|
---|
1576 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1577 | 0, // Format_RGB666,
|
---|
1578 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1579 | 0, // Format_RGB555,
|
---|
1580 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1581 | 0, // Format_RGB888,
|
---|
1582 | 0, // Format_RGB444,
|
---|
1583 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1584 | },
|
---|
1585 | { // Format_RGB16
|
---|
1586 | 0, // Format_Invalid,
|
---|
1587 | 0, // Format_Mono,
|
---|
1588 | 0, // Format_MonoLSB,
|
---|
1589 | 0, // Format_Indexed8,
|
---|
1590 | qt_blend_rgb32_on_rgb16, // Format_RGB32,
|
---|
1591 | 0, // Format_ARGB32,
|
---|
1592 | qt_blend_argb32_on_rgb16, // Format_ARGB32_Premultiplied,
|
---|
1593 | qt_blend_rgb16_on_rgb16, // Format_RGB16,
|
---|
1594 | qt_blend_argb24_on_rgb16, // Format_ARGB8565_Premultiplied,
|
---|
1595 | 0, // Format_RGB666,
|
---|
1596 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1597 | 0, // Format_RGB555,
|
---|
1598 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1599 | 0, // Format_RGB888,
|
---|
1600 | 0, // Format_RGB444,
|
---|
1601 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1602 | },
|
---|
1603 | { // Format_ARGB8565_Premultiplied
|
---|
1604 | 0, // Format_Invalid,
|
---|
1605 | 0, // Format_Mono,
|
---|
1606 | 0, // Format_MonoLSB,
|
---|
1607 | 0, // Format_Indexed8,
|
---|
1608 | 0, // Format_RGB32,
|
---|
1609 | 0, // Format_ARGB32,
|
---|
1610 | 0, // Format_ARGB32_Premultiplied,
|
---|
1611 | 0, // Format_RGB16,
|
---|
1612 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1613 | 0, // Format_RGB666,
|
---|
1614 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1615 | 0, // Format_RGB555,
|
---|
1616 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1617 | 0, // Format_RGB888,
|
---|
1618 | 0, // Format_RGB444,
|
---|
1619 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1620 | },
|
---|
1621 | { // Format_RGB666
|
---|
1622 | 0, // Format_Invalid,
|
---|
1623 | 0, // Format_Mono,
|
---|
1624 | 0, // Format_MonoLSB,
|
---|
1625 | 0, // Format_Indexed8,
|
---|
1626 | 0, // Format_RGB32,
|
---|
1627 | 0, // Format_ARGB32,
|
---|
1628 | 0, // Format_ARGB32_Premultiplied,
|
---|
1629 | 0, // Format_RGB16,
|
---|
1630 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1631 | 0, // Format_RGB666,
|
---|
1632 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1633 | 0, // Format_RGB555,
|
---|
1634 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1635 | 0, // Format_RGB888,
|
---|
1636 | 0, // Format_RGB444,
|
---|
1637 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1638 | },
|
---|
1639 | { // Format_ARGB6666_Premultiplied
|
---|
1640 | 0, // Format_Invalid,
|
---|
1641 | 0, // Format_Mono,
|
---|
1642 | 0, // Format_MonoLSB,
|
---|
1643 | 0, // Format_Indexed8,
|
---|
1644 | 0, // Format_RGB32,
|
---|
1645 | 0, // Format_ARGB32,
|
---|
1646 | 0, // Format_ARGB32_Premultiplied,
|
---|
1647 | 0, // Format_RGB16,
|
---|
1648 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1649 | 0, // Format_RGB666,
|
---|
1650 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1651 | 0, // Format_RGB555,
|
---|
1652 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1653 | 0, // Format_RGB888,
|
---|
1654 | 0, // Format_RGB444,
|
---|
1655 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1656 | },
|
---|
1657 | { // Format_RGB555
|
---|
1658 | 0, // Format_Invalid,
|
---|
1659 | 0, // Format_Mono,
|
---|
1660 | 0, // Format_MonoLSB,
|
---|
1661 | 0, // Format_Indexed8,
|
---|
1662 | 0, // Format_RGB32,
|
---|
1663 | 0, // Format_ARGB32,
|
---|
1664 | 0, // Format_ARGB32_Premultiplied,
|
---|
1665 | 0, // Format_RGB16,
|
---|
1666 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1667 | 0, // Format_RGB666,
|
---|
1668 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1669 | 0, // Format_RGB555,
|
---|
1670 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1671 | 0, // Format_RGB888,
|
---|
1672 | 0, // Format_RGB444,
|
---|
1673 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1674 | },
|
---|
1675 | { // Format_ARGB8555_Premultiplied
|
---|
1676 | 0, // Format_Invalid,
|
---|
1677 | 0, // Format_Mono,
|
---|
1678 | 0, // Format_MonoLSB,
|
---|
1679 | 0, // Format_Indexed8,
|
---|
1680 | 0, // Format_RGB32,
|
---|
1681 | 0, // Format_ARGB32,
|
---|
1682 | 0, // Format_ARGB32_Premultiplied,
|
---|
1683 | 0, // Format_RGB16,
|
---|
1684 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1685 | 0, // Format_RGB666,
|
---|
1686 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1687 | 0, // Format_RGB555,
|
---|
1688 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1689 | 0, // Format_RGB888,
|
---|
1690 | 0, // Format_RGB444,
|
---|
1691 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1692 | },
|
---|
1693 | { // Format_RGB888
|
---|
1694 | 0, // Format_Invalid,
|
---|
1695 | 0, // Format_Mono,
|
---|
1696 | 0, // Format_MonoLSB,
|
---|
1697 | 0, // Format_Indexed8,
|
---|
1698 | 0, // Format_RGB32,
|
---|
1699 | 0, // Format_ARGB32,
|
---|
1700 | 0, // Format_ARGB32_Premultiplied,
|
---|
1701 | 0, // Format_RGB16,
|
---|
1702 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1703 | 0, // Format_RGB666,
|
---|
1704 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1705 | 0, // Format_RGB555,
|
---|
1706 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1707 | 0, // Format_RGB888,
|
---|
1708 | 0, // Format_RGB444,
|
---|
1709 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1710 | },
|
---|
1711 | { // Format_RGB444
|
---|
1712 | 0, // Format_Invalid,
|
---|
1713 | 0, // Format_Mono,
|
---|
1714 | 0, // Format_MonoLSB,
|
---|
1715 | 0, // Format_Indexed8,
|
---|
1716 | 0, // Format_RGB32,
|
---|
1717 | 0, // Format_ARGB32,
|
---|
1718 | 0, // Format_ARGB32_Premultiplied,
|
---|
1719 | 0, // Format_RGB16,
|
---|
1720 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1721 | 0, // Format_RGB666,
|
---|
1722 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1723 | 0, // Format_RGB555,
|
---|
1724 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1725 | 0, // Format_RGB888,
|
---|
1726 | 0, // Format_RGB444,
|
---|
1727 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1728 | },
|
---|
1729 | { // Format_ARGB4444_Premultiplied
|
---|
1730 | 0, // Format_Invalid,
|
---|
1731 | 0, // Format_Mono,
|
---|
1732 | 0, // Format_MonoLSB,
|
---|
1733 | 0, // Format_Indexed8,
|
---|
1734 | 0, // Format_RGB32,
|
---|
1735 | 0, // Format_ARGB32,
|
---|
1736 | 0, // Format_ARGB32_Premultiplied,
|
---|
1737 | 0, // Format_RGB16,
|
---|
1738 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1739 | 0, // Format_RGB666,
|
---|
1740 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1741 | 0, // Format_RGB555,
|
---|
1742 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1743 | 0, // Format_RGB888,
|
---|
1744 | 0, // Format_RGB444,
|
---|
1745 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1746 | }
|
---|
1747 | };
|
---|
1748 |
|
---|
1749 | SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFormats] = {
|
---|
1750 | { // Format_Invalid
|
---|
1751 | 0, // Format_Invalid,
|
---|
1752 | 0, // Format_Mono,
|
---|
1753 | 0, // Format_MonoLSB,
|
---|
1754 | 0, // Format_Indexed8,
|
---|
1755 | 0, // Format_RGB32,
|
---|
1756 | 0, // Format_ARGB32,
|
---|
1757 | 0, // Format_ARGB32_Premultiplied,
|
---|
1758 | 0, // Format_RGB16,
|
---|
1759 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1760 | 0, // Format_RGB666,
|
---|
1761 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1762 | 0, // Format_RGB555,
|
---|
1763 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1764 | 0, // Format_RGB888,
|
---|
1765 | 0, // Format_RGB444,
|
---|
1766 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1767 | },
|
---|
1768 | { // Format_Mono
|
---|
1769 | 0, // Format_Invalid,
|
---|
1770 | 0, // Format_Mono,
|
---|
1771 | 0, // Format_MonoLSB,
|
---|
1772 | 0, // Format_Indexed8,
|
---|
1773 | 0, // Format_RGB32,
|
---|
1774 | 0, // Format_ARGB32,
|
---|
1775 | 0, // Format_ARGB32_Premultiplied,
|
---|
1776 | 0, // Format_RGB16,
|
---|
1777 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1778 | 0, // Format_RGB666,
|
---|
1779 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1780 | 0, // Format_RGB555,
|
---|
1781 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1782 | 0, // Format_RGB888,
|
---|
1783 | 0, // Format_RGB444,
|
---|
1784 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1785 | },
|
---|
1786 | { // Format_MonoLSB
|
---|
1787 | 0, // Format_Invalid,
|
---|
1788 | 0, // Format_Mono,
|
---|
1789 | 0, // Format_MonoLSB,
|
---|
1790 | 0, // Format_Indexed8,
|
---|
1791 | 0, // Format_RGB32,
|
---|
1792 | 0, // Format_ARGB32,
|
---|
1793 | 0, // Format_ARGB32_Premultiplied,
|
---|
1794 | 0, // Format_RGB16,
|
---|
1795 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1796 | 0, // Format_RGB666,
|
---|
1797 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1798 | 0, // Format_RGB555,
|
---|
1799 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1800 | 0, // Format_RGB888,
|
---|
1801 | 0, // Format_RGB444,
|
---|
1802 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1803 | },
|
---|
1804 | { // Format_Indexed8
|
---|
1805 | 0, // Format_Invalid,
|
---|
1806 | 0, // Format_Mono,
|
---|
1807 | 0, // Format_MonoLSB,
|
---|
1808 | 0, // Format_Indexed8,
|
---|
1809 | 0, // Format_RGB32,
|
---|
1810 | 0, // Format_ARGB32,
|
---|
1811 | 0, // Format_ARGB32_Premultiplied,
|
---|
1812 | 0, // Format_RGB16,
|
---|
1813 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1814 | 0, // Format_RGB666,
|
---|
1815 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1816 | 0, // Format_RGB555,
|
---|
1817 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1818 | 0, // Format_RGB888,
|
---|
1819 | 0, // Format_RGB444,
|
---|
1820 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1821 | },
|
---|
1822 | { // Format_RGB32
|
---|
1823 | 0, // Format_Invalid,
|
---|
1824 | 0, // Format_Mono,
|
---|
1825 | 0, // Format_MonoLSB,
|
---|
1826 | 0, // Format_Indexed8,
|
---|
1827 | qt_transform_image_rgb32_on_rgb32, // Format_RGB32,
|
---|
1828 | 0, // Format_ARGB32,
|
---|
1829 | qt_transform_image_argb32_on_argb32, // Format_ARGB32_Premultiplied,
|
---|
1830 | 0, // Format_RGB16,
|
---|
1831 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1832 | 0, // Format_RGB666,
|
---|
1833 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1834 | 0, // Format_RGB555,
|
---|
1835 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1836 | 0, // Format_RGB888,
|
---|
1837 | 0, // Format_RGB444,
|
---|
1838 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1839 | },
|
---|
1840 | { // Format_ARGB32
|
---|
1841 | 0, // Format_Invalid,
|
---|
1842 | 0, // Format_Mono,
|
---|
1843 | 0, // Format_MonoLSB,
|
---|
1844 | 0, // Format_Indexed8,
|
---|
1845 | 0, // Format_RGB32,
|
---|
1846 | 0, // Format_ARGB32,
|
---|
1847 | 0, // Format_ARGB32_Premultiplied,
|
---|
1848 | 0, // Format_RGB16,
|
---|
1849 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1850 | 0, // Format_RGB666,
|
---|
1851 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1852 | 0, // Format_RGB555,
|
---|
1853 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1854 | 0, // Format_RGB888,
|
---|
1855 | 0, // Format_RGB444,
|
---|
1856 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1857 | },
|
---|
1858 | { // Format_ARGB32_Premultiplied
|
---|
1859 | 0, // Format_Invalid,
|
---|
1860 | 0, // Format_Mono,
|
---|
1861 | 0, // Format_MonoLSB,
|
---|
1862 | 0, // Format_Indexed8,
|
---|
1863 | qt_transform_image_rgb32_on_rgb32, // Format_RGB32,
|
---|
1864 | 0, // Format_ARGB32,
|
---|
1865 | qt_transform_image_argb32_on_argb32, // Format_ARGB32_Premultiplied,
|
---|
1866 | 0, // Format_RGB16,
|
---|
1867 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1868 | 0, // Format_RGB666,
|
---|
1869 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1870 | 0, // Format_RGB555,
|
---|
1871 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1872 | 0, // Format_RGB888,
|
---|
1873 | 0, // Format_RGB444,
|
---|
1874 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1875 | },
|
---|
1876 | { // Format_RGB16
|
---|
1877 | 0, // Format_Invalid,
|
---|
1878 | 0, // Format_Mono,
|
---|
1879 | 0, // Format_MonoLSB,
|
---|
1880 | 0, // Format_Indexed8,
|
---|
1881 | 0, // Format_RGB32,
|
---|
1882 | 0, // Format_ARGB32,
|
---|
1883 | qt_transform_image_argb32_on_rgb16, // Format_ARGB32_Premultiplied,
|
---|
1884 | qt_transform_image_rgb16_on_rgb16, // Format_RGB16,
|
---|
1885 | qt_transform_image_argb24_on_rgb16, // Format_ARGB8565_Premultiplied,
|
---|
1886 | 0, // Format_RGB666,
|
---|
1887 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1888 | 0, // Format_RGB555,
|
---|
1889 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1890 | 0, // Format_RGB888,
|
---|
1891 | 0, // Format_RGB444,
|
---|
1892 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1893 | },
|
---|
1894 | { // Format_ARGB8565_Premultiplied
|
---|
1895 | 0, // Format_Invalid,
|
---|
1896 | 0, // Format_Mono,
|
---|
1897 | 0, // Format_MonoLSB,
|
---|
1898 | 0, // Format_Indexed8,
|
---|
1899 | 0, // Format_RGB32,
|
---|
1900 | 0, // Format_ARGB32,
|
---|
1901 | 0, // Format_ARGB32_Premultiplied,
|
---|
1902 | 0, // Format_RGB16,
|
---|
1903 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1904 | 0, // Format_RGB666,
|
---|
1905 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1906 | 0, // Format_RGB555,
|
---|
1907 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1908 | 0, // Format_RGB888,
|
---|
1909 | 0, // Format_RGB444,
|
---|
1910 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1911 | },
|
---|
1912 | { // Format_RGB666
|
---|
1913 | 0, // Format_Invalid,
|
---|
1914 | 0, // Format_Mono,
|
---|
1915 | 0, // Format_MonoLSB,
|
---|
1916 | 0, // Format_Indexed8,
|
---|
1917 | 0, // Format_RGB32,
|
---|
1918 | 0, // Format_ARGB32,
|
---|
1919 | 0, // Format_ARGB32_Premultiplied,
|
---|
1920 | 0, // Format_RGB16,
|
---|
1921 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1922 | 0, // Format_RGB666,
|
---|
1923 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1924 | 0, // Format_RGB555,
|
---|
1925 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1926 | 0, // Format_RGB888,
|
---|
1927 | 0, // Format_RGB444,
|
---|
1928 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1929 | },
|
---|
1930 | { // Format_ARGB6666_Premultiplied
|
---|
1931 | 0, // Format_Invalid,
|
---|
1932 | 0, // Format_Mono,
|
---|
1933 | 0, // Format_MonoLSB,
|
---|
1934 | 0, // Format_Indexed8,
|
---|
1935 | 0, // Format_RGB32,
|
---|
1936 | 0, // Format_ARGB32,
|
---|
1937 | 0, // Format_ARGB32_Premultiplied,
|
---|
1938 | 0, // Format_RGB16,
|
---|
1939 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1940 | 0, // Format_RGB666,
|
---|
1941 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1942 | 0, // Format_RGB555,
|
---|
1943 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1944 | 0, // Format_RGB888,
|
---|
1945 | 0, // Format_RGB444,
|
---|
1946 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1947 | },
|
---|
1948 | { // Format_RGB555
|
---|
1949 | 0, // Format_Invalid,
|
---|
1950 | 0, // Format_Mono,
|
---|
1951 | 0, // Format_MonoLSB,
|
---|
1952 | 0, // Format_Indexed8,
|
---|
1953 | 0, // Format_RGB32,
|
---|
1954 | 0, // Format_ARGB32,
|
---|
1955 | 0, // Format_ARGB32_Premultiplied,
|
---|
1956 | 0, // Format_RGB16,
|
---|
1957 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1958 | 0, // Format_RGB666,
|
---|
1959 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1960 | 0, // Format_RGB555,
|
---|
1961 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1962 | 0, // Format_RGB888,
|
---|
1963 | 0, // Format_RGB444,
|
---|
1964 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1965 | },
|
---|
1966 | { // Format_ARGB8555_Premultiplied
|
---|
1967 | 0, // Format_Invalid,
|
---|
1968 | 0, // Format_Mono,
|
---|
1969 | 0, // Format_MonoLSB,
|
---|
1970 | 0, // Format_Indexed8,
|
---|
1971 | 0, // Format_RGB32,
|
---|
1972 | 0, // Format_ARGB32,
|
---|
1973 | 0, // Format_ARGB32_Premultiplied,
|
---|
1974 | 0, // Format_RGB16,
|
---|
1975 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1976 | 0, // Format_RGB666,
|
---|
1977 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1978 | 0, // Format_RGB555,
|
---|
1979 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1980 | 0, // Format_RGB888,
|
---|
1981 | 0, // Format_RGB444,
|
---|
1982 | 0 // Format_ARGB4444_Premultiplied,
|
---|
1983 | },
|
---|
1984 | { // Format_RGB888
|
---|
1985 | 0, // Format_Invalid,
|
---|
1986 | 0, // Format_Mono,
|
---|
1987 | 0, // Format_MonoLSB,
|
---|
1988 | 0, // Format_Indexed8,
|
---|
1989 | 0, // Format_RGB32,
|
---|
1990 | 0, // Format_ARGB32,
|
---|
1991 | 0, // Format_ARGB32_Premultiplied,
|
---|
1992 | 0, // Format_RGB16,
|
---|
1993 | 0, // Format_ARGB8565_Premultiplied,
|
---|
1994 | 0, // Format_RGB666,
|
---|
1995 | 0, // Format_ARGB6666_Premultiplied,
|
---|
1996 | 0, // Format_RGB555,
|
---|
1997 | 0, // Format_ARGB8555_Premultiplied,
|
---|
1998 | 0, // Format_RGB888,
|
---|
1999 | 0, // Format_RGB444,
|
---|
2000 | 0 // Format_ARGB4444_Premultiplied,
|
---|
2001 | },
|
---|
2002 | { // Format_RGB444
|
---|
2003 | 0, // Format_Invalid,
|
---|
2004 | 0, // Format_Mono,
|
---|
2005 | 0, // Format_MonoLSB,
|
---|
2006 | 0, // Format_Indexed8,
|
---|
2007 | 0, // Format_RGB32,
|
---|
2008 | 0, // Format_ARGB32,
|
---|
2009 | 0, // Format_ARGB32_Premultiplied,
|
---|
2010 | 0, // Format_RGB16,
|
---|
2011 | 0, // Format_ARGB8565_Premultiplied,
|
---|
2012 | 0, // Format_RGB666,
|
---|
2013 | 0, // Format_ARGB6666_Premultiplied,
|
---|
2014 | 0, // Format_RGB555,
|
---|
2015 | 0, // Format_ARGB8555_Premultiplied,
|
---|
2016 | 0, // Format_RGB888,
|
---|
2017 | 0, // Format_RGB444,
|
---|
2018 | 0 // Format_ARGB4444_Premultiplied,
|
---|
2019 | },
|
---|
2020 | { // Format_ARGB4444_Premultiplied
|
---|
2021 | 0, // Format_Invalid,
|
---|
2022 | 0, // Format_Mono,
|
---|
2023 | 0, // Format_MonoLSB,
|
---|
2024 | 0, // Format_Indexed8,
|
---|
2025 | 0, // Format_RGB32,
|
---|
2026 | 0, // Format_ARGB32,
|
---|
2027 | 0, // Format_ARGB32_Premultiplied,
|
---|
2028 | 0, // Format_RGB16,
|
---|
2029 | 0, // Format_ARGB8565_Premultiplied,
|
---|
2030 | 0, // Format_RGB666,
|
---|
2031 | 0, // Format_ARGB6666_Premultiplied,
|
---|
2032 | 0, // Format_RGB555,
|
---|
2033 | 0, // Format_ARGB8555_Premultiplied,
|
---|
2034 | 0, // Format_RGB888,
|
---|
2035 | 0, // Format_RGB444,
|
---|
2036 | 0 // Format_ARGB4444_Premultiplied,
|
---|
2037 | }
|
---|
2038 | };
|
---|
2039 |
|
---|
2040 | QT_END_NAMESPACE
|
---|