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