qmlFrontend/previewimageprovider.cpp
branchqmlfrontend
changeset 10426 727a154cf784
parent 10424 4be6cd55f1cf
equal deleted inserted replaced
10424:4be6cd55f1cf 10426:727a154cf784
    16     return m_px;
    16     return m_px;
    17 }
    17 }
    18 
    18 
    19 void PreviewImageProvider::setPixmap(const QByteArray &px)
    19 void PreviewImageProvider::setPixmap(const QByteArray &px)
    20 {
    20 {
    21     if(px.size() == 128 * 256)
    21     QVector<QRgb> colorTable;
    22     {
    22     colorTable.resize(256);
    23         QVector<QRgb> colorTable;
    23     for(int i = 0; i < 256; ++i)
    24         colorTable.resize(256);
    24         colorTable[i] = qRgba(255, 255, 0, i);
    25         for(int i = 0; i < 256; ++i)
       
    26             colorTable[i] = qRgba(255, 255, 0, i);
       
    27 
    25 
    28         const quint8 *buf = (const quint8*) px.constData();
    26     const quint8 *buf = (const quint8*) px.constData();
    29         QImage im(buf, 256, 128, QImage::Format_Indexed8);
    27     QImage im(buf, 256, 128, QImage::Format_Indexed8);
    30         im.setColorTable(colorTable);
    28     im.setColorTable(colorTable);
    31 
    29 
    32         m_px = QPixmap::fromImage(im, Qt::ColorOnly);
    30     m_px = QPixmap::fromImage(im, Qt::ColorOnly);
    33         //QPixmap pxres(px.size());
    31     //QPixmap pxres(px.size());
    34         //QPainter p(&pxres);
    32     //QPainter p(&pxres);
    35 
    33 
    36         //p.fillRect(pxres.rect(), linearGrad);
    34     //p.fillRect(pxres.rect(), linearGrad);
    37         //p.drawPixmap(0, 0, px);
    35     //p.drawPixmap(0, 0, px);
    38     }
       
    39 }
    36 }