author | unc0rr |
Mon, 30 Nov 2015 23:43:19 +0300 | |
branch | qmlfrontend |
changeset 11440 | 28fb618d99c4 |
parent 10426 | 727a154cf784 |
permissions | -rw-r--r-- |
10420 | 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 |
||
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
19 |
void PreviewImageProvider::setPixmap(const QByteArray &px) |
10420 | 20 |
{ |
10426 | 21 |
QVector<QRgb> colorTable; |
22 |
colorTable.resize(256); |
|
23 |
for(int i = 0; i < 256; ++i) |
|
24 |
colorTable[i] = qRgba(255, 255, 0, i); |
|
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
25 |
|
10426 | 26 |
const quint8 *buf = (const quint8*) px.constData(); |
27 |
QImage im(buf, 256, 128, QImage::Format_Indexed8); |
|
28 |
im.setColorTable(colorTable); |
|
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
29 |
|
10426 | 30 |
m_px = QPixmap::fromImage(im, Qt::ColorOnly); |
31 |
//QPixmap pxres(px.size()); |
|
32 |
//QPainter p(&pxres); |
|
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
33 |
|
10426 | 34 |
//p.fillRect(pxres.rect(), linearGrad); |
35 |
//p.drawPixmap(0, 0, px); |
|
10420 | 36 |
} |