tools/qvfb/qvfbview.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   106     case 1:
   106     case 1:
   107         mView = new QMMapViewProtocol(id, QSize(w, h), d, this);
   107         mView = new QMMapViewProtocol(id, QSize(w, h), d, this);
   108         break;
   108         break;
   109     }
   109     }
   110 
   110 
   111     connect(mView, SIGNAL(displayDataChanged(const QRect &)),
   111     connect(mView, SIGNAL(displayDataChanged(QRect)),
   112             SLOT(refreshDisplay(const QRect &)));
   112             SLOT(refreshDisplay(QRect)));
   113 #ifdef Q_WS_X11
   113 #ifdef Q_WS_X11
   114     connect(mView, SIGNAL(displayEmbedRequested(WId)),
   114     connect(mView, SIGNAL(displayEmbedRequested(WId)),
   115             this, SLOT(embedDisplay(WId)));
   115             this, SLOT(embedDisplay(WId)));
   116 #endif
   116 #endif
   117 
   117 
   594     case 8:
   594     case 8:
   595         img = QImage(mView->data() + r.y() * mView->linestep() + r.x(),
   595         img = QImage(mView->data() + r.y() * mView->linestep() + r.x(),
   596                    r.width(), r.height(), mView->linestep(),
   596                    r.width(), r.height(), mView->linestep(),
   597                    QImage::Format_Indexed8);
   597                    QImage::Format_Indexed8);
   598         img.setColorTable(mView->clut());
   598         img.setColorTable(mView->clut());
   599         if (img.numColors() <= 0)
   599         if (img.colorCount() <= 0)
   600             img = QImage();
   600             img = QImage();
   601         break;
   601         break;
   602     }
   602     }
   603 
   603 
   604     if (rgb_swapped)
   604     if (rgb_swapped)
   611             img.setColorTable(c);
   611             img.setColorTable(c);
   612         } else {
   612         } else {
   613             if ( img.format() != QImage::Format_ARGB32_Premultiplied )
   613             if ( img.format() != QImage::Format_ARGB32_Premultiplied )
   614                 img = img.convertToFormat(QImage::Format_RGB32);
   614                 img = img.convertToFormat(QImage::Format_RGB32);
   615 
   615 
   616             // NOTE: calling bits() may change numBytes(), so do not
   616             // NOTE: calling bits() may change byteCount(), so do not
   617             // pass them as parameters (which are evaluated right-to-left).
   617             // pass them as parameters (which are evaluated right-to-left).
   618             QRgb *b = (QRgb*)img.bits();
   618             QRgb *b = (QRgb*)img.bits();
   619             int n = img.numBytes()/4;
   619             int n = img.byteCount()/4;
   620             dim(b,n,brightness);
   620             dim(b,n,brightness);
   621         }
   621         }
   622     }
   622     }
   623 
   623 
   624     return img;
   624     return img;