Compare commits

...

6 Commits

Author SHA1 Message Date
fee0165bef Update dependency version to 6.7.0 2024-10-04 16:57:57 +02:00
ae641f7e94 Fix endianness bug in PCX reader on big endian architectures
When reading from a sequential device, the peekHeader() method in
the PCX readers reads the header its defined little endian into
arch-specific endianness for multibyte types.

Being a "peek" method, it then it tries to push back the bytes into
the device after reading for its next use, but it doesn’t convert
multibyte types correctly from arch-specifice endianness to the
initial little endian format.

Subsequent reading of the data from the device will thus lead to
incorrect values for multibyte types on the next use.

This patch reuses the same technique as the TGA reader to read the
whole header as bytes before deserializing it, so that the bytes
can be pushed back into the sequential device in the same order.
2024-09-22 01:31:13 +02:00
46f7b90ce6 Fixed read of BGR32 and RGB555 formats 2024-09-16 17:16:28 +02:00
f7c8eaa140 FIxed comparison of unsigned expression
Fix of [Issue 9](https://invent.kde.org/frameworks/kimageformats/-/issues/9)

Same of MR !253 to solve the `Fix of [Issue 9](https://invent.kde.org/frameworks/kimageformats/-/issues/9)` when rebasing.
2024-09-15 15:00:11 +00:00
36bfee8ae3 raw: Getting the image size does not need unpacking
According to the libraw documentation, the sizes are available directly
after open_datastream.
2024-09-13 19:17:31 +02:00
e2aaf89ec5 Update version to 6.7.0 2024-09-06 14:21:04 +02:00
5 changed files with 26 additions and 27 deletions

View File

@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.16)
set(KF_VERSION "6.6.0") # handled by release scripts
set(KF_DEP_VERSION "6.6.0") # handled by release scripts
set(KF_VERSION "6.7.0") # handled by release scripts
set(KF_DEP_VERSION "6.7.0") # handled by release scripts
project(KImageFormats VERSION ${KF_VERSION})
include(FeatureSummary)
find_package(ECM 6.6.0 NO_MODULE)
find_package(ECM 6.7.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)

View File

@ -136,7 +136,7 @@ public:
}
if (reader->supportsOption(QImageIOHandler::ImageTransformation)) {
m_transformations = reader->transformation();
if (m_transformations < 0 || m_transformations > 7)
if (int(m_transformations) < 0 || int(m_transformations) > 7)
ok = false;
}
return ok;

View File

@ -175,8 +175,8 @@ public:
// 32-bit
if (IsEqualGUID(jxrfmt, GUID_PKPixelFormat32bppBGR)) {
*conversionFormat = GUID_PKPixelFormat32bppRGB;
return QImage::Format_RGBX8888; // Format_RGB32 (?)
*conversionFormat = GUID_PKPixelFormat24bppRGB;
return QImage::Format_RGB888;
};
if (IsEqualGUID(jxrfmt, GUID_PKPixelFormat32bppBGRA)) {
*conversionFormat = GUID_PKPixelFormat32bppRGBA;
@ -643,7 +643,7 @@ private:
<< std::pair<QImage::Format, PKPixelFormatGUID>(QImage::Format_Mono, GUID_PKPixelFormatBlackWhite)
<< std::pair<QImage::Format, PKPixelFormatGUID>(QImage::Format_Grayscale8, GUID_PKPixelFormat8bppGray)
<< std::pair<QImage::Format, PKPixelFormatGUID>(QImage::Format_Grayscale16, GUID_PKPixelFormat16bppGray)
<< std::pair<QImage::Format, PKPixelFormatGUID>(QImage::Format_RGB555, GUID_PKPixelFormat16bppRGB565)
<< std::pair<QImage::Format, PKPixelFormatGUID>(QImage::Format_RGB555, GUID_PKPixelFormat16bppRGB555)
<< std::pair<QImage::Format, PKPixelFormatGUID>(QImage::Format_RGB16, GUID_PKPixelFormat16bppRGB565)
<< std::pair<QImage::Format, PKPixelFormatGUID>(QImage::Format_BGR888, GUID_PKPixelFormat24bppBGR)
<< std::pair<QImage::Format, PKPixelFormatGUID>(QImage::Format_RGB888, GUID_PKPixelFormat24bppRGB)

View File

@ -266,29 +266,30 @@ PCXHEADER::PCXHEADER()
bool peekHeader(QIODevice *d, PCXHEADER& h)
{
qint64 pos = 0;
if (!d->isSequential()) {
pos = d->pos();
qint64 oldPos = d->pos();
QByteArray head = d->read(sizeof(PCXHEADER));
int readBytes = head.size();
if (d->isSequential()) {
for (int pos = readBytes -1; pos >= 0; --pos) {
d->ungetChar(head[pos]);
}
} else {
d->seek(oldPos);
}
if (readBytes < sizeof(PCXHEADER)) {
return false;
}
auto ok = false;
{ // datastream is destroyed before working on device
QDataStream ds(d);
QDataStream ds(head);
ds.setByteOrder(QDataStream::LittleEndian);
ds >> h;
ok = ds.status() == QDataStream::Ok && h.isValid();
}
if (!d->isSequential()) {
return d->seek(pos) && ok;
}
// sequential device undo
auto head = reinterpret_cast<char*>(&h);
auto readBytes = sizeof(h);
while (readBytes > 0) {
d->ungetChar(head[readBytes-- - 1]);
}
return ok;
}

View File

@ -806,12 +806,10 @@ QVariant RAWHandler::option(ImageOption option) const
rawProcessor->imgdata.rawparams.shot_select = currentImageNumber();
#endif
if (rawProcessor->open_datastream(&stream) == LIBRAW_SUCCESS) {
if (rawProcessor->unpack() == LIBRAW_SUCCESS) {
auto w = libraw_get_iwidth(&rawProcessor->imgdata);
auto h = libraw_get_iheight(&rawProcessor->imgdata);
// flip & 4: taken from LibRaw code
v = (rawProcessor->imgdata.sizes.flip & 4) ? QSize(h, w) : QSize(w, h);
}
auto w = libraw_get_iwidth(&rawProcessor->imgdata);
auto h = libraw_get_iheight(&rawProcessor->imgdata);
// flip & 4: taken from LibRaw code
v = (rawProcessor->imgdata.sizes.flip & 4) ? QSize(h, w) : QSize(w, h);
}
d->rollbackTransaction();
}