QPNGImageWriter: fix compilation with libpng 1.4
Amends 83de6d0ce5
.
The interface of png_set_iCCP() changed source-incompatibly from 1.4
to 1.5. #ifdef on the version as is done elsewhere in the code. Drop a
no-op C cast.
Also add PNG_iCCP_SUPPORTED around the new code, as that check is used
elsewhere in the code.
Change-Id: Ie203bd9eebea5697f426fa3e95591f86346b2685
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
parent
889b1c4b28
commit
1fcd8345ac
@ -980,6 +980,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, volatile int compression_i
|
|||||||
bpc, // per channel
|
bpc, // per channel
|
||||||
color_type, 0, 0, 0); // sets #channels
|
color_type, 0, 0, 0); // sets #channels
|
||||||
|
|
||||||
|
#ifdef PNG_iCCP_SUPPORTED
|
||||||
if (image.colorSpace().isValid()) {
|
if (image.colorSpace().isValid()) {
|
||||||
QColorSpace cs = image.colorSpace();
|
QColorSpace cs = image.colorSpace();
|
||||||
// Support the old gamma making it override transferfunction.
|
// Support the old gamma making it override transferfunction.
|
||||||
@ -995,9 +996,17 @@ bool QPNGImageWriter::writeImage(const QImage& image, volatile int compression_i
|
|||||||
if (iccProfileName.isEmpty())
|
if (iccProfileName.isEmpty())
|
||||||
iccProfileName = QByteArrayLiteral("Custom");
|
iccProfileName = QByteArrayLiteral("Custom");
|
||||||
QByteArray iccProfile = cs.iccProfile();
|
QByteArray iccProfile = cs.iccProfile();
|
||||||
png_set_iCCP(png_ptr, info_ptr, (png_const_charp)iccProfileName.constData(),
|
png_set_iCCP(png_ptr, info_ptr,
|
||||||
PNG_COMPRESSION_TYPE_BASE, (png_const_bytep)iccProfile.constData(), iccProfile.length());
|
#if PNG_LIBPNG_VER < 10500
|
||||||
} else if (gamma != 0.0) {
|
iccProfileName.data(), PNG_COMPRESSION_TYPE_BASE, iccProfile.data(),
|
||||||
|
#else
|
||||||
|
iccProfileName.constData(), PNG_COMPRESSION_TYPE_BASE,
|
||||||
|
(png_const_bytep)iccProfile.constData(),
|
||||||
|
#endif
|
||||||
|
iccProfile.length());
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
if (gamma != 0.0) {
|
||||||
png_set_gAMA(png_ptr, info_ptr, 1.0/gamma);
|
png_set_gAMA(png_ptr, info_ptr, 1.0/gamma);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user