mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-07-18 03:54:18 -04:00
IFF: read only support to Interchange Format Files
Read-only support for most common Interchange Format Files (IFF). Supports IFF saved by Photoshop for the Amiga and Maya platform and HAM6 coded files. Closes #29
This commit is contained in:
committed by
Albert Astals Cid
parent
e6357c22f7
commit
4f2f2425d3
@ -28,6 +28,7 @@
|
||||
|
||||
#include "fastmath_p.h"
|
||||
#include "microexif_p.h"
|
||||
#include "packbits_p.h"
|
||||
#include "psd_p.h"
|
||||
#include "scanlineconverter_p.h"
|
||||
#include "util_p.h"
|
||||
@ -712,48 +713,6 @@ static bool IsSupported(const PSDHeader &header)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief decompress
|
||||
* Fast PackBits decompression.
|
||||
* \param input The compressed input buffer.
|
||||
* \param ilen The input buffer size.
|
||||
* \param output The uncompressed target buffer.
|
||||
* \param olen The target buffer size.
|
||||
* \return The number of valid bytes in the target buffer.
|
||||
*/
|
||||
qint64 decompress(const char *input, qint64 ilen, char *output, qint64 olen)
|
||||
{
|
||||
qint64 j = 0;
|
||||
for (qint64 ip = 0, rr = 0, available = olen; j < olen && ip < ilen; available = olen - j) {
|
||||
signed char n = static_cast<signed char>(input[ip++]);
|
||||
if (n == -128)
|
||||
continue;
|
||||
|
||||
if (n >= 0) {
|
||||
rr = qint64(n) + 1;
|
||||
if (available < rr) {
|
||||
--ip;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ip + rr > ilen)
|
||||
return -1;
|
||||
memcpy(output + j, input + ip, size_t(rr));
|
||||
ip += rr;
|
||||
} else if (ip < ilen) {
|
||||
rr = qint64(1-n);
|
||||
if (available < rr) {
|
||||
--ip;
|
||||
break;
|
||||
}
|
||||
memset(output + j, input[ip++], size_t(rr));
|
||||
}
|
||||
|
||||
j += rr;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief imageFormat
|
||||
* \param header The PSD header.
|
||||
@ -1102,7 +1061,7 @@ bool readChannel(QByteArray &target, QDataStream &stream, quint32 compressedSize
|
||||
if (stream.readRawData(tmp.data(), tmp.size()) != tmp.size()) {
|
||||
return false;
|
||||
}
|
||||
if (decompress(tmp.data(), tmp.size(), target.data(), target.size()) < 0) {
|
||||
if (packbitsDecompress(tmp.data(), tmp.size(), target.data(), target.size()) < 0) {
|
||||
return false;
|
||||
}
|
||||
} else if (stream.readRawData(target.data(), target.size()) != target.size()) {
|
||||
|
Reference in New Issue
Block a user