Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/qvfb/qvfbview.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the tools applications of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    9090QVFbView::QVFbView(int id, int w, int h, int d, Rotation r, QWidget *parent)
    9191        : QVFbAbstractView(parent),
    92           viewdepth(d), viewFormat(DefaultFormat), rsh(0), gsh(0), bsh(0), rmax(15), gmax(15), bmax(15),
     92          viewdepth(d), viewFormat(DefaultFormat), rgb_swapped(0), rsh(0), gsh(0), bsh(0), rmax(15), gmax(15), bmax(15),
    9393        contentsWidth(w), contentsHeight(h), gred(1.0), ggreen(1.0), gblue(1.0),
    9494        gammatable(0), refreshRate(30), animation(0),
     
    109109    }
    110110
    111     connect(mView, SIGNAL(displayDataChanged(const QRect &)),
    112             SLOT(refreshDisplay(const QRect &)));
     111    connect(mView, SIGNAL(displayDataChanged(QRect)),
     112            SLOT(refreshDisplay(QRect)));
    113113#ifdef Q_WS_X11
    114114    connect(mView, SIGNAL(displayEmbedRequested(WId)),
     
    458458        break;
    459459    }
     460
     461    case 2: {
     462        if (requiredSize > buffer.size())
     463            buffer.resize(requiredSize);
     464
     465        // XXX: hw: replace by drawhelper functionality
     466
     467        const int pixelsPerByte = 4;
     468        quint8 *src = reinterpret_cast<quint8*>(mView->data())
     469                      + r.y() * mView->linestep() + r.x() / pixelsPerByte;
     470        const int align = qMin(r.width(), (4 - (r.x() & 3)) & 3);
     471        const int doAlign = (align > 0 ? 1 : 0);
     472        const int tail = qMin(r.width(), (r.width() - align) & 3);
     473        const int doTail = (tail > 0 ? 1 : 0);
     474        const int width8 = (r.width() - align) / pixelsPerByte;
     475        const int stride = mView->linestep() - (width8 + doAlign);
     476
     477        uchar *b = reinterpret_cast<uchar*>(buffer.data());
     478        img = QImage(b, r.width(), r.height(), QImage::Format_RGB32);
     479        for (int y = 0; y < r.height(); ++y) {
     480            quint32 *dest = reinterpret_cast<quint32*>(img.scanLine(y));
     481            quint8 c;
     482
     483            if (doAlign) {
     484                switch (align) {
     485                case 3: c = ((*src & 0x30) >> 4) * 0x55;
     486                        *dest++ = qRgb(c, c, c);
     487                case 2: c = ((*src & 0x0c) >> 2) * 0x55;
     488                        *dest++ = qRgb(c, c, c);
     489                case 1: c = ((*src & 0x03)) * 0x55;
     490                        *dest++ = qRgb(c, c, c);
     491                }
     492                ++src;
     493            }
     494            for (int i = 0; i < width8; ++i) {
     495                c = ((*src & 0xc0) >> 6) * 0x55;
     496                *dest++ = qRgb(c, c, c);
     497                c = ((*src & 0x30) >> 4) * 0x55;
     498                *dest++ = qRgb(c, c, c);
     499                c = ((*src & 0x0c) >> 2) * 0x55;
     500                *dest++ = qRgb(c, c, c);
     501                c = ((*src & 0x03)) * 0x55;
     502                *dest++ = qRgb(c, c, c);
     503
     504                ++src;
     505            }
     506            if (doTail) {
     507                switch (tail) {
     508                case 3: c = ((*src & 0x0c) >> 2) * 0x55;
     509                        dest[2] = qRgb(c, c, c);
     510                case 2: c = ((*src & 0x30) >> 4) * 0x55;
     511                        dest[1] = qRgb(c, c, c);
     512                case 1: c = ((*src & 0xc0) >> 6) * 0x55;
     513                        dest[0] = qRgb(c, c, c);
     514                }
     515            }
     516            src += stride;
     517        }
     518        break;
     519    }
     520
    460521    case 4: {
    461522        if (requiredSize > buffer.size())
     
    536597                   QImage::Format_Indexed8);
    537598        img.setColorTable(mView->clut());
    538         if (img.numColors() <= 0)
     599        if (img.colorCount() <= 0)
    539600            img = QImage();
    540601        break;
    541602    }
     603
     604    if (rgb_swapped)
     605        img = img.rgbSwapped();
    542606
    543607    if ( brightness != 255 ) {
     
    550614                img = img.convertToFormat(QImage::Format_RGB32);
    551615
    552             // NOTE: calling bits() may change numBytes(), so do not
     616            // NOTE: calling bits() may change byteCount(), so do not
    553617            // pass them as parameters (which are evaluated right-to-left).
    554618            QRgb *b = (QRgb*)img.bits();
    555             int n = img.numBytes()/4;
     619            int n = img.byteCount()/4;
    556620            dim(b,n,brightness);
    557621        }
Note: See TracChangeset for help on using the changeset viewer.