mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-04 00:04:03 -04:00
fix(ImageCache): don't convert CYMK image to RGB
CMYK image support has been added in Qt 6.8.0. For now, it's not possible to render in a CMYK image, and as a consequence to scale it. So, QGIS will report a warning message to user if requested size is different from the CMYK image one.
This commit is contained in:
parent
d2a173fdcf
commit
7d1419e823
@ -482,7 +482,11 @@ QImage QgsImageCache::renderImage( const QString &path, QSize size, const bool k
|
||||
}
|
||||
}
|
||||
|
||||
if ( !im.hasAlphaChannel() )
|
||||
if ( !im.hasAlphaChannel()
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
&& im.format() != QImage::Format_CMYK8888
|
||||
#endif
|
||||
)
|
||||
im = im.convertToFormat( QImage::Format_ARGB32 );
|
||||
|
||||
if ( opacity < 1.0 )
|
||||
|
@ -12,6 +12,9 @@
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QSignalSpy>
|
||||
|
||||
#include "qgstest.h"
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
@ -28,6 +31,7 @@
|
||||
#include "qgsapplication.h"
|
||||
#include "qgsrenderchecker.h"
|
||||
#include "qgssettings.h"
|
||||
#include "qgsmessagelog.h"
|
||||
|
||||
/**
|
||||
* \ingroup UnitTests
|
||||
@ -61,6 +65,7 @@ class TestQgsImageCache : public QgsTest
|
||||
void nextFrameDelay();
|
||||
void imageFrames();
|
||||
void preseedAnimation();
|
||||
void cmykImage();
|
||||
};
|
||||
|
||||
|
||||
@ -476,5 +481,23 @@ bool TestQgsImageCache::imageCheck( const QString &testName, QImage &image, int
|
||||
mReport += checker.report();
|
||||
return resultFlag;
|
||||
}
|
||||
|
||||
void TestQgsImageCache::cmykImage()
|
||||
{
|
||||
QgsImageCache cache;
|
||||
const QString imagePath = TEST_DATA_DIR + QStringLiteral( "/cmyk.jpg" );
|
||||
bool fitInCache;
|
||||
const QImage image = cache.pathAsImage( imagePath, QSize( 130, 50 ), true, 1.0, fitInCache );
|
||||
QVERIFY( !image.isNull() );
|
||||
QCOMPARE( image.size(), QSize( 130, 50 ) );
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
QCOMPARE( image.format(), QImage::Format_CMYK8888 );
|
||||
#else
|
||||
QCOMPARE( image.format(), QImage::Format_ARGB32 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QGSTEST_MAIN( TestQgsImageCache )
|
||||
#include "testqgsimagecache.moc"
|
||||
|
BIN
tests/testdata/cmyk.jpg
vendored
Normal file
BIN
tests/testdata/cmyk.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Loading…
x
Reference in New Issue
Block a user