Commit cdda7738 authored by Halla Rempt's avatar Halla Rempt

BUG:351298 Do not crash saving 16 bit CMYK to JPEG

The result looks wrong, though... Inverted. This also makes
the filter obey the batch mode setting, so it won't show a
warning message box when saving lab or ycbcr to jpeg.
parent 86bbe868
......@@ -91,10 +91,9 @@ J_COLOR_SPACE getColorTypeforColorSpace(const KoColorSpace * cs)
if (KoID(cs->id()) == KoID("RGBA") || KoID(cs->id()) == KoID("RGBA16")) {
return JCS_RGB;
}
if (KoID(cs->id()) == KoID("CMYK") || KoID(cs->id()) == KoID("CMYK16")) {
if (KoID(cs->id()) == KoID("CMYK") || KoID(cs->id()) == KoID("CMYKAU16")) {
return JCS_CMYK;
}
QMessageBox::information(0, i18nc("@title:window", "Krita"), i18n("Cannot export images in %1.\nWill save as RGB.", cs->name())) ;
return JCS_UNKNOWN;
}
......@@ -113,11 +112,12 @@ QString getColorSpaceModelForColorType(J_COLOR_SPACE color_type)
}
KisJPEGConverter::KisJPEGConverter(KisDocument *doc)
KisJPEGConverter::KisJPEGConverter(KisDocument *doc, bool batchMode)
{
m_doc = doc;
m_job = 0;
m_stop = false;
m_batchMode = batchMode;
}
KisJPEGConverter::~KisJPEGConverter()
......@@ -475,9 +475,14 @@ KisImageBuilder_Result KisJPEGConverter::buildFile(const KUrl& uri, KisPaintLaye
const KoColorSpace * cs = layer->colorSpace();
J_COLOR_SPACE color_type = getColorTypeforColorSpace(cs);
if (color_type == JCS_UNKNOWN) {
if (!m_batchMode) {
QMessageBox::information(0, i18nc("@title:window", "Krita"), i18n("Cannot export images in %1.\nWill save as RGB.", cs->name()));
}
KUndo2Command *tmp = layer->paintDevice()->convertTo(KoColorSpaceRegistry::instance()->rgb8(), KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags);
delete tmp;
cs = KoColorSpaceRegistry::instance()->rgb8();
color_type = JCS_RGB;
}
......@@ -485,6 +490,7 @@ KisImageBuilder_Result KisJPEGConverter::buildFile(const KUrl& uri, KisPaintLaye
const KoColorSpace* dst = KoColorSpaceRegistry::instance()->colorSpace(RGBAColorModelID.id(), layer->colorSpace()->colorDepthId().id(), "sRGB built-in - (lcms internal)");
KUndo2Command *tmp = layer->paintDevice()->convertTo(dst);
delete tmp;
cs = dst;
color_type = JCS_RGB;
}
......
......@@ -85,7 +85,7 @@ class KisJPEGConverter : public QObject
{
Q_OBJECT
public:
KisJPEGConverter(KisDocument *doc);
KisJPEGConverter(KisDocument *doc, bool batchMode = false);
virtual ~KisJPEGConverter();
public:
KisImageBuilder_Result buildImage(const KUrl& uri);
......@@ -102,6 +102,7 @@ private:
KisDocument *m_doc;
bool m_stop;
KIO::TransferJob *m_job;
bool m_batchMode;
};
#endif
......@@ -48,7 +48,7 @@
#include <kis_exif_info_visitor.h>
#include <generator/kis_generator_layer.h>
#include "kis_jpeg_converter.h"
#include <KisImportExportManager.h>
#include "ui_kis_wdg_options_jpeg.h"
......@@ -195,7 +195,7 @@ KisImportExportFilter::ConversionStatus KisJPEGExport::convert(const QByteArray&
image->refreshGraph();
image->lock();
KisJPEGConverter kpc(input);
KisJPEGConverter kpc(input, m_chain->manager()->getBatchMode());
KisPaintDeviceSP pd = new KisPaintDevice(*image->projection());
image->unlock();
......
......@@ -27,6 +27,7 @@
#include <kis_image.h>
#include <KisViewManager.h>
#include <KisImportExportManager.h>
#include "kis_jpeg_converter.h"
......@@ -64,7 +65,7 @@ KisImportExportFilter::ConversionStatus KisJPEGImport::convert(const QByteArray&
if (url.isEmpty())
return KisImportExportFilter::FileNotFound;
KisJPEGConverter ib(doc);
KisJPEGConverter ib(doc, m_chain->manager()->getBatchMode());
// if (view != 0)
// view -> canvasSubject() -> progressDisplay() -> setSubject(&ib, false, true);
......
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