Make QRegion not need to be friends with QVector
[profile/ivi/qtbase.git] / src / gui / painting / qblendfunctions.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include <qmath.h>
43 #include "qblendfunctions_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 struct Blend_RGB16_on_RGB16_NoAlpha {
75     inline void write(quint16 *dst, quint16 src) { *dst = src; }
76
77     inline void flush(void *) {}
78 };
79
80 struct Blend_RGB16_on_RGB16_ConstAlpha {
81     inline Blend_RGB16_on_RGB16_ConstAlpha(quint32 alpha) {
82         m_alpha = (alpha * 255) >> 8;
83         m_ialpha = 255 - m_alpha;
84     }
85
86     inline void write(quint16 *dst, quint16 src) {
87         *dst = BYTE_MUL_RGB16(src, m_alpha) + BYTE_MUL_RGB16(*dst, m_ialpha);
88     }
89
90     inline void flush(void *) {}
91
92     quint32 m_alpha;
93     quint32 m_ialpha;
94 };
95
96 struct Blend_ARGB32_on_RGB16_SourceAlpha {
97     inline void write(quint16 *dst, quint32 src) {
98         const quint8 alpha = qAlpha(src);
99         if (alpha) {
100             quint16 s = qConvertRgb32To16(src);
101             if(alpha < 255)
102                 s += BYTE_MUL_RGB16(*dst, 255 - alpha);
103             *dst = s;
104         }
105     }
106
107     inline void flush(void *) {}
108 };
109
110 struct Blend_ARGB32_on_RGB16_SourceAndConstAlpha {
111     inline Blend_ARGB32_on_RGB16_SourceAndConstAlpha(quint32 alpha) {
112         m_alpha = (alpha * 255) >> 8;
113     }
114
115     inline void write(quint16 *dst, quint32 src) {
116         src = BYTE_MUL(src, m_alpha);
117         const quint8 alpha = qAlpha(src);
118         if(alpha) {
119             quint16 s = qConvertRgb32To16(src);
120             if(alpha < 255)
121                 s += BYTE_MUL_RGB16(*dst, 255 - alpha);
122             *dst = s;
123         }
124     }
125
126     inline void flush(void *) {}
127
128     quint32 m_alpha;
129 };
130
131 void qt_scale_image_rgb16_on_rgb16(uchar *destPixels, int dbpl,
132                                    const uchar *srcPixels, int sbpl,
133                                    const QRectF &targetRect,
134                                    const QRectF &sourceRect,
135                                    const QRect &clip,
136                                    int const_alpha)
137 {
138 #ifdef QT_DEBUG_DRAW
139     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",
140            destPixels, dbpl, srcPixels, sbpl,
141            targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
142            sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
143            const_alpha);
144 #endif
145     if (const_alpha == 256) {
146         Blend_RGB16_on_RGB16_NoAlpha noAlpha;
147         qt_scale_image_16bit<quint16>(destPixels, dbpl, srcPixels, sbpl,
148                                       targetRect, sourceRect, clip, noAlpha);
149     } else {
150         Blend_RGB16_on_RGB16_ConstAlpha constAlpha(const_alpha);
151         qt_scale_image_16bit<quint16>(destPixels, dbpl, srcPixels, sbpl,
152                                      targetRect, sourceRect, clip, constAlpha);
153     }
154 }
155
156 void qt_scale_image_argb32_on_rgb16(uchar *destPixels, int dbpl,
157                                     const uchar *srcPixels, int sbpl,
158                                     const QRectF &targetRect,
159                                     const QRectF &sourceRect,
160                                     const QRect &clip,
161                                     int const_alpha)
162 {
163 #ifdef QT_DEBUG_DRAW
164     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",
165            destPixels, dbpl, srcPixels, sbpl,
166            targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
167            sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
168            const_alpha);
169 #endif
170     if (const_alpha == 256) {
171         Blend_ARGB32_on_RGB16_SourceAlpha noAlpha;
172         qt_scale_image_16bit<quint32>(destPixels, dbpl, srcPixels, sbpl,
173                                       targetRect, sourceRect, clip, noAlpha);
174     } else {
175         Blend_ARGB32_on_RGB16_SourceAndConstAlpha constAlpha(const_alpha);
176         qt_scale_image_16bit<quint32>(destPixels, dbpl, srcPixels, sbpl,
177                                      targetRect, sourceRect, clip, constAlpha);
178     }
179 }
180
181 void qt_blend_rgb16_on_rgb16(uchar *dst, int dbpl,
182                              const uchar *src, int sbpl,
183                              int w, int h,
184                              int const_alpha)
185 {
186 #ifdef QT_DEBUG_DRAW
187     printf("qt_blend_rgb16_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
188            dst, dbpl, src, sbpl, w, h, const_alpha);
189 #endif
190
191     if (const_alpha == 256) {
192         if (w <= 64) {
193             while (h--) {
194                 QT_MEMCPY_USHORT(dst, src, w);
195                 dst += dbpl;
196                 src += sbpl;
197             }
198         } else {
199             int length = w << 1;
200             while (h--) {
201                 memcpy(dst, src, length);
202                 dst += dbpl;
203                 src += sbpl;
204             }
205         }
206     } else if (const_alpha != 0) {
207         quint16 *d = (quint16 *) dst;
208         const quint16 *s = (const quint16 *) src;
209         quint8 a = (255 * const_alpha) >> 8;
210         quint8 ia = 255 - a;
211         while (h--) {
212             for (int x=0; x<w; ++x) {
213                 d[x] = BYTE_MUL_RGB16(s[x], a) + BYTE_MUL_RGB16(d[x], ia);
214             }
215             d = (quint16 *)(((uchar *) d) + dbpl);
216             s = (const quint16 *)(((const uchar *) s) + sbpl);
217         }
218     }
219 }
220
221
222 void qt_blend_argb32_on_rgb16_const_alpha(uchar *destPixels, int dbpl,
223                                           const uchar *srcPixels, int sbpl,
224                                           int w, int h,
225                                           int const_alpha)
226 {
227     quint16 *dst = (quint16 *) destPixels;
228     const quint32 *src = (const quint32 *) srcPixels;
229
230     const_alpha = (const_alpha * 255) >> 8;
231     for (int y=0; y<h; ++y) {
232         for (int i = 0; i < w; ++i) {
233             uint s = src[i];
234             s = BYTE_MUL(s, const_alpha);
235             int alpha = qAlpha(s);
236             s = qConvertRgb32To16(s);
237             s += BYTE_MUL_RGB16(dst[i], 255 - alpha);
238             dst[i] = s;
239         }
240         dst = (quint16 *)(((uchar *) dst) + dbpl);
241         src = (const quint32 *)(((const uchar *) src) + sbpl);
242     }
243 }
244
245 static void qt_blend_argb32_on_rgb16(uchar *destPixels, int dbpl,
246                                      const uchar *srcPixels, int sbpl,
247                                      int w, int h,
248                                      int const_alpha)
249 {
250     if (const_alpha != 256) {
251         qt_blend_argb32_on_rgb16_const_alpha(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
252         return;
253     }
254
255     quint16 *dst = (quint16 *) destPixels;
256     quint32 *src = (quint32 *) srcPixels;
257
258     for (int y=0; y<h; ++y) {
259         for (int x=0; x<w; ++x) {
260
261             quint32 spix = src[x];
262             quint32 alpha = spix >> 24;
263
264             if (alpha == 255) {
265                 dst[x] = qConvertRgb32To16(spix);
266             } else if (alpha != 0) {
267                 quint32 dpix = dst[x];
268
269                 quint32 sia = 255 - alpha;
270
271                 quint32 sr = (spix >> 8) & 0xf800;
272                 quint32 sg = (spix >> 5) & 0x07e0;
273                 quint32 sb = (spix >> 3) & 0x001f;
274
275                 quint32 dr = (dpix & 0x0000f800);
276                 quint32 dg = (dpix & 0x000007e0);
277                 quint32 db = (dpix & 0x0000001f);
278
279                 quint32 siar = dr * sia;
280                 quint32 siag = dg * sia;
281                 quint32 siab = db * sia;
282
283                 quint32 rr = sr + ((siar + (siar>>8) + (0x80 << 8)) >> 8);
284                 quint32 rg = sg + ((siag + (siag>>8) + (0x80 << 3)) >> 8);
285                 quint32 rb = sb + ((siab + (siab>>8) + (0x80 >> 3)) >> 8);
286
287                 dst[x] = (rr & 0xf800)
288                          | (rg & 0x07e0)
289                          | (rb);
290             }
291         }
292         dst = (quint16 *) (((uchar *) dst) + dbpl);
293         src = (quint32 *) (((uchar *) src) + sbpl);
294     }
295 }
296
297
298 static void qt_blend_rgb32_on_rgb16(uchar *destPixels, int dbpl,
299                                     const uchar *srcPixels, int sbpl,
300                                     int w, int h,
301                                     int const_alpha)
302 {
303 #ifdef QT_DEBUG_DRAW
304     printf("qt_blend_rgb32_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
305            destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
306 #endif
307
308     if (const_alpha != 256) {
309         qt_blend_argb32_on_rgb16(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
310         return;
311     }
312
313     const quint32 *src = (const quint32 *) srcPixels;
314     int srcExtraStride = (sbpl >> 2) - w;
315
316     int dstJPL = dbpl / 2;
317
318     quint16 *dst = (quint16 *) destPixels;
319     quint16 *dstEnd = dst + dstJPL * h;
320
321     int dstExtraStride = dstJPL - w;
322
323     while (dst < dstEnd) {
324         const quint32 *srcEnd = src + w;
325         while (src < srcEnd) {
326             *dst = qConvertRgb32To16(*src);
327             ++dst;
328             ++src;
329         }
330         dst += dstExtraStride;
331         src += srcExtraStride;
332     }
333 }
334
335
336
337 /************************************************************************
338                        RGB32 (-888) format target format
339  ************************************************************************/
340
341 static void qt_blend_argb32_on_argb32(uchar *destPixels, int dbpl,
342                                       const uchar *srcPixels, int sbpl,
343                                       int w, int h,
344                                       int const_alpha)
345 {
346 #ifdef QT_DEBUG_DRAW
347     fprintf(stdout, "qt_blend_argb32_on_argb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
348             destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
349     fflush(stdout);
350 #endif
351
352     const uint *src = (const uint *) srcPixels;
353     uint *dst = (uint *) destPixels;
354     if (const_alpha == 256) {
355         for (int y=0; y<h; ++y) {
356             for (int x=0; x<w; ++x) {
357                 uint s = src[x];
358                 if (s >= 0xff000000)
359                     dst[x] = s;
360                 else if (s != 0)
361                     dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
362             }
363             dst = (quint32 *)(((uchar *) dst) + dbpl);
364             src = (const quint32 *)(((const uchar *) src) + sbpl);
365         }
366     } else if (const_alpha != 0) {
367         const_alpha = (const_alpha * 255) >> 8;
368         for (int y=0; y<h; ++y) {
369             for (int x=0; x<w; ++x) {
370                 uint s = BYTE_MUL(src[x], const_alpha);
371                 dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
372             }
373             dst = (quint32 *)(((uchar *) dst) + dbpl);
374             src = (const quint32 *)(((const uchar *) src) + sbpl);
375         }
376     }
377 }
378
379
380 void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl,
381                              const uchar *srcPixels, int sbpl,
382                              int w, int h,
383                              int const_alpha)
384 {
385 #ifdef QT_DEBUG_DRAW
386     fprintf(stdout, "qt_blend_rgb32_on_rgb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
387             destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
388     fflush(stdout);
389 #endif
390
391     if (const_alpha != 256) {
392         qt_blend_argb32_on_argb32(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
393         return;
394     }
395
396     const uint *src = (const uint *) srcPixels;
397     uint *dst = (uint *) destPixels;
398     int len = w * 4;
399     for (int y=0; y<h; ++y) {
400         memcpy(dst, src, len);
401         dst = (quint32 *)(((uchar *) dst) + dbpl);
402         src = (const quint32 *)(((const uchar *) src) + sbpl);
403     }
404 }
405
406
407
408 struct Blend_RGB32_on_RGB32_NoAlpha {
409     inline void write(quint32 *dst, quint32 src) { *dst = src; }
410
411     inline void flush(void *) {}
412 };
413
414 struct Blend_RGB32_on_RGB32_ConstAlpha {
415     inline Blend_RGB32_on_RGB32_ConstAlpha(quint32 alpha) {
416         m_alpha = (alpha * 255) >> 8;
417         m_ialpha = 255 - m_alpha;
418     }
419
420     inline void write(quint32 *dst, quint32 src) {
421         *dst = BYTE_MUL(src, m_alpha) + BYTE_MUL(*dst, m_ialpha);
422     }
423
424     inline void flush(void *) {}
425
426     quint32 m_alpha;
427     quint32 m_ialpha;
428 };
429
430 struct Blend_ARGB32_on_ARGB32_SourceAlpha {
431     inline void write(quint32 *dst, quint32 src) {
432         *dst = src + BYTE_MUL(*dst, qAlpha(~src));
433     }
434
435     inline void flush(void *) {}
436 };
437
438 struct Blend_ARGB32_on_ARGB32_SourceAndConstAlpha {
439     inline Blend_ARGB32_on_ARGB32_SourceAndConstAlpha(quint32 alpha) {
440         m_alpha = (alpha * 255) >> 8;
441         m_ialpha = 255 - m_alpha;
442     }
443
444     inline void write(quint32 *dst, quint32 src) {
445         src = BYTE_MUL(src, m_alpha);
446         *dst = src + BYTE_MUL(*dst, qAlpha(~src));
447     }
448
449     inline void flush(void *) {}
450
451     quint32 m_alpha;
452     quint32 m_ialpha;
453 };
454
455 void qt_scale_image_rgb32_on_rgb32(uchar *destPixels, int dbpl,
456                                    const uchar *srcPixels, int sbpl,
457                                    const QRectF &targetRect,
458                                    const QRectF &sourceRect,
459                                    const QRect &clip,
460                                    int const_alpha)
461 {
462 #ifdef QT_DEBUG_DRAW
463     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",
464            destPixels, dbpl, srcPixels, sbpl,
465            targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
466            sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
467            const_alpha);
468 #endif
469     if (const_alpha == 256) {
470         Blend_RGB32_on_RGB32_NoAlpha noAlpha;
471         qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl,
472                              targetRect, sourceRect, clip, noAlpha);
473     } else {
474         Blend_RGB32_on_RGB32_ConstAlpha constAlpha(const_alpha);
475         qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl,
476                              targetRect, sourceRect, clip, constAlpha);
477     }
478 }
479
480 void qt_scale_image_argb32_on_argb32(uchar *destPixels, int dbpl,
481                                      const uchar *srcPixels, int sbpl,
482                                      const QRectF &targetRect,
483                                      const QRectF &sourceRect,
484                                      const QRect &clip,
485                                      int const_alpha)
486 {
487 #ifdef QT_DEBUG_DRAW
488     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",
489            destPixels, dbpl, srcPixels, sbpl,
490            targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
491            sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
492            const_alpha);
493 #endif
494     if (const_alpha == 256) {
495         Blend_ARGB32_on_ARGB32_SourceAlpha sourceAlpha;
496         qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl,
497                              targetRect, sourceRect, clip, sourceAlpha);
498     } else {
499         Blend_ARGB32_on_ARGB32_SourceAndConstAlpha constAlpha(const_alpha);
500         qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl,
501                              targetRect, sourceRect, clip, constAlpha);
502     }
503 }
504
505 void qt_transform_image_rgb16_on_rgb16(uchar *destPixels, int dbpl,
506                                        const uchar *srcPixels, int sbpl,
507                                        const QRectF &targetRect,
508                                        const QRectF &sourceRect,
509                                        const QRect &clip,
510                                        const QTransform &targetRectTransform,
511                                        int const_alpha)
512 {
513     if (const_alpha == 256) {
514         Blend_RGB16_on_RGB16_NoAlpha noAlpha;
515         qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl,
516                            reinterpret_cast<const quint16 *>(srcPixels), sbpl,
517                            targetRect, sourceRect, clip, targetRectTransform, noAlpha);
518     } else {
519         Blend_RGB16_on_RGB16_ConstAlpha constAlpha(const_alpha);
520         qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl,
521                            reinterpret_cast<const quint16 *>(srcPixels), sbpl,
522                            targetRect, sourceRect, clip, targetRectTransform, constAlpha);
523     }
524 }
525
526 void qt_transform_image_argb32_on_rgb16(uchar *destPixels, int dbpl,
527                                         const uchar *srcPixels, int sbpl,
528                                         const QRectF &targetRect,
529                                         const QRectF &sourceRect,
530                                         const QRect &clip,
531                                         const QTransform &targetRectTransform,
532                                         int const_alpha)
533 {
534     if (const_alpha == 256) {
535         Blend_ARGB32_on_RGB16_SourceAlpha noAlpha;
536         qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl,
537                            reinterpret_cast<const quint32 *>(srcPixels), sbpl,
538                            targetRect, sourceRect, clip, targetRectTransform, noAlpha);
539     } else {
540         Blend_ARGB32_on_RGB16_SourceAndConstAlpha constAlpha(const_alpha);
541         qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl,
542                            reinterpret_cast<const quint32 *>(srcPixels), sbpl,
543                            targetRect, sourceRect, clip, targetRectTransform, constAlpha);
544     }
545 }
546
547
548 void qt_transform_image_rgb32_on_rgb32(uchar *destPixels, int dbpl,
549                                        const uchar *srcPixels, int sbpl,
550                                        const QRectF &targetRect,
551                                        const QRectF &sourceRect,
552                                        const QRect &clip,
553                                        const QTransform &targetRectTransform,
554                                        int const_alpha)
555 {
556     if (const_alpha == 256) {
557         Blend_RGB32_on_RGB32_NoAlpha noAlpha;
558         qt_transform_image(reinterpret_cast<quint32 *>(destPixels), dbpl,
559                            reinterpret_cast<const quint32 *>(srcPixels), sbpl,
560                            targetRect, sourceRect, clip, targetRectTransform, noAlpha);
561     } else {
562         Blend_RGB32_on_RGB32_ConstAlpha constAlpha(const_alpha);
563         qt_transform_image(reinterpret_cast<quint32 *>(destPixels), dbpl,
564                            reinterpret_cast<const quint32 *>(srcPixels), sbpl,
565                            targetRect, sourceRect, clip, targetRectTransform, constAlpha);
566     }
567 }
568
569 void qt_transform_image_argb32_on_argb32(uchar *destPixels, int dbpl,
570                                          const uchar *srcPixels, int sbpl,
571                                          const QRectF &targetRect,
572                                          const QRectF &sourceRect,
573                                          const QRect &clip,
574                                          const QTransform &targetRectTransform,
575                                          int const_alpha)
576 {
577     if (const_alpha == 256) {
578         Blend_ARGB32_on_ARGB32_SourceAlpha sourceAlpha;
579         qt_transform_image(reinterpret_cast<quint32 *>(destPixels), dbpl,
580                            reinterpret_cast<const quint32 *>(srcPixels), sbpl,
581                            targetRect, sourceRect, clip, targetRectTransform, sourceAlpha);
582     } else {
583         Blend_ARGB32_on_ARGB32_SourceAndConstAlpha constAlpha(const_alpha);
584         qt_transform_image(reinterpret_cast<quint32 *>(destPixels), dbpl,
585                            reinterpret_cast<const quint32 *>(srcPixels), sbpl,
586                            targetRect, sourceRect, clip, targetRectTransform, constAlpha);
587     }
588 }
589
590 SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = {
591     {   // Format_Invalid
592         0,      // Format_Invalid,
593         0,      // Format_Mono,
594         0,      // Format_MonoLSB,
595         0,      // Format_Indexed8,
596         0,      // Format_RGB32,
597         0,      // Format_ARGB32,
598         0,      // Format_ARGB32_Premultiplied,
599         0,      // Format_RGB16,
600         0,      // Format_ARGB8565_Premultiplied,
601         0,      // Format_RGB666,
602         0,      // Format_ARGB6666_Premultiplied,
603         0,      // Format_RGB555,
604         0,      // Format_ARGB8555_Premultiplied,
605         0,      // Format_RGB888,
606         0,      // Format_RGB444,
607         0       // Format_ARGB4444_Premultiplied,
608     },
609     {   // Format_Mono
610         0,      // Format_Invalid,
611         0,      // Format_Mono,
612         0,      // Format_MonoLSB,
613         0,      // Format_Indexed8,
614         0,      // Format_RGB32,
615         0,      // Format_ARGB32,
616         0,      // Format_ARGB32_Premultiplied,
617         0,      // Format_RGB16,
618         0,      // Format_ARGB8565_Premultiplied,
619         0,      // Format_RGB666,
620         0,      // Format_ARGB6666_Premultiplied,
621         0,      // Format_RGB555,
622         0,      // Format_ARGB8555_Premultiplied,
623         0,      // Format_RGB888,
624         0,      // Format_RGB444,
625         0       // Format_ARGB4444_Premultiplied,
626     },
627     {   // Format_MonoLSB
628         0,      // Format_Invalid,
629         0,      // Format_Mono,
630         0,      // Format_MonoLSB,
631         0,      // Format_Indexed8,
632         0,      // Format_RGB32,
633         0,      // Format_ARGB32,
634         0,      // Format_ARGB32_Premultiplied,
635         0,      // Format_RGB16,
636         0,      // Format_ARGB8565_Premultiplied,
637         0,      // Format_RGB666,
638         0,      // Format_ARGB6666_Premultiplied,
639         0,      // Format_RGB555,
640         0,      // Format_ARGB8555_Premultiplied,
641         0,      // Format_RGB888,
642         0,      // Format_RGB444,
643         0       // Format_ARGB4444_Premultiplied,
644     },
645     {   // Format_Indexed8
646         0,      // Format_Invalid,
647         0,      // Format_Mono,
648         0,      // Format_MonoLSB,
649         0,      // Format_Indexed8,
650         0,      // Format_RGB32,
651         0,      // Format_ARGB32,
652         0,      // Format_ARGB32_Premultiplied,
653         0,      // Format_RGB16,
654         0,      // Format_ARGB8565_Premultiplied,
655         0,      // Format_RGB666,
656         0,      // Format_ARGB6666_Premultiplied,
657         0,      // Format_RGB555,
658         0,      // Format_ARGB8555_Premultiplied,
659         0,      // Format_RGB888,
660         0,      // Format_RGB444,
661         0       // Format_ARGB4444_Premultiplied,
662     },
663     {   // Format_RGB32
664         0,      // Format_Invalid,
665         0,      // Format_Mono,
666         0,      // Format_MonoLSB,
667         0,      // Format_Indexed8,
668         qt_scale_image_rgb32_on_rgb32,      // Format_RGB32,
669         0,      // Format_ARGB32,
670         qt_scale_image_argb32_on_argb32,    // Format_ARGB32_Premultiplied,
671         0,      // Format_RGB16,
672         0,      // Format_ARGB8565_Premultiplied,
673         0,      // Format_RGB666,
674         0,      // Format_ARGB6666_Premultiplied,
675         0,      // Format_RGB555,
676         0,      // Format_ARGB8555_Premultiplied,
677         0,      // Format_RGB888,
678         0,      // Format_RGB444,
679         0       // Format_ARGB4444_Premultiplied,
680     },
681     {   // Format_ARGB32
682         0,      // Format_Invalid,
683         0,      // Format_Mono,
684         0,      // Format_MonoLSB,
685         0,      // Format_Indexed8,
686         0,      // Format_RGB32,
687         0,      // Format_ARGB32,
688         0,      // Format_ARGB32_Premultiplied,
689         0,      // Format_RGB16,
690         0,      // Format_ARGB8565_Premultiplied,
691         0,      // Format_RGB666,
692         0,      // Format_ARGB6666_Premultiplied,
693         0,      // Format_RGB555,
694         0,      // Format_ARGB8555_Premultiplied,
695         0,      // Format_RGB888,
696         0,      // Format_RGB444,
697         0       // Format_ARGB4444_Premultiplied,
698     },
699     {   // Format_ARGB32_Premultiplied
700         0,      // Format_Invalid,
701         0,      // Format_Mono,
702         0,      // Format_MonoLSB,
703         0,      // Format_Indexed8,
704         qt_scale_image_rgb32_on_rgb32,          // Format_RGB32,
705         0,      // Format_ARGB32,
706         qt_scale_image_argb32_on_argb32,        // Format_ARGB32_Premultiplied,
707         0,      // Format_RGB16,
708         0,      // Format_ARGB8565_Premultiplied,
709         0,      // Format_RGB666,
710         0,      // Format_ARGB6666_Premultiplied,
711         0,      // Format_RGB555,
712         0,      // Format_ARGB8555_Premultiplied,
713         0,      // Format_RGB888,
714         0,      // Format_RGB444,
715         0       // Format_ARGB4444_Premultiplied,
716     },
717     {   // Format_RGB16
718         0,      // Format_Invalid,
719         0,      // Format_Mono,
720         0,      // Format_MonoLSB,
721         0,      // Format_Indexed8,
722         0,      // Format_RGB32,
723         0,      // Format_ARGB32,
724         qt_scale_image_argb32_on_rgb16,       // Format_ARGB32_Premultiplied,
725         qt_scale_image_rgb16_on_rgb16,        // Format_RGB16,
726         0,      // Format_ARGB8565_Premultiplied,
727         0,      // Format_RGB666,
728         0,      // Format_ARGB6666_Premultiplied,
729         0,      // Format_RGB555,
730         0,      // Format_ARGB8555_Premultiplied,
731         0,      // Format_RGB888,
732         0,      // Format_RGB444,
733         0       // Format_ARGB4444_Premultiplied,
734     },
735     {   // Format_ARGB8565_Premultiplied
736         0,      // Format_Invalid,
737         0,      // Format_Mono,
738         0,      // Format_MonoLSB,
739         0,      // Format_Indexed8,
740         0,      // Format_RGB32,
741         0,      // Format_ARGB32,
742         0,      // Format_ARGB32_Premultiplied,
743         0,      // Format_RGB16,
744         0,      // Format_ARGB8565_Premultiplied,
745         0,      // Format_RGB666,
746         0,      // Format_ARGB6666_Premultiplied,
747         0,      // Format_RGB555,
748         0,      // Format_ARGB8555_Premultiplied,
749         0,      // Format_RGB888,
750         0,      // Format_RGB444,
751         0       // Format_ARGB4444_Premultiplied,
752     },
753     {   // Format_RGB666
754         0,      // Format_Invalid,
755         0,      // Format_Mono,
756         0,      // Format_MonoLSB,
757         0,      // Format_Indexed8,
758         0,      // Format_RGB32,
759         0,      // Format_ARGB32,
760         0,      // Format_ARGB32_Premultiplied,
761         0,      // Format_RGB16,
762         0,      // Format_ARGB8565_Premultiplied,
763         0,      // Format_RGB666,
764         0,      // Format_ARGB6666_Premultiplied,
765         0,      // Format_RGB555,
766         0,      // Format_ARGB8555_Premultiplied,
767         0,      // Format_RGB888,
768         0,      // Format_RGB444,
769         0       // Format_ARGB4444_Premultiplied,
770     },
771     {   // Format_ARGB6666_Premultiplied
772         0,      // Format_Invalid,
773         0,      // Format_Mono,
774         0,      // Format_MonoLSB,
775         0,      // Format_Indexed8,
776         0,      // Format_RGB32,
777         0,      // Format_ARGB32,
778         0,      // Format_ARGB32_Premultiplied,
779         0,      // Format_RGB16,
780         0,      // Format_ARGB8565_Premultiplied,
781         0,      // Format_RGB666,
782         0,      // Format_ARGB6666_Premultiplied,
783         0,      // Format_RGB555,
784         0,      // Format_ARGB8555_Premultiplied,
785         0,      // Format_RGB888,
786         0,      // Format_RGB444,
787         0       // Format_ARGB4444_Premultiplied,
788     },
789     {   // Format_RGB555
790         0,      // Format_Invalid,
791         0,      // Format_Mono,
792         0,      // Format_MonoLSB,
793         0,      // Format_Indexed8,
794         0,      // Format_RGB32,
795         0,      // Format_ARGB32,
796         0,      // Format_ARGB32_Premultiplied,
797         0,      // Format_RGB16,
798         0,      // Format_ARGB8565_Premultiplied,
799         0,      // Format_RGB666,
800         0,      // Format_ARGB6666_Premultiplied,
801         0,      // Format_RGB555,
802         0,      // Format_ARGB8555_Premultiplied,
803         0,      // Format_RGB888,
804         0,      // Format_RGB444,
805         0       // Format_ARGB4444_Premultiplied,
806     },
807     {   // Format_ARGB8555_Premultiplied
808         0,      // Format_Invalid,
809         0,      // Format_Mono,
810         0,      // Format_MonoLSB,
811         0,      // Format_Indexed8,
812         0,      // Format_RGB32,
813         0,      // Format_ARGB32,
814         0,      // Format_ARGB32_Premultiplied,
815         0,      // Format_RGB16,
816         0,      // Format_ARGB8565_Premultiplied,
817         0,      // Format_RGB666,
818         0,      // Format_ARGB6666_Premultiplied,
819         0,      // Format_RGB555,
820         0,      // Format_ARGB8555_Premultiplied,
821         0,      // Format_RGB888,
822         0,      // Format_RGB444,
823         0       // Format_ARGB4444_Premultiplied,
824     },
825     {   // Format_RGB888
826         0,      // Format_Invalid,
827         0,      // Format_Mono,
828         0,      // Format_MonoLSB,
829         0,      // Format_Indexed8,
830         0,      // Format_RGB32,
831         0,      // Format_ARGB32,
832         0,      // Format_ARGB32_Premultiplied,
833         0,      // Format_RGB16,
834         0,      // Format_ARGB8565_Premultiplied,
835         0,      // Format_RGB666,
836         0,      // Format_ARGB6666_Premultiplied,
837         0,      // Format_RGB555,
838         0,      // Format_ARGB8555_Premultiplied,
839         0,      // Format_RGB888,
840         0,      // Format_RGB444,
841         0       // Format_ARGB4444_Premultiplied,
842     },
843     {   // Format_RGB444
844         0,      // Format_Invalid,
845         0,      // Format_Mono,
846         0,      // Format_MonoLSB,
847         0,      // Format_Indexed8,
848         0,      // Format_RGB32,
849         0,      // Format_ARGB32,
850         0,      // Format_ARGB32_Premultiplied,
851         0,      // Format_RGB16,
852         0,      // Format_ARGB8565_Premultiplied,
853         0,      // Format_RGB666,
854         0,      // Format_ARGB6666_Premultiplied,
855         0,      // Format_RGB555,
856         0,      // Format_ARGB8555_Premultiplied,
857         0,      // Format_RGB888,
858         0,      // Format_RGB444,
859         0       // Format_ARGB4444_Premultiplied,
860     },
861     {   // Format_ARGB4444_Premultiplied
862         0,      // Format_Invalid,
863         0,      // Format_Mono,
864         0,      // Format_MonoLSB,
865         0,      // Format_Indexed8,
866         0,      // Format_RGB32,
867         0,      // Format_ARGB32,
868         0,      // Format_ARGB32_Premultiplied,
869         0,      // Format_RGB16,
870         0,      // Format_ARGB8565_Premultiplied,
871         0,      // Format_RGB666,
872         0,      // Format_ARGB6666_Premultiplied,
873         0,      // Format_RGB555,
874         0,      // Format_ARGB8555_Premultiplied,
875         0,      // Format_RGB888,
876         0,      // Format_RGB444,
877         0       // Format_ARGB4444_Premultiplied,
878     }
879 };
880
881
882 SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = {
883     {   // Format_Invalid
884         0,      // Format_Invalid,
885         0,      // Format_Mono,
886         0,      // Format_MonoLSB,
887         0,      // Format_Indexed8,
888         0,      // Format_RGB32,
889         0,      // Format_ARGB32,
890         0,      // Format_ARGB32_Premultiplied,
891         0,      // Format_RGB16,
892         0,      // Format_ARGB8565_Premultiplied,
893         0,      // Format_RGB666,
894         0,      // Format_ARGB6666_Premultiplied,
895         0,      // Format_RGB555,
896         0,      // Format_ARGB8555_Premultiplied,
897         0,      // Format_RGB888,
898         0,      // Format_RGB444,
899         0       // Format_ARGB4444_Premultiplied,
900     },
901     {   // Format_Mono
902         0,      // Format_Invalid,
903         0,      // Format_Mono,
904         0,      // Format_MonoLSB,
905         0,      // Format_Indexed8,
906         0,      // Format_RGB32,
907         0,      // Format_ARGB32,
908         0,      // Format_ARGB32_Premultiplied,
909         0,      // Format_RGB16,
910         0,      // Format_ARGB8565_Premultiplied,
911         0,      // Format_RGB666,
912         0,      // Format_ARGB6666_Premultiplied,
913         0,      // Format_RGB555,
914         0,      // Format_ARGB8555_Premultiplied,
915         0,      // Format_RGB888,
916         0,      // Format_RGB444,
917         0       // Format_ARGB4444_Premultiplied,
918     },
919     {   // Format_MonoLSB
920         0,      // Format_Invalid,
921         0,      // Format_Mono,
922         0,      // Format_MonoLSB,
923         0,      // Format_Indexed8,
924         0,      // Format_RGB32,
925         0,      // Format_ARGB32,
926         0,      // Format_ARGB32_Premultiplied,
927         0,      // Format_RGB16,
928         0,      // Format_ARGB8565_Premultiplied,
929         0,      // Format_RGB666,
930         0,      // Format_ARGB6666_Premultiplied,
931         0,      // Format_RGB555,
932         0,      // Format_ARGB8555_Premultiplied,
933         0,      // Format_RGB888,
934         0,      // Format_RGB444,
935         0       // Format_ARGB4444_Premultiplied,
936     },
937     {   // Format_Indexed8
938         0,      // Format_Invalid,
939         0,      // Format_Mono,
940         0,      // Format_MonoLSB,
941         0,      // Format_Indexed8,
942         0,      // Format_RGB32,
943         0,      // Format_ARGB32,
944         0,      // Format_ARGB32_Premultiplied,
945         0,      // Format_RGB16,
946         0,      // Format_ARGB8565_Premultiplied,
947         0,      // Format_RGB666,
948         0,      // Format_ARGB6666_Premultiplied,
949         0,      // Format_RGB555,
950         0,      // Format_ARGB8555_Premultiplied,
951         0,      // Format_RGB888,
952         0,      // Format_RGB444,
953         0       // Format_ARGB4444_Premultiplied,
954     },
955     {   // Format_RGB32
956         0,      // Format_Invalid,
957         0,      // Format_Mono,
958         0,      // Format_MonoLSB,
959         0,      // Format_Indexed8,
960         qt_blend_rgb32_on_rgb32,        // Format_RGB32,
961         0,      // Format_ARGB32,
962         qt_blend_argb32_on_argb32,      // Format_ARGB32_Premultiplied,
963         0,      // Format_RGB16,
964         0,      // Format_ARGB8565_Premultiplied,
965         0,      // Format_RGB666,
966         0,      // Format_ARGB6666_Premultiplied,
967         0,      // Format_RGB555,
968         0,      // Format_ARGB8555_Premultiplied,
969         0,      // Format_RGB888,
970         0,      // Format_RGB444,
971         0       // Format_ARGB4444_Premultiplied,
972     },
973     {   // Format_ARGB32
974         0,      // Format_Invalid,
975         0,      // Format_Mono,
976         0,      // Format_MonoLSB,
977         0,      // Format_Indexed8,
978         0,      // Format_RGB32,
979         0,      // Format_ARGB32,
980         0,      // Format_ARGB32_Premultiplied,
981         0,      // Format_RGB16,
982         0,      // Format_ARGB8565_Premultiplied,
983         0,      // Format_RGB666,
984         0,      // Format_ARGB6666_Premultiplied,
985         0,      // Format_RGB555,
986         0,      // Format_ARGB8555_Premultiplied,
987         0,      // Format_RGB888,
988         0,      // Format_RGB444,
989         0       // Format_ARGB4444_Premultiplied,
990     },
991     {   // Format_ARGB32_Premultiplied
992         0,      // Format_Invalid,
993         0,      // Format_Mono,
994         0,      // Format_MonoLSB,
995         0,      // Format_Indexed8,
996         qt_blend_rgb32_on_rgb32,        // Format_RGB32,
997         0,      // Format_ARGB32,
998         qt_blend_argb32_on_argb32,      // Format_ARGB32_Premultiplied,
999         0,      // Format_RGB16,
1000         0,      // Format_ARGB8565_Premultiplied,
1001         0,      // Format_RGB666,
1002         0,      // Format_ARGB6666_Premultiplied,
1003         0,      // Format_RGB555,
1004         0,      // Format_ARGB8555_Premultiplied,
1005         0,      // Format_RGB888,
1006         0,      // Format_RGB444,
1007         0       // Format_ARGB4444_Premultiplied,
1008     },
1009     {   // Format_RGB16
1010         0,      // Format_Invalid,
1011         0,      // Format_Mono,
1012         0,      // Format_MonoLSB,
1013         0,      // Format_Indexed8,
1014         qt_blend_rgb32_on_rgb16,  // Format_RGB32,
1015         0,      // Format_ARGB32,
1016         qt_blend_argb32_on_rgb16, // Format_ARGB32_Premultiplied,
1017         qt_blend_rgb16_on_rgb16,  // Format_RGB16,
1018         0,      // Format_ARGB8565_Premultiplied,
1019         0,      // Format_RGB666,
1020         0,      // Format_ARGB6666_Premultiplied,
1021         0,      // Format_RGB555,
1022         0,      // Format_ARGB8555_Premultiplied,
1023         0,      // Format_RGB888,
1024         0,      // Format_RGB444,
1025         0       // Format_ARGB4444_Premultiplied,
1026     },
1027     {   // Format_ARGB8565_Premultiplied
1028         0,      // Format_Invalid,
1029         0,      // Format_Mono,
1030         0,      // Format_MonoLSB,
1031         0,      // Format_Indexed8,
1032         0,      // Format_RGB32,
1033         0,      // Format_ARGB32,
1034         0,      // Format_ARGB32_Premultiplied,
1035         0,      // Format_RGB16,
1036         0,      // Format_ARGB8565_Premultiplied,
1037         0,      // Format_RGB666,
1038         0,      // Format_ARGB6666_Premultiplied,
1039         0,      // Format_RGB555,
1040         0,      // Format_ARGB8555_Premultiplied,
1041         0,      // Format_RGB888,
1042         0,      // Format_RGB444,
1043         0       // Format_ARGB4444_Premultiplied,
1044     },
1045     {   // Format_RGB666
1046         0,      // Format_Invalid,
1047         0,      // Format_Mono,
1048         0,      // Format_MonoLSB,
1049         0,      // Format_Indexed8,
1050         0,      // Format_RGB32,
1051         0,      // Format_ARGB32,
1052         0,      // Format_ARGB32_Premultiplied,
1053         0,      // Format_RGB16,
1054         0,      // Format_ARGB8565_Premultiplied,
1055         0,      // Format_RGB666,
1056         0,      // Format_ARGB6666_Premultiplied,
1057         0,      // Format_RGB555,
1058         0,      // Format_ARGB8555_Premultiplied,
1059         0,      // Format_RGB888,
1060         0,      // Format_RGB444,
1061         0       // Format_ARGB4444_Premultiplied,
1062     },
1063     {   // Format_ARGB6666_Premultiplied
1064         0,      // Format_Invalid,
1065         0,      // Format_Mono,
1066         0,      // Format_MonoLSB,
1067         0,      // Format_Indexed8,
1068         0,      // Format_RGB32,
1069         0,      // Format_ARGB32,
1070         0,      // Format_ARGB32_Premultiplied,
1071         0,      // Format_RGB16,
1072         0,      // Format_ARGB8565_Premultiplied,
1073         0,      // Format_RGB666,
1074         0,      // Format_ARGB6666_Premultiplied,
1075         0,      // Format_RGB555,
1076         0,      // Format_ARGB8555_Premultiplied,
1077         0,      // Format_RGB888,
1078         0,      // Format_RGB444,
1079         0       // Format_ARGB4444_Premultiplied,
1080     },
1081     {   // Format_RGB555
1082         0,      // Format_Invalid,
1083         0,      // Format_Mono,
1084         0,      // Format_MonoLSB,
1085         0,      // Format_Indexed8,
1086         0,      // Format_RGB32,
1087         0,      // Format_ARGB32,
1088         0,      // Format_ARGB32_Premultiplied,
1089         0,      // Format_RGB16,
1090         0,      // Format_ARGB8565_Premultiplied,
1091         0,      // Format_RGB666,
1092         0,      // Format_ARGB6666_Premultiplied,
1093         0,      // Format_RGB555,
1094         0,      // Format_ARGB8555_Premultiplied,
1095         0,      // Format_RGB888,
1096         0,      // Format_RGB444,
1097         0       // Format_ARGB4444_Premultiplied,
1098     },
1099     {   // Format_ARGB8555_Premultiplied
1100         0,      // Format_Invalid,
1101         0,      // Format_Mono,
1102         0,      // Format_MonoLSB,
1103         0,      // Format_Indexed8,
1104         0,      // Format_RGB32,
1105         0,      // Format_ARGB32,
1106         0,      // Format_ARGB32_Premultiplied,
1107         0,      // Format_RGB16,
1108         0,      // Format_ARGB8565_Premultiplied,
1109         0,      // Format_RGB666,
1110         0,      // Format_ARGB6666_Premultiplied,
1111         0,      // Format_RGB555,
1112         0,      // Format_ARGB8555_Premultiplied,
1113         0,      // Format_RGB888,
1114         0,      // Format_RGB444,
1115         0       // Format_ARGB4444_Premultiplied,
1116     },
1117     {   // Format_RGB888
1118         0,      // Format_Invalid,
1119         0,      // Format_Mono,
1120         0,      // Format_MonoLSB,
1121         0,      // Format_Indexed8,
1122         0,      // Format_RGB32,
1123         0,      // Format_ARGB32,
1124         0,      // Format_ARGB32_Premultiplied,
1125         0,      // Format_RGB16,
1126         0,      // Format_ARGB8565_Premultiplied,
1127         0,      // Format_RGB666,
1128         0,      // Format_ARGB6666_Premultiplied,
1129         0,      // Format_RGB555,
1130         0,      // Format_ARGB8555_Premultiplied,
1131         0,      // Format_RGB888,
1132         0,      // Format_RGB444,
1133         0       // Format_ARGB4444_Premultiplied,
1134     },
1135     {   // Format_RGB444
1136         0,      // Format_Invalid,
1137         0,      // Format_Mono,
1138         0,      // Format_MonoLSB,
1139         0,      // Format_Indexed8,
1140         0,      // Format_RGB32,
1141         0,      // Format_ARGB32,
1142         0,      // Format_ARGB32_Premultiplied,
1143         0,      // Format_RGB16,
1144         0,      // Format_ARGB8565_Premultiplied,
1145         0,      // Format_RGB666,
1146         0,      // Format_ARGB6666_Premultiplied,
1147         0,      // Format_RGB555,
1148         0,      // Format_ARGB8555_Premultiplied,
1149         0,      // Format_RGB888,
1150         0,      // Format_RGB444,
1151         0       // Format_ARGB4444_Premultiplied,
1152     },
1153     {   // Format_ARGB4444_Premultiplied
1154         0,      // Format_Invalid,
1155         0,      // Format_Mono,
1156         0,      // Format_MonoLSB,
1157         0,      // Format_Indexed8,
1158         0,      // Format_RGB32,
1159         0,      // Format_ARGB32,
1160         0,      // Format_ARGB32_Premultiplied,
1161         0,      // Format_RGB16,
1162         0,      // Format_ARGB8565_Premultiplied,
1163         0,      // Format_RGB666,
1164         0,      // Format_ARGB6666_Premultiplied,
1165         0,      // Format_RGB555,
1166         0,      // Format_ARGB8555_Premultiplied,
1167         0,      // Format_RGB888,
1168         0,      // Format_RGB444,
1169         0       // Format_ARGB4444_Premultiplied,
1170     }
1171 };
1172
1173 SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFormats] = {
1174     {   // Format_Invalid
1175         0,      // Format_Invalid,
1176         0,      // Format_Mono,
1177         0,      // Format_MonoLSB,
1178         0,      // Format_Indexed8,
1179         0,      // Format_RGB32,
1180         0,      // Format_ARGB32,
1181         0,      // Format_ARGB32_Premultiplied,
1182         0,      // Format_RGB16,
1183         0,      // Format_ARGB8565_Premultiplied,
1184         0,      // Format_RGB666,
1185         0,      // Format_ARGB6666_Premultiplied,
1186         0,      // Format_RGB555,
1187         0,      // Format_ARGB8555_Premultiplied,
1188         0,      // Format_RGB888,
1189         0,      // Format_RGB444,
1190         0       // Format_ARGB4444_Premultiplied,
1191     },
1192     {   // Format_Mono
1193         0,      // Format_Invalid,
1194         0,      // Format_Mono,
1195         0,      // Format_MonoLSB,
1196         0,      // Format_Indexed8,
1197         0,      // Format_RGB32,
1198         0,      // Format_ARGB32,
1199         0,      // Format_ARGB32_Premultiplied,
1200         0,      // Format_RGB16,
1201         0,      // Format_ARGB8565_Premultiplied,
1202         0,      // Format_RGB666,
1203         0,      // Format_ARGB6666_Premultiplied,
1204         0,      // Format_RGB555,
1205         0,      // Format_ARGB8555_Premultiplied,
1206         0,      // Format_RGB888,
1207         0,      // Format_RGB444,
1208         0       // Format_ARGB4444_Premultiplied,
1209     },
1210     {   // Format_MonoLSB
1211         0,      // Format_Invalid,
1212         0,      // Format_Mono,
1213         0,      // Format_MonoLSB,
1214         0,      // Format_Indexed8,
1215         0,      // Format_RGB32,
1216         0,      // Format_ARGB32,
1217         0,      // Format_ARGB32_Premultiplied,
1218         0,      // Format_RGB16,
1219         0,      // Format_ARGB8565_Premultiplied,
1220         0,      // Format_RGB666,
1221         0,      // Format_ARGB6666_Premultiplied,
1222         0,      // Format_RGB555,
1223         0,      // Format_ARGB8555_Premultiplied,
1224         0,      // Format_RGB888,
1225         0,      // Format_RGB444,
1226         0       // Format_ARGB4444_Premultiplied,
1227     },
1228     {   // Format_Indexed8
1229         0,      // Format_Invalid,
1230         0,      // Format_Mono,
1231         0,      // Format_MonoLSB,
1232         0,      // Format_Indexed8,
1233         0,      // Format_RGB32,
1234         0,      // Format_ARGB32,
1235         0,      // Format_ARGB32_Premultiplied,
1236         0,      // Format_RGB16,
1237         0,      // Format_ARGB8565_Premultiplied,
1238         0,      // Format_RGB666,
1239         0,      // Format_ARGB6666_Premultiplied,
1240         0,      // Format_RGB555,
1241         0,      // Format_ARGB8555_Premultiplied,
1242         0,      // Format_RGB888,
1243         0,      // Format_RGB444,
1244         0       // Format_ARGB4444_Premultiplied,
1245     },
1246     {   // Format_RGB32
1247         0,      // Format_Invalid,
1248         0,      // Format_Mono,
1249         0,      // Format_MonoLSB,
1250         0,      // Format_Indexed8,
1251         qt_transform_image_rgb32_on_rgb32,      // Format_RGB32,
1252         0,      // Format_ARGB32,
1253         qt_transform_image_argb32_on_argb32,    // Format_ARGB32_Premultiplied,
1254         0,      // Format_RGB16,
1255         0,      // Format_ARGB8565_Premultiplied,
1256         0,      // Format_RGB666,
1257         0,      // Format_ARGB6666_Premultiplied,
1258         0,      // Format_RGB555,
1259         0,      // Format_ARGB8555_Premultiplied,
1260         0,      // Format_RGB888,
1261         0,      // Format_RGB444,
1262         0       // Format_ARGB4444_Premultiplied,
1263     },
1264     {   // Format_ARGB32
1265         0,      // Format_Invalid,
1266         0,      // Format_Mono,
1267         0,      // Format_MonoLSB,
1268         0,      // Format_Indexed8,
1269         0,      // Format_RGB32,
1270         0,      // Format_ARGB32,
1271         0,      // Format_ARGB32_Premultiplied,
1272         0,      // Format_RGB16,
1273         0,      // Format_ARGB8565_Premultiplied,
1274         0,      // Format_RGB666,
1275         0,      // Format_ARGB6666_Premultiplied,
1276         0,      // Format_RGB555,
1277         0,      // Format_ARGB8555_Premultiplied,
1278         0,      // Format_RGB888,
1279         0,      // Format_RGB444,
1280         0       // Format_ARGB4444_Premultiplied,
1281     },
1282     {   // Format_ARGB32_Premultiplied
1283         0,      // Format_Invalid,
1284         0,      // Format_Mono,
1285         0,      // Format_MonoLSB,
1286         0,      // Format_Indexed8,
1287         qt_transform_image_rgb32_on_rgb32,          // Format_RGB32,
1288         0,      // Format_ARGB32,
1289         qt_transform_image_argb32_on_argb32,        // Format_ARGB32_Premultiplied,
1290         0,      // Format_RGB16,
1291         0,      // Format_ARGB8565_Premultiplied,
1292         0,      // Format_RGB666,
1293         0,      // Format_ARGB6666_Premultiplied,
1294         0,      // Format_RGB555,
1295         0,      // Format_ARGB8555_Premultiplied,
1296         0,      // Format_RGB888,
1297         0,      // Format_RGB444,
1298         0       // Format_ARGB4444_Premultiplied,
1299     },
1300     {   // Format_RGB16
1301         0,      // Format_Invalid,
1302         0,      // Format_Mono,
1303         0,      // Format_MonoLSB,
1304         0,      // Format_Indexed8,
1305         0,      // Format_RGB32,
1306         0,      // Format_ARGB32,
1307         qt_transform_image_argb32_on_rgb16,       // Format_ARGB32_Premultiplied,
1308         qt_transform_image_rgb16_on_rgb16,        // Format_RGB16,
1309         0,      // Format_ARGB8565_Premultiplied,
1310         0,      // Format_RGB666,
1311         0,      // Format_ARGB6666_Premultiplied,
1312         0,      // Format_RGB555,
1313         0,      // Format_ARGB8555_Premultiplied,
1314         0,      // Format_RGB888,
1315         0,      // Format_RGB444,
1316         0       // Format_ARGB4444_Premultiplied,
1317     },
1318     {   // Format_ARGB8565_Premultiplied
1319         0,      // Format_Invalid,
1320         0,      // Format_Mono,
1321         0,      // Format_MonoLSB,
1322         0,      // Format_Indexed8,
1323         0,      // Format_RGB32,
1324         0,      // Format_ARGB32,
1325         0,      // Format_ARGB32_Premultiplied,
1326         0,      // Format_RGB16,
1327         0,      // Format_ARGB8565_Premultiplied,
1328         0,      // Format_RGB666,
1329         0,      // Format_ARGB6666_Premultiplied,
1330         0,      // Format_RGB555,
1331         0,      // Format_ARGB8555_Premultiplied,
1332         0,      // Format_RGB888,
1333         0,      // Format_RGB444,
1334         0       // Format_ARGB4444_Premultiplied,
1335     },
1336     {   // Format_RGB666
1337         0,      // Format_Invalid,
1338         0,      // Format_Mono,
1339         0,      // Format_MonoLSB,
1340         0,      // Format_Indexed8,
1341         0,      // Format_RGB32,
1342         0,      // Format_ARGB32,
1343         0,      // Format_ARGB32_Premultiplied,
1344         0,      // Format_RGB16,
1345         0,      // Format_ARGB8565_Premultiplied,
1346         0,      // Format_RGB666,
1347         0,      // Format_ARGB6666_Premultiplied,
1348         0,      // Format_RGB555,
1349         0,      // Format_ARGB8555_Premultiplied,
1350         0,      // Format_RGB888,
1351         0,      // Format_RGB444,
1352         0       // Format_ARGB4444_Premultiplied,
1353     },
1354     {   // Format_ARGB6666_Premultiplied
1355         0,      // Format_Invalid,
1356         0,      // Format_Mono,
1357         0,      // Format_MonoLSB,
1358         0,      // Format_Indexed8,
1359         0,      // Format_RGB32,
1360         0,      // Format_ARGB32,
1361         0,      // Format_ARGB32_Premultiplied,
1362         0,      // Format_RGB16,
1363         0,      // Format_ARGB8565_Premultiplied,
1364         0,      // Format_RGB666,
1365         0,      // Format_ARGB6666_Premultiplied,
1366         0,      // Format_RGB555,
1367         0,      // Format_ARGB8555_Premultiplied,
1368         0,      // Format_RGB888,
1369         0,      // Format_RGB444,
1370         0       // Format_ARGB4444_Premultiplied,
1371     },
1372     {   // Format_RGB555
1373         0,      // Format_Invalid,
1374         0,      // Format_Mono,
1375         0,      // Format_MonoLSB,
1376         0,      // Format_Indexed8,
1377         0,      // Format_RGB32,
1378         0,      // Format_ARGB32,
1379         0,      // Format_ARGB32_Premultiplied,
1380         0,      // Format_RGB16,
1381         0,      // Format_ARGB8565_Premultiplied,
1382         0,      // Format_RGB666,
1383         0,      // Format_ARGB6666_Premultiplied,
1384         0,      // Format_RGB555,
1385         0,      // Format_ARGB8555_Premultiplied,
1386         0,      // Format_RGB888,
1387         0,      // Format_RGB444,
1388         0       // Format_ARGB4444_Premultiplied,
1389     },
1390     {   // Format_ARGB8555_Premultiplied
1391         0,      // Format_Invalid,
1392         0,      // Format_Mono,
1393         0,      // Format_MonoLSB,
1394         0,      // Format_Indexed8,
1395         0,      // Format_RGB32,
1396         0,      // Format_ARGB32,
1397         0,      // Format_ARGB32_Premultiplied,
1398         0,      // Format_RGB16,
1399         0,      // Format_ARGB8565_Premultiplied,
1400         0,      // Format_RGB666,
1401         0,      // Format_ARGB6666_Premultiplied,
1402         0,      // Format_RGB555,
1403         0,      // Format_ARGB8555_Premultiplied,
1404         0,      // Format_RGB888,
1405         0,      // Format_RGB444,
1406         0       // Format_ARGB4444_Premultiplied,
1407     },
1408     {   // Format_RGB888
1409         0,      // Format_Invalid,
1410         0,      // Format_Mono,
1411         0,      // Format_MonoLSB,
1412         0,      // Format_Indexed8,
1413         0,      // Format_RGB32,
1414         0,      // Format_ARGB32,
1415         0,      // Format_ARGB32_Premultiplied,
1416         0,      // Format_RGB16,
1417         0,      // Format_ARGB8565_Premultiplied,
1418         0,      // Format_RGB666,
1419         0,      // Format_ARGB6666_Premultiplied,
1420         0,      // Format_RGB555,
1421         0,      // Format_ARGB8555_Premultiplied,
1422         0,      // Format_RGB888,
1423         0,      // Format_RGB444,
1424         0       // Format_ARGB4444_Premultiplied,
1425     },
1426     {   // Format_RGB444
1427         0,      // Format_Invalid,
1428         0,      // Format_Mono,
1429         0,      // Format_MonoLSB,
1430         0,      // Format_Indexed8,
1431         0,      // Format_RGB32,
1432         0,      // Format_ARGB32,
1433         0,      // Format_ARGB32_Premultiplied,
1434         0,      // Format_RGB16,
1435         0,      // Format_ARGB8565_Premultiplied,
1436         0,      // Format_RGB666,
1437         0,      // Format_ARGB6666_Premultiplied,
1438         0,      // Format_RGB555,
1439         0,      // Format_ARGB8555_Premultiplied,
1440         0,      // Format_RGB888,
1441         0,      // Format_RGB444,
1442         0       // Format_ARGB4444_Premultiplied,
1443     },
1444     {   // Format_ARGB4444_Premultiplied
1445         0,      // Format_Invalid,
1446         0,      // Format_Mono,
1447         0,      // Format_MonoLSB,
1448         0,      // Format_Indexed8,
1449         0,      // Format_RGB32,
1450         0,      // Format_ARGB32,
1451         0,      // Format_ARGB32_Premultiplied,
1452         0,      // Format_RGB16,
1453         0,      // Format_ARGB8565_Premultiplied,
1454         0,      // Format_RGB666,
1455         0,      // Format_ARGB6666_Premultiplied,
1456         0,      // Format_RGB555,
1457         0,      // Format_ARGB8555_Premultiplied,
1458         0,      // Format_RGB888,
1459         0,      // Format_RGB444,
1460         0       // Format_ARGB4444_Premultiplied,
1461     }
1462 };
1463
1464 QT_END_NAMESPACE