mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-07-17 11:44:16 -04:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
4be09ba419 | |||
6cbdf9cf54 | |||
7d6de20e8c | |||
b37c991e39 | |||
249046f25d | |||
9f7b1b8dee | |||
f065104b72 | |||
f34185197a | |||
9f24023ca7 |
@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.16)
|
|||||||
project(KImageFormats)
|
project(KImageFormats)
|
||||||
|
|
||||||
include(FeatureSummary)
|
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")
|
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)
|
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||||
|
|
||||||
@ -91,6 +91,7 @@ if (BUILD_TESTING)
|
|||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif()
|
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)
|
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
|
||||||
|
BIN
autotests/read/exr/gray.exr
Normal file
BIN
autotests/read/exr/gray.exr
Normal file
Binary file not shown.
BIN
autotests/read/exr/gray.png
Normal file
BIN
autotests/read/exr/gray.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
@ -621,7 +621,14 @@ bool EXRHandler::write(const QImage &image)
|
|||||||
|
|
||||||
// write the EXR
|
// write the EXR
|
||||||
K_OStream ostr(device(), QByteArray());
|
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;
|
Imf::Array2D<Imf::Rgba> pixels;
|
||||||
pixels.resizeErase(EXR_LINES_PER_BLOCK, width);
|
pixels.resizeErase(EXR_LINES_PER_BLOCK, width);
|
||||||
|
|
||||||
|
@ -631,7 +631,7 @@ static bool IsValid(const PSDHeader &header)
|
|||||||
qDebug() << "PSD header: invalid color mode" << header.color_mode;
|
qDebug() << "PSD header: invalid color mode" << header.color_mode;
|
||||||
return false;
|
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).
|
// Photoshop does not make you add more (see also 53alphas.psd test case).
|
||||||
if (header.channel_count < 1 || header.channel_count > 57) {
|
if (header.channel_count < 1 || header.channel_count > 57) {
|
||||||
qDebug() << "PSD header: invalid number of channels" << header.channel_count;
|
qDebug() << "PSD header: invalid number of channels" << header.channel_count;
|
||||||
|
@ -60,20 +60,33 @@ const uchar *ScanLineConverter::convertedScanLine(const QImage &image, qint32 y)
|
|||||||
}
|
}
|
||||||
if (image.width() != _tmpBuffer.width() || image.format() != _tmpBuffer.format()) {
|
if (image.width() != _tmpBuffer.width() || image.format() != _tmpBuffer.format()) {
|
||||||
_tmpBuffer = QImage(image.width(), 1, image.format());
|
_tmpBuffer = QImage(image.width(), 1, image.format());
|
||||||
|
_tmpBuffer.setColorTable(image.colorTable());
|
||||||
}
|
}
|
||||||
if (_tmpBuffer.isNull()) {
|
if (_tmpBuffer.isNull()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
std::memcpy(_tmpBuffer.bits(), image.constScanLine(y), std::min(_tmpBuffer.bytesPerLine(), image.bytesPerLine()));
|
std::memcpy(_tmpBuffer.bits(), image.constScanLine(y), std::min(_tmpBuffer.bytesPerLine(), image.bytesPerLine()));
|
||||||
|
auto tmp = _tmpBuffer;
|
||||||
if (colorSpaceConversion) {
|
if (colorSpaceConversion) {
|
||||||
auto cs = image.colorSpace();
|
auto cs = image.colorSpace();
|
||||||
if (!cs.isValid()) {
|
if (!cs.isValid()) {
|
||||||
cs = _defaultColorSpace;
|
cs = _defaultColorSpace;
|
||||||
}
|
}
|
||||||
_tmpBuffer.setColorSpace(cs);
|
if (tmp.depth() < 24) {
|
||||||
_tmpBuffer.convertToColorSpace(_colorSpace);
|
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()) {
|
if (_convBuffer.isNull()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -90,9 +103,6 @@ qsizetype ScanLineConverter::bytesPerLine() const
|
|||||||
|
|
||||||
bool ScanLineConverter::isColorSpaceConversionNeeded(const QImage &image, const QColorSpace &targetColorSpace, const QColorSpace &defaultColorSpace)
|
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();
|
auto sourceColorSpace = image.colorSpace();
|
||||||
if (!sourceColorSpace.isValid()) {
|
if (!sourceColorSpace.isValid()) {
|
||||||
sourceColorSpace = defaultColorSpace;
|
sourceColorSpace = defaultColorSpace;
|
||||||
|
@ -960,7 +960,11 @@ bool XCFImageFormat::loadImageProperties(QDataStream &xcf_io, XCFImage &xcf_imag
|
|||||||
case PROP_PARASITES:
|
case PROP_PARASITES:
|
||||||
while (!property.atEnd()) {
|
while (!property.atEnd()) {
|
||||||
char *tag;
|
char *tag;
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||||
quint32 size;
|
quint32 size;
|
||||||
|
#else
|
||||||
|
qsizetype size;
|
||||||
|
#endif
|
||||||
|
|
||||||
property.readBytes(tag, size);
|
property.readBytes(tag, size);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user