equal
deleted
inserted
replaced
|
1 #include "previewimageprovider.h" |
|
2 |
|
3 PreviewImageProvider::PreviewImageProvider() |
|
4 : QQuickImageProvider(QQuickImageProvider::Pixmap) |
|
5 { |
|
6 } |
|
7 |
|
8 QPixmap PreviewImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) |
|
9 { |
|
10 Q_UNUSED(id); |
|
11 Q_UNUSED(requestedSize); |
|
12 |
|
13 if (size) |
|
14 *size = m_px.size(); |
|
15 |
|
16 return m_px; |
|
17 } |
|
18 |
|
19 void PreviewImageProvider::setPixmap(const QByteArray &px) |
|
20 { |
|
21 QVector<QRgb> colorTable; |
|
22 colorTable.resize(256); |
|
23 for(int i = 0; i < 256; ++i) |
|
24 colorTable[i] = qRgba(255, 255, 0, i); |
|
25 |
|
26 const quint8 *buf = (const quint8*) px.constData(); |
|
27 QImage im(buf, 256, 128, QImage::Format_Indexed8); |
|
28 im.setColorTable(colorTable); |
|
29 |
|
30 m_px = QPixmap::fromImage(im, Qt::ColorOnly); |
|
31 //QPixmap pxres(px.size()); |
|
32 //QPainter p(&pxres); |
|
33 |
|
34 //p.fillRect(pxres.rect(), linearGrad); |
|
35 //p.drawPixmap(0, 0, px); |
|
36 } |