Changeset 561 for trunk/tools/qvfb/qvfbview.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/tools/qvfb/qvfbview.cpp
r2 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the tools applications of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 90 90 QVFbView::QVFbView(int id, int w, int h, int d, Rotation r, QWidget *parent) 91 91 : QVFbAbstractView(parent), 92 viewdepth(d), viewFormat(DefaultFormat), r sh(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), 93 93 contentsWidth(w), contentsHeight(h), gred(1.0), ggreen(1.0), gblue(1.0), 94 94 gammatable(0), refreshRate(30), animation(0), … … 109 109 } 110 110 111 connect(mView, SIGNAL(displayDataChanged( const QRect &)),112 SLOT(refreshDisplay( const QRect &)));111 connect(mView, SIGNAL(displayDataChanged(QRect)), 112 SLOT(refreshDisplay(QRect))); 113 113 #ifdef Q_WS_X11 114 114 connect(mView, SIGNAL(displayEmbedRequested(WId)), … … 458 458 break; 459 459 } 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 460 521 case 4: { 461 522 if (requiredSize > buffer.size()) … … 536 597 QImage::Format_Indexed8); 537 598 img.setColorTable(mView->clut()); 538 if (img. numColors() <= 0)599 if (img.colorCount() <= 0) 539 600 img = QImage(); 540 601 break; 541 602 } 603 604 if (rgb_swapped) 605 img = img.rgbSwapped(); 542 606 543 607 if ( brightness != 255 ) { … … 550 614 img = img.convertToFormat(QImage::Format_RGB32); 551 615 552 // NOTE: calling bits() may change numBytes(), so do not616 // NOTE: calling bits() may change byteCount(), so do not 553 617 // pass them as parameters (which are evaluated right-to-left). 554 618 QRgb *b = (QRgb*)img.bits(); 555 int n = img. numBytes()/4;619 int n = img.byteCount()/4; 556 620 dim(b,n,brightness); 557 621 }
Note:
See TracChangeset
for help on using the changeset viewer.