Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit a2db748d authored by Boudewijn Rempt's avatar Boudewijn Rempt

EXR" Convert images to a supported colorspace

In the export dialog we warn and promise that conversion will
happen, so we should not give an error.
parent e9c81a26
......@@ -1044,16 +1044,22 @@ KisImageBuilder_Result EXRConverter::buildFile(const QString &filename, KisPaint
Imf::PixelType pixelType = Imf::NUM_PIXELTYPES;
if(layer->colorSpace()->colorDepthId() == Float16BitsColorDepthID) {
if (layer->colorSpace()->colorDepthId() == Float16BitsColorDepthID) {
pixelType = Imf::HALF;
} else if(layer->colorSpace()->colorDepthId() == Float32BitsColorDepthID)
{
}
else if(layer->colorSpace()->colorDepthId() == Float32BitsColorDepthID) {
pixelType = Imf::FLOAT;
}
if(pixelType >= Imf::NUM_PIXELTYPES)
{
return KisImageBuilder_RESULT_UNSUPPORTED_COLORSPACE;
else {
const KoColorSpace *cs = 0;
if (layer->colorSpace()->colorModelId() == GrayAColorModelID) {
cs = KoColorSpaceRegistry::instance()->colorSpace(GrayAColorModelID.id(), Float16BitsColorDepthID.id());
}
else {
cs = KoColorSpaceRegistry::instance()->colorSpace(RGBAColorModelID.id(), Float16BitsColorDepthID.id());
}
image->convertImageColorSpace(cs, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags());
pixelType = Imf::HALF;
}
......@@ -1288,6 +1294,17 @@ KisImageBuilder_Result EXRConverter::buildFile(const QString &filename, KisGroup
qint32 width = image->width();
Imf::Header header(width, height);
if (image->colorSpace()->colorDepthId() != Float16BitsColorDepthID && image->colorSpace()->colorDepthId() != Float32BitsColorDepthID) {
const KoColorSpace *cs = 0;
if (layer->colorSpace()->colorModelId() == GrayAColorModelID) {
cs = KoColorSpaceRegistry::instance()->colorSpace(GrayAColorModelID.id(), Float16BitsColorDepthID.id());
}
else {
cs = KoColorSpaceRegistry::instance()->colorSpace(RGBAColorModelID.id(), Float16BitsColorDepthID.id());
}
image->convertImageColorSpace(cs, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags());
}
QList<ExrPaintLayerSaveInfo> informationObjects;
d->recBuildPaintLayerSaveInfo(informationObjects, "", layer);
......
......@@ -84,7 +84,7 @@ KisImportExportFilter::ConversionStatus EXRExport::convert(KisDocument *document
res = exrConverter.buildFile(filename(), image->rootLayer());
}
dbgFile << " Result =" << res;
dbgFile << " Result =" << res;
switch (res) {
case KisImageBuilder_RESULT_INVALID_ARG:
document->setErrorMessage(i18n("This layer cannot be saved to EXR."));
......@@ -107,7 +107,9 @@ KisImportExportFilter::ConversionStatus EXRExport::convert(KisDocument *document
return KisImportExportFilter::WrongFormat;
case KisImageBuilder_RESULT_OK:
document->setErrorMessage(exrConverter.errorMessage());
if (!exrConverter.errorMessage().isNull()) {
document->setErrorMessage(exrConverter.errorMessage());
}
return KisImportExportFilter::OK;
default:
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment