Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.9.5
-
None
-
-
ff6cf6764ded8c028f693da70b876a00fbff2a5f (qt/qtimageformats/5.15)
Description
When reading TIFF-Files QImage can create slightly incorrect images (RGB-Value #ffc4c4c4 instead of #ffc3c3c3).
When you load the attached TIF-File 'ORG.TIF' into Qt and write a TIF-File with QImage-Writer, the results are different between Qt4 and Qt5 ('OUT_QT5.9.5' vs. 'OUT_QT4.5.2').
As we matched our images in unit-tests with Qt4 which don't succeed with Qt5, we assume an error in Qt5.
Step by Step:
1. Export ORG.TIF with QImageWriter on Qt4: OUT_QT4.5.2.TIF
2. Compare ORG.TIF with OUT_QT4.5.2.TIF on Qt4: equal
3. Export ORG.TIF with QImageWriter on Qt5: OUT_QT5.9.5.TIF
4. Compare ORG.TIF with OUT_QT5.9.5.TIF on Qt5: equal
5. Compare ORG.TIF with OUT_QT4.5.2.TIF on Qt5: different
Code (for Qt4 and Qt5):
#include <qcoreapplication.h>
#include <qimage.h>
#include <qimagewriter.h>
#include <stdio.h>
bool imageWrite(QString const& fn_in, QString const fn_out) {
QImage img(fn_in);
QImageWriter iw(fn_out, "TIFF");
return iw.write(img);
}
QString imageCompare(QString const& fn_lhs, QString const& fn_rhs) {
QImage lhs(fn_lhs);
QImage rhs(fn_rhs);
int w = lhs.width();
int h = lhs.height();
if (w != rhs.width()) return "width different";
if (h != rhs.height()) return "height different";
for (int yy = 0; yy < h; ++yy) {
for (int xx = 0; xx < w; ++xx) {
QRgb rl = lhs.pixel(xx, yy);
QRgb rr = rhs.pixel(xx, yy);
if ((rl & RGB_MASK) != (rr & RGB_MASK)) {
return QString("Pixel x=%1, y=%2: #%3 different from #%4")
.arg(xx).arg(yy)
.arg(rl,8,16,QLatin1Char('0'))
.arg(rr,8,16,QLatin1Char('0'));
}
}
}
return QString();
}
int main(int argc, char* argv[]) {
QCoreApplication app(argc, argv);
QString fn_lhs = argc > 1
? argv[1]
: "ORG.TIF";
QString fn_rhs = argc > 2
? argv[2]
: QString("OUT_QT%1.TIF").arg(QT_VERSION_STR);
if (argc <= 2) {
if (!imageWrite(fn_lhs, fn_rhs)) return 1;
}
QString res = imageCompare(fn_lhs, fn_rhs);
QString msg = res.isEmpty()
? QString("'%1' equals '%2'").arg(fn_lhs, fn_rhs)
: QString("'%1' != '%2': %3").arg(fn_lhs, fn_rhs, res);
fputs(msg.toLatin1(), stderr);
return 0;
}