mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-07-17 11:44:16 -04:00
Support to MCH with 4+ channels (treat as CMYK)
This commit is contained in:
@ -646,6 +646,9 @@ static bool IsValid(const PSDHeader &header)
|
|||||||
// Check that the header is supported by this plugin.
|
// Check that the header is supported by this plugin.
|
||||||
static bool IsSupported(const PSDHeader &header)
|
static bool IsSupported(const PSDHeader &header)
|
||||||
{
|
{
|
||||||
|
if (!IsValid(header)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (header.version != 1 && header.version != 2) {
|
if (header.version != 1 && header.version != 2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -660,10 +663,15 @@ static bool IsSupported(const PSDHeader &header)
|
|||||||
header.color_mode != CM_INDEXED &&
|
header.color_mode != CM_INDEXED &&
|
||||||
header.color_mode != CM_DUOTONE &&
|
header.color_mode != CM_DUOTONE &&
|
||||||
header.color_mode != CM_CMYK &&
|
header.color_mode != CM_CMYK &&
|
||||||
|
header.color_mode != CM_MULTICHANNEL &&
|
||||||
header.color_mode != CM_LABCOLOR &&
|
header.color_mode != CM_LABCOLOR &&
|
||||||
header.color_mode != CM_BITMAP) {
|
header.color_mode != CM_BITMAP) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (header.color_mode == CM_MULTICHANNEL &&
|
||||||
|
header.channel_count < 4) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,13 +737,14 @@ static QImage::Format imageFormat(const PSDHeader &header, bool alpha)
|
|||||||
else
|
else
|
||||||
format = header.channel_count < 4 || !alpha ? QImage::Format_RGB888 : QImage::Format_RGBA8888;
|
format = header.channel_count < 4 || !alpha ? QImage::Format_RGB888 : QImage::Format_RGBA8888;
|
||||||
break;
|
break;
|
||||||
case CM_CMYK: // Photoshop supports CMYK 8-bits and 16-bits only
|
case CM_MULTICHANNEL: // Treat MCH as CMYK (number of channel check is done in IsSupported())
|
||||||
|
case CM_CMYK: // Photoshop supports CMYK/MCH 8-bits and 16-bits only
|
||||||
if (header.depth == 16)
|
if (header.depth == 16)
|
||||||
format = header.channel_count < 5 || !alpha ? QImage::Format_RGBX64 : QImage::Format_RGBA64;
|
format = header.channel_count < 5 || !alpha ? QImage::Format_RGBX64 : QImage::Format_RGBA64;
|
||||||
else if (header.depth == 8)
|
else if (header.depth == 8)
|
||||||
format = header.channel_count < 5 || !alpha ? QImage::Format_RGB888 : QImage::Format_RGBA8888;
|
format = header.channel_count < 5 || !alpha ? QImage::Format_RGB888 : QImage::Format_RGBA8888;
|
||||||
break;
|
break;
|
||||||
case CM_LABCOLOR: // Photoshop supports LAB 8-bits and 16-bits only
|
case CM_LABCOLOR: // Photoshop supports LAB 8-bits and 16-bits only
|
||||||
if (header.depth == 16)
|
if (header.depth == 16)
|
||||||
format = header.channel_count < 4 || !alpha ? QImage::Format_RGBX64 : QImage::Format_RGBA64;
|
format = header.channel_count < 4 || !alpha ? QImage::Format_RGBX64 : QImage::Format_RGBA64;
|
||||||
else if (header.depth == 8)
|
else if (header.depth == 8)
|
||||||
@ -1078,7 +1087,7 @@ static bool LoadPSD(QDataStream &stream, const PSDHeader &header, QImage &img)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Conversion to RGB
|
// Conversion to RGB
|
||||||
if (header.color_mode == CM_CMYK) {
|
if (header.color_mode == CM_CMYK || header.color_mode == CM_MULTICHANNEL) {
|
||||||
if (header.depth == 8)
|
if (header.depth == 8)
|
||||||
cmykToRgb<quint8>(img.scanLine(y), imgChannels, psdScanline.data(), header.channel_count, header.width, alpha);
|
cmykToRgb<quint8>(img.scanLine(y), imgChannels, psdScanline.data(), header.channel_count, header.width, alpha);
|
||||||
else
|
else
|
||||||
@ -1257,7 +1266,7 @@ bool PSDHandler::canRead(QIODevice *device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return IsValid(header);
|
return IsSupported(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
QImageIOPlugin::Capabilities PSDPlugin::capabilities(QIODevice *device, const QByteArray &format) const
|
QImageIOPlugin::Capabilities PSDPlugin::capabilities(QIODevice *device, const QByteArray &format) const
|
||||||
|
Reference in New Issue
Block a user