summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qimage.cpp16
-rw-r--r--src/gui/image/qimagereader.cpp2
-rw-r--r--src/gui/image/qimagewriter.cpp1
-rw-r--r--src/gui/image/qpaintengine_pic.cpp2
-rw-r--r--src/gui/image/qpicture.cpp13
-rw-r--r--src/gui/image/qpixmap_raster.cpp8
-rw-r--r--src/gui/image/qpixmap_x11.cpp2
-rw-r--r--src/gui/image/qpixmapfilter.cpp2
8 files changed, 30 insertions, 16 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 94307de..85be5b1 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -118,8 +118,8 @@ const QVector<QRgb> *qt_image_colortable(const QImage &image)
return &image.d->colortable;
}
-extern int qt_defaultDpiX();
-extern int qt_defaultDpiY();
+Q_GUI_EXPORT extern int qt_defaultDpiX();
+Q_GUI_EXPORT extern int qt_defaultDpiY();
QBasicAtomicInt qimage_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1);
@@ -2988,19 +2988,19 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt:
colorTable.resize(256);
for (int i=0; i<256; ++i)
colorTable[i] = qRgb(i, i, i);
-
}
int w = src->width;
const uchar *src_data = src->data;
uchar *dest_data = dest->data;
+ int tableSize = colorTable.size() - 1;
for (int y = 0; y < src->height; y++) {
uint *p = (uint *)dest_data;
const uchar *b = src_data;
uint *end = p + w;
while (p < end)
- *p++ = colorTable.at(*b++);
+ *p++ = colorTable.at(qMin<int>(tableSize, *b++));
src_data += src->bytes_per_line;
dest_data += dest->bytes_per_line;
@@ -5704,9 +5704,13 @@ void QImage::setAlphaChannel(const QImage &alphaChannel)
return;
}
- detach();
+ if (d->format == QImage::Format_ARGB32_Premultiplied)
+ detach();
+ else
+ *this = convertToFormat(QImage::Format_ARGB32_Premultiplied);
- *this = convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ if (isNull())
+ return;
// Slight optimization since alphachannels are returned as 8-bit grays.
if (alphaChannel.d->depth == 8 && alphaChannel.isGrayscale()) {
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index 9320cfc..27f9627 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -503,7 +503,7 @@ QImageReaderPrivate::~QImageReaderPrivate()
bool QImageReaderPrivate::initHandler()
{
// check some preconditions
- if (!device || (!deleteDevice && !device->isOpen())) {
+ if (!device || (!deleteDevice && !device->isOpen() && !device->open(QIODevice::ReadOnly))) {
imageReaderError = QImageReader::DeviceError;
errorString = QLatin1String(QT_TRANSLATE_NOOP(QImageReader, "Invalid device"));
return false;
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
index a5f7b31..503a1b2 100644
--- a/src/gui/image/qimagewriter.cpp
+++ b/src/gui/image/qimagewriter.cpp
@@ -197,6 +197,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device,
for (int i = 0; i < keys.size(); ++i) {
QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i)));
if (plugin && (plugin->capabilities(device, testFormat) & QImageIOPlugin::CanWrite)) {
+ delete handler;
handler = plugin->create(device, testFormat);
break;
}
diff --git a/src/gui/image/qpaintengine_pic.cpp b/src/gui/image/qpaintengine_pic.cpp
index 029154b..fd1ee6a 100644
--- a/src/gui/image/qpaintengine_pic.cpp
+++ b/src/gui/image/qpaintengine_pic.cpp
@@ -477,7 +477,7 @@ void QPicturePaintEngine::drawImage(const QRectF &r, const QImage &image, const
writeCmdLength(pos, r, false);
}
-extern int qt_defaultDpi();
+Q_GUI_EXPORT extern int qt_defaultDpi();
void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti)
{
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index 3220a67..20a1dce 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -108,8 +108,8 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,
const char *qt_mfhdr_tag = "QPIC"; // header tag
static const quint16 mfhdr_maj = 11; // major version #
static const quint16 mfhdr_min = 0; // minor version #
-extern int qt_defaultDpiX();
-extern int qt_defaultDpiY();
+Q_GUI_EXPORT extern int qt_defaultDpiX();
+Q_GUI_EXPORT extern int qt_defaultDpiY();
/*!
Constructs an empty picture.
@@ -651,7 +651,12 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords)
s >> dbl;
QFont fnt(font, painter->device());
- qreal scale = painter->device()->logicalDpiY() / (dbl*qt_defaultDpiY());
+ // Fonts that specify a pixel size should not be scaled - QPicture already
+ // have a matrix set to compensate for the DPI differences between the
+ // default Qt DPI and the actual target device DPI, and we have to take that
+ // into consideration in the case where the font has a pixel size set.
+
+ qreal scale = fnt.pointSize() == -1 ? 1 : painter->device()->logicalDpiY() / (dbl*qt_defaultDpiY());
painter->save();
painter->scale(1/scale, 1/scale);
@@ -660,7 +665,7 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords)
int flags = Qt::TextSingleLine | Qt::TextDontClip | Qt::TextForceLeftToRight;
- QSizeF size(scale, scale);
+ QSizeF size(1, 1);
if (justificationWidth > 0) {
size.setWidth(justificationWidth*scale);
flags |= Qt::TextJustificationForced;
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index 0b1c18d..9dc15fc 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -182,6 +182,7 @@ void QRasterPixmapData::fromImage(const QImage &sourceImage,
QImage::Format opaqueFormat = QNativeImage::systemFormat();
QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied;
+#ifndef QT_HAVE_NEON
switch (opaqueFormat) {
case QImage::Format_RGB16:
alphaFormat = QImage::Format_ARGB8565_Premultiplied;
@@ -189,6 +190,7 @@ void QRasterPixmapData::fromImage(const QImage &sourceImage,
default: // We don't care about the others...
break;
}
+#endif
if (!sourceImage.hasAlphaChannel()
|| ((flags & Qt::NoOpaqueDetection) == 0
@@ -238,6 +240,7 @@ void QRasterPixmapData::fill(const QColor &color)
if (alpha != 255) {
if (!image.hasAlphaChannel()) {
QImage::Format toFormat;
+#ifndef QT_HAVE_NEON
if (image.format() == QImage::Format_RGB16)
toFormat = QImage::Format_ARGB8565_Premultiplied;
else if (image.format() == QImage::Format_RGB666)
@@ -247,6 +250,7 @@ void QRasterPixmapData::fill(const QColor &color)
else if (image.format() == QImage::Format_RGB444)
toFormat = QImage::Format_ARGB4444_Premultiplied;
else
+#endif
toFormat = QImage::Format_ARGB32_Premultiplied;
image = QImage(image.width(), image.height(), toFormat);
}
@@ -357,8 +361,8 @@ QPaintEngine* QRasterPixmapData::paintEngine() const
return image.paintEngine();
}
-extern int qt_defaultDpiX();
-extern int qt_defaultDpiY();
+Q_GUI_EXPORT extern int qt_defaultDpiX();
+Q_GUI_EXPORT extern int qt_defaultDpiY();
int QRasterPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
{
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp
index 5a882af..6bebefc 100644
--- a/src/gui/image/qpixmap_x11.cpp
+++ b/src/gui/image/qpixmap_x11.cpp
@@ -383,7 +383,7 @@ struct QX11AlphaDetector
return has;
// Will implicitly also check format and return quickly for opaque types...
checked = true;
- has = const_cast<QImage *>(image)->data_ptr()->checkForAlphaPixels();
+ has = image->isNull() ? false : const_cast<QImage *>(image)->data_ptr()->checkForAlphaPixels();
return has;
}
diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp
index 5355ad3..70770c4 100644
--- a/src/gui/image/qpixmapfilter.cpp
+++ b/src/gui/image/qpixmapfilter.cpp
@@ -898,7 +898,7 @@ Q_GUI_EXPORT void qt_blurImage(QImage &blurImage, qreal radius, bool quality, in
expblur<12, 10, false>(blurImage, radius, quality, transposed);
}
-bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
+Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
/*!
\internal