summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qimage.cpp44
-rw-r--r--src/gui/image/qpixmap.cpp6
2 files changed, 24 insertions, 26 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 3abfac1575..bd32ca7bee 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -840,17 +840,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;
}
@@ -2249,21 +2238,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.
@@ -4250,6 +4248,8 @@ void QImage::setAlphaChannel(const QImage &alphaChannel)
} else {
const QImage sourceImage = alphaChannel.convertToFormat(QImage::Format_RGB32);
+ if (sourceImage.isNull())
+ return;
const uchar *src_data = sourceImage.d->data;
uchar *dest_data = d->data;
for (int y=0; y<h; ++y) {
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 4ab8160f21..a360debf5b 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -1410,10 +1410,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