mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-07-18 20:04:16 -04:00
JXL: added ImageTransformation option
Let Qt rotate the image when the ImageAutotransform option is set to true. In tests it also solves the image size control with the value returned by the options with certain rotations.
This commit is contained in:
committed by
Albert Astals Cid
parent
51921e8ee5
commit
219d9cb2c2
BIN
autotests/read/jxl/orientation6_notranfs.jxl
Normal file
BIN
autotests/read/jxl/orientation6_notranfs.jxl
Normal file
Binary file not shown.
19
autotests/read/jxl/orientation6_notranfs.jxl.json
Normal file
19
autotests/read/jxl/orientation6_notranfs.jxl.json
Normal file
@ -0,0 +1,19 @@
|
||||
[
|
||||
{
|
||||
"minQtVersion" : "6.5.7",
|
||||
"maxQtVersion" : "6.5.99",
|
||||
"disableAutoTransform": true,
|
||||
"fileName" : "orientation6_notranfs.png",
|
||||
"comment" : "Test with automatic transformation disabled."
|
||||
},
|
||||
{
|
||||
"minQtVersion" : "6.7.3",
|
||||
"disableAutoTransform": true,
|
||||
"fileName" : "orientation6_notranfs.png",
|
||||
"comment" : "Test with automatic transformation disabled."
|
||||
},
|
||||
{
|
||||
"unsupportedFormat" : true,
|
||||
"comment" : "It is not possible to disable the transformation with the current version of the plugin."
|
||||
}
|
||||
]
|
BIN
autotests/read/jxl/orientation6_notranfs.png
Normal file
BIN
autotests/read/jxl/orientation6_notranfs.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
@ -267,10 +267,13 @@ int main(int argc, char **argv)
|
||||
continue;
|
||||
}
|
||||
|
||||
bool skipTest = false;
|
||||
QFileInfo expFileInfo = timg.compareImage(skipTest);
|
||||
if (skipTest) {
|
||||
QTextStream(stdout) << "SKIP : " << fi.fileName() << ": image format not supported by current Qt version!\n";
|
||||
TemplateImage::TestFlags flags = TemplateImage::None;
|
||||
QString comment;
|
||||
QFileInfo expFileInfo = timg.compareImage(flags, comment);
|
||||
if ((flags & TemplateImage::SkipTest) == TemplateImage::SkipTest) {
|
||||
if(comment.isEmpty())
|
||||
comment = QStringLiteral("image format not supported by current Qt version!");
|
||||
QTextStream(stdout) << "SKIP : " << fi.fileName() << QStringLiteral(": %1\n").arg(comment);
|
||||
++skipped;
|
||||
continue;
|
||||
}
|
||||
@ -291,7 +294,7 @@ int main(int argc, char **argv)
|
||||
QImage expImage;
|
||||
|
||||
// inputImage is auto-rotated to final orientation
|
||||
inputReader.setAutoTransform(true);
|
||||
inputReader.setAutoTransform((flags & TemplateImage::DisableAutotransform) != TemplateImage::DisableAutotransform);
|
||||
|
||||
if (!expReader.read(&expImage)) {
|
||||
QTextStream(stdout) << "ERROR: " << fi.fileName() << ": could not load " << expfilename << ": " << expReader.errorString() << "\n";
|
||||
|
@ -28,10 +28,10 @@ bool TemplateImage::isTemplate() const
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo TemplateImage::compareImage(bool &skipTest) const
|
||||
QFileInfo TemplateImage::compareImage(TestFlags &flags, QString& comment) const
|
||||
{
|
||||
auto fi = jsonImage(skipTest);
|
||||
if (skipTest) {
|
||||
auto fi = jsonImage(flags, comment);
|
||||
if ((flags & TestFlag::SkipTest) == TestFlag::SkipTest) {
|
||||
return {};
|
||||
}
|
||||
if (fi.exists()) {
|
||||
@ -58,8 +58,9 @@ QFileInfo TemplateImage::legacyImage() const
|
||||
return {};
|
||||
}
|
||||
|
||||
QFileInfo TemplateImage::jsonImage(bool &skipTest) const
|
||||
QFileInfo TemplateImage::jsonImage(TestFlags &flags, QString& comment) const
|
||||
{
|
||||
flags = TestFlag::None;
|
||||
auto fi = QFileInfo(QStringLiteral("%1.json").arg(m_fi.filePath()));
|
||||
if (!fi.exists()) {
|
||||
return {};
|
||||
@ -86,6 +87,10 @@ QFileInfo TemplateImage::jsonImage(bool &skipTest) const
|
||||
auto maxQt = QVersionNumber::fromString(obj.value("maxQtVersion").toString());
|
||||
auto name = obj.value("fileName").toString();
|
||||
auto unsupportedFormat = obj.value("unsupportedFormat").toBool();
|
||||
comment = obj.value("comment").toString();
|
||||
|
||||
if(obj.value("disableAutoTransform").toBool())
|
||||
flags |= TestFlag::DisableAutotransform;
|
||||
|
||||
// filter
|
||||
if (name.isEmpty() && !unsupportedFormat)
|
||||
@ -95,7 +100,7 @@ QFileInfo TemplateImage::jsonImage(bool &skipTest) const
|
||||
if (!maxQt.isNull() && currentQt > maxQt)
|
||||
continue;
|
||||
if (unsupportedFormat) {
|
||||
skipTest = true;
|
||||
flags |= TestFlag::SkipTest;
|
||||
break;
|
||||
}
|
||||
return QFileInfo(QStringLiteral("%1/%2").arg(fi.path(), name));
|
||||
|
@ -16,6 +16,13 @@
|
||||
class TemplateImage
|
||||
{
|
||||
public:
|
||||
enum TestFlag {
|
||||
None = 0x0,
|
||||
SkipTest = 0x1,
|
||||
DisableAutotransform = 0x2
|
||||
};
|
||||
Q_DECLARE_FLAGS(TestFlags, TestFlag)
|
||||
|
||||
/*!
|
||||
* \brief TemplateImage
|
||||
* \param fi The image to test.
|
||||
@ -42,10 +49,10 @@ public:
|
||||
|
||||
/*!
|
||||
* \brief compareImage
|
||||
* \param skipTest True if the test should be skipped (e.g. image format not supported by current Qt version).
|
||||
* \param flags Flags for modifying test behavior (e.g. image format not supported by current Qt version).
|
||||
* \return The template image to use for the comparison.
|
||||
*/
|
||||
QFileInfo compareImage(bool &skipTest) const;
|
||||
QFileInfo compareImage(TestFlags &flags, QString& comment) const;
|
||||
|
||||
/*!
|
||||
* \brief suffixes
|
||||
@ -62,13 +69,15 @@ private:
|
||||
|
||||
/*!
|
||||
* \brief jsonImage
|
||||
* \param skipTest True if the test should be skipped (not supported).
|
||||
* \param flags Flags for modifying test behavior.
|
||||
* \return The template image read from the corresponding JSON.
|
||||
*/
|
||||
QFileInfo jsonImage(bool &skipTest) const;
|
||||
QFileInfo jsonImage(TestFlags &flags, QString& comment) const;
|
||||
|
||||
private:
|
||||
QFileInfo m_fi;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(TemplateImage::TestFlags)
|
||||
|
||||
#endif // TEMPLATEIMAGE_H
|
||||
|
Reference in New Issue
Block a user