diff options
author | Liang Qi <liang.qi@qt.io> | 2016-08-01 08:51:18 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-08-01 10:03:21 +0200 |
commit | 3cb7302480390e5149a9cf6f49ac1ca94ef63f97 (patch) | |
tree | 831134f1053214ab0d5ba4d406cf7b860ed7c578 /src/gui/image | |
parent | 2ff1557937c398a7fb5cc7ba120e7ca3b5eacd36 (diff) | |
parent | f24cc53cc27d8ed4be4c1d0d2df059dd6a6909a9 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
src/widgets/itemviews/qabstractitemview.cpp
src/widgets/itemviews/qabstractitemview_p.h
Change-Id: I54589b1365103cb1749186af92aab03a49c94b64
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qimage.cpp | 42 | ||||
-rw-r--r-- | src/gui/image/qpixmap.cpp | 6 |
2 files changed, 22 insertions, 26 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 64dafdddc3..de02e9a1dd 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -841,17 +841,6 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm d->cleanupFunction = cleanupFunction; d->cleanupInfo = cleanupInfo; - switch (format) { - case QImage::Format_Mono: - case QImage::Format_MonoLSB: - d->colortable.resize(2); - d->colortable[0] = QColor(Qt::black).rgba(); - d->colortable[1] = QColor(Qt::white).rgba(); - break; - default: - break; - } - return d; } @@ -2250,21 +2239,30 @@ QRgb QImage::pixel(int x, int y) const } const uchar *s = d->data + y * d->bytes_per_line; - switch(d->format) { + + int index = -1; + switch (d->format) { case Format_Mono: - return d->colortable.at((*(s + (x >> 3)) >> (~x & 7)) & 1); + index = (*(s + (x >> 3)) >> (~x & 7)) & 1; + break; case Format_MonoLSB: - return d->colortable.at((*(s + (x >> 3)) >> (x & 7)) & 1); + index = (*(s + (x >> 3)) >> (x & 7)) & 1; + break; case Format_Indexed8: - { - int index = (int)s[x]; - if (index < d->colortable.size()) { - return d->colortable.at(index); - } else { - qWarning("QImage::pixel: color table index %d out of range.", index); - return 0; - } + index = s[x]; + break; + default: + break; + } + if (index >= 0) { // Indexed format + if (index >= d->colortable.size()) { + qWarning("QImage::pixel: color table index %d out of range.", index); + return 0; } + return d->colortable.at(index); + } + + switch (d->format) { case Format_RGB32: return 0xff000000 | reinterpret_cast<const QRgb *>(s)[x]; case Format_ARGB32: // Keep old behaviour. diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 09d23c0084..59d6dc12c6 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1418,10 +1418,8 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) QPixmap using the fromImage(). If this is too expensive an operation, you can use QBitmap::fromImage() instead. - The QPixmap class also supports conversion to and from HICON: - the toWinHICON() function creates a HICON equivalent to the - QPixmap, and returns the HICON handle. The fromWinHICON() - function returns a QPixmap that is equivalent to the given icon. + To convert a QPixmap to and from HICON you can use the QtWinExtras + functions QtWin::toHICON() and QtWin::fromHICON() respectively. \section1 Pixmap Transformations |