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