Compare commits

..

9 Commits

Author SHA1 Message Date
4be09ba419 update version for new release 2024-02-21 11:15:16 +00:00
6cbdf9cf54 Workaround QTBUG-120614 2024-02-09 07:55:28 +00:00
7d6de20e8c update version for new release 2024-02-01 09:26:20 +00:00
b37c991e39 Port to ECMFeatureSummary
This avoids a feature summary in the middle of the cmake configuration
when this module is used as a git submodule.

GIT_SILENT
2024-01-26 14:17:50 +01:00
249046f25d update version for new release 2024-01-10 11:27:02 +00:00
9f7b1b8dee ScanlineConverter: fix indexed conversion and support for source depth less than 24 bits 2024-01-06 09:04:06 +01:00
f065104b72 Less space used when saving a grayscale image 2024-01-06 08:20:14 +01:00
f34185197a Fix build with Qt 6.7 2023-12-20 18:32:28 +01:00
9f24023ca7 The maximum number of channels explained better
Just a clarification on why the maximum value of channels present in the specifications is not used.
2023-12-20 16:43:12 +00:00
7 changed files with 32 additions and 10 deletions

View File

@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.16)
project(KImageFormats)
include(FeatureSummary)
find_package(ECM 5.240.0 NO_MODULE)
find_package(ECM 6.0.0 NO_MODULE)
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
@ -91,6 +91,7 @@ if (BUILD_TESTING)
add_subdirectory(tests)
endif()
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
include(ECMFeatureSummary)
ecm_feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)

BIN
autotests/read/exr/gray.exr Normal file

Binary file not shown.

BIN
autotests/read/exr/gray.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -621,7 +621,14 @@ bool EXRHandler::write(const QImage &image)
// write the EXR
K_OStream ostr(device(), QByteArray());
Imf::RgbaOutputFile file(ostr, header, image.hasAlphaChannel() ? Imf::RgbaChannels::WRITE_RGBA : Imf::RgbaChannels::WRITE_RGB);
auto channelsType = image.hasAlphaChannel() ? Imf::RgbaChannels::WRITE_RGBA : Imf::RgbaChannels::WRITE_RGB;
if (image.format() == QImage::Format_Mono ||
image.format() == QImage::Format_MonoLSB ||
image.format() == QImage::Format_Grayscale16 ||
image.format() == QImage::Format_Grayscale8) {
channelsType = Imf::RgbaChannels::WRITE_Y;
}
Imf::RgbaOutputFile file(ostr, header, channelsType);
Imf::Array2D<Imf::Rgba> pixels;
pixels.resizeErase(EXR_LINES_PER_BLOCK, width);

View File

@ -631,7 +631,7 @@ static bool IsValid(const PSDHeader &header)
qDebug() << "PSD header: invalid color mode" << header.color_mode;
return false;
}
// Specs tells: "Supported range is 1 to 56" but the limit is 57:
// Specs tells: "Supported range is 1 to 56" but when the alpha channel is present the limit is 57:
// Photoshop does not make you add more (see also 53alphas.psd test case).
if (header.channel_count < 1 || header.channel_count > 57) {
qDebug() << "PSD header: invalid number of channels" << header.channel_count;

View File

@ -60,20 +60,33 @@ const uchar *ScanLineConverter::convertedScanLine(const QImage &image, qint32 y)
}
if (image.width() != _tmpBuffer.width() || image.format() != _tmpBuffer.format()) {
_tmpBuffer = QImage(image.width(), 1, image.format());
_tmpBuffer.setColorTable(image.colorTable());
}
if (_tmpBuffer.isNull()) {
return nullptr;
}
std::memcpy(_tmpBuffer.bits(), image.constScanLine(y), std::min(_tmpBuffer.bytesPerLine(), image.bytesPerLine()));
auto tmp = _tmpBuffer;
if (colorSpaceConversion) {
auto cs = image.colorSpace();
if (!cs.isValid()) {
cs = _defaultColorSpace;
}
_tmpBuffer.setColorSpace(cs);
_tmpBuffer.convertToColorSpace(_colorSpace);
if (tmp.depth() < 24) {
tmp.convertTo(tmp.hasAlphaChannel() ? QImage::Format_ARGB32 : QImage::Format_RGB32);
}
tmp.setColorSpace(cs);
tmp.convertToColorSpace(_colorSpace);
}
_convBuffer = _tmpBuffer.convertToFormat(_targetFormat);
/*
* Work Around for wrong RGBA64 -> 16FPx4/32FPx4 conversion on Intel architecture.
* Luckily convertTo() works fine with 16FPx4 images so I can use it instead convertToFormat().
* See also: https://bugreports.qt.io/browse/QTBUG-120614
*/
tmp.convertTo(_targetFormat);
_convBuffer = tmp;
if (_convBuffer.isNull()) {
return nullptr;
}
@ -90,9 +103,6 @@ qsizetype ScanLineConverter::bytesPerLine() const
bool ScanLineConverter::isColorSpaceConversionNeeded(const QImage &image, const QColorSpace &targetColorSpace, const QColorSpace &defaultColorSpace)
{
if (image.depth() < 24) { // RGB 8 bit or grater only
return false;
}
auto sourceColorSpace = image.colorSpace();
if (!sourceColorSpace.isValid()) {
sourceColorSpace = defaultColorSpace;

View File

@ -960,7 +960,11 @@ bool XCFImageFormat::loadImageProperties(QDataStream &xcf_io, XCFImage &xcf_imag
case PROP_PARASITES:
while (!property.atEnd()) {
char *tag;
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
quint32 size;
#else
qsizetype size;
#endif
property.readBytes(tag, size);