diff --git a/autotests/read/psd/mch3-16bits.png b/autotests/read/psd/mch3-16bits.png new file mode 100644 index 0000000..e773bff Binary files /dev/null and b/autotests/read/psd/mch3-16bits.png differ diff --git a/autotests/read/psd/mch3-16bits.psb b/autotests/read/psd/mch3-16bits.psb new file mode 100644 index 0000000..4bcc5df Binary files /dev/null and b/autotests/read/psd/mch3-16bits.psb differ diff --git a/autotests/read/psd/mch3-8bits.png b/autotests/read/psd/mch3-8bits.png new file mode 100644 index 0000000..951c758 Binary files /dev/null and b/autotests/read/psd/mch3-8bits.png differ diff --git a/autotests/read/psd/mch3-8bits.psb b/autotests/read/psd/mch3-8bits.psb new file mode 100644 index 0000000..44ba360 Binary files /dev/null and b/autotests/read/psd/mch3-8bits.psb differ diff --git a/src/imageformats/psd.cpp b/src/imageformats/psd.cpp index 0a61c3b..0d7ed39 100644 --- a/src/imageformats/psd.cpp +++ b/src/imageformats/psd.cpp @@ -669,7 +669,7 @@ static bool IsSupported(const PSDHeader &header) return false; } if (header.color_mode == CM_MULTICHANNEL && - header.channel_count < 4) { + header.channel_count < 3) { return false; } return true; @@ -916,8 +916,8 @@ inline void cmykToRgb(uchar *target, qint32 targetChannels, const char *source, auto max = double(std::numeric_limits::max()); auto invmax = 1.0 / max; // speed improvements by ~10% - if (sourceChannels < 4) { - qDebug() << "cmykToRgb: image is not a valid CMYK!"; + if (sourceChannels < 3) { + qDebug() << "cmykToRgb: image is not a valid CMY/CMYK!"; return; } @@ -926,7 +926,7 @@ inline void cmykToRgb(uchar *target, qint32 targetChannels, const char *source, auto C = 1 - *(ps + 0) * invmax; auto M = 1 - *(ps + 1) * invmax; auto Y = 1 - *(ps + 2) * invmax; - auto K = 1 - *(ps + 3) * invmax; + auto K = sourceChannels > 3 ? 1 - *(ps + 3) * invmax : 0.0; auto pt = t + targetChannels * w; *(pt + 0) = T(std::min(max - (C * (1 - K) + K) * max + 0.5, max));