summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qimage.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-04-03 01:00:11 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-04-03 01:00:11 +0200
commit682513bed4401fbc5f8fbaf52752565dbdb0fd03 (patch)
tree130a1eb852a1e596a76608193be86cd08bf3c57d /src/gui/image/qimage.cpp
parentb91e6f6f40864d54903d707d7f19a9732188b670 (diff)
parentf99fe9cee9d35e1fabbf45364631f4a7f049ebe3 (diff)
Merge remote-tracking branch 'origin/5.13' into dev
Diffstat (limited to 'src/gui/image/qimage.cpp')
-rw-r--r--src/gui/image/qimage.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index a6ac3bc333..8b2db6d346 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -1094,16 +1094,32 @@ void QImage::detach()
}
-static void copyMetadata(QImageData *dst, const QImageData *src)
+static void copyPhysicalMetadata(QImageData *dst, const QImageData *src)
{
- // Doesn't copy colortable and alpha_clut, or offset.
dst->dpmx = src->dpmx;
dst->dpmy = src->dpmy;
dst->devicePixelRatio = src->devicePixelRatio;
+}
+
+static void copyMetadata(QImageData *dst, const QImageData *src)
+{
+ // Doesn't copy colortable and alpha_clut, or offset.
+ copyPhysicalMetadata(dst, src);
dst->text = src->text;
dst->colorSpace = src->colorSpace;
}
+static void copyMetadata(QImage *dst, const QImage &src)
+{
+ dst->setDotsPerMeterX(src.dotsPerMeterX());
+ dst->setDotsPerMeterY(src.dotsPerMeterY());
+ dst->setDevicePixelRatio(src.devicePixelRatio());
+ const auto textKeys = src.textKeys();
+ for (const auto &key: textKeys)
+ dst->setText(key, src.text(key));
+
+}
+
/*!
\fn QImage QImage::copy(int x, int y, int width, int height) const
\overload
@@ -2955,8 +2971,10 @@ QImage QImage::createAlphaMask(Qt::ImageConversionFlags flags) const
}
QImage mask(d->width, d->height, Format_MonoLSB);
- if (!mask.isNull())
+ if (!mask.isNull()) {
dither_to_Mono(mask.d, d, flags, true);
+ copyPhysicalMetadata(mask.d, d);
+ }
return mask;
}
@@ -3074,6 +3092,7 @@ QImage QImage::createHeuristicMask(bool clipTight) const
#undef PIX
+ copyPhysicalMetadata(m.d, d);
return m;
}
#endif //QT_NO_IMAGE_HEURISTIC_MASK
@@ -3117,6 +3136,8 @@ QImage QImage::createMaskFromColor(QRgb color, Qt::MaskMode mode) const
}
if (mode == Qt::MaskOutColor)
maskImage.invertPixels();
+
+ copyPhysicalMetadata(maskImage.d, d);
return maskImage;
}
@@ -4688,8 +4709,7 @@ QImage QImage::smoothScaled(int w, int h) const {
static QImage rotated90(const QImage &image)
{
QImage out(image.height(), image.width(), image.format());
- out.setDotsPerMeterX(image.dotsPerMeterY());
- out.setDotsPerMeterY(image.dotsPerMeterX());
+ copyMetadata(&out, image);
if (image.colorCount() > 0)
out.setColorTable(image.colorTable());
int w = image.width();
@@ -4717,8 +4737,7 @@ static QImage rotated180(const QImage &image)
return image.mirrored(true, true);
QImage out(image.width(), image.height(), image.format());
- out.setDotsPerMeterX(image.dotsPerMeterY());
- out.setDotsPerMeterY(image.dotsPerMeterX());
+ copyMetadata(&out, image);
if (image.colorCount() > 0)
out.setColorTable(image.colorTable());
int w = image.width();
@@ -4730,8 +4749,7 @@ static QImage rotated180(const QImage &image)
static QImage rotated270(const QImage &image)
{
QImage out(image.height(), image.width(), image.format());
- out.setDotsPerMeterX(image.dotsPerMeterY());
- out.setDotsPerMeterY(image.dotsPerMeterX());
+ copyMetadata(&out, image);
if (image.colorCount() > 0)
out.setColorTable(image.colorTable());
int w = image.width();