Commit 817e66fd authored by Boudewijn Rempt's avatar Boudewijn Rempt

BUG:373267 Always save the merged image as 8 bit sRGB, no profile

For maximum compatibility with other applications.
parent 5d75bb20
......@@ -199,13 +199,13 @@ public:
* it is usually the concatenation of the id of the color model and of the color
* depth, for instance "RGBA8" or "CMYKA16" or "XYZA32f".
*/
virtual QString id() const;
QString id() const;
/**
* User visible name which contains the name of the color model and of the color depth.
* For intance "RGBA (8-bits)" or "CMYKA (16-bits)".
*/
virtual QString name() const;
QString name() const;
/**
* @return a string that identify the color model (for instance "RGB" or "CMYK" ...)
......
......@@ -835,6 +835,8 @@ KisImageWSP KisPNGConverter::image()
bool KisPNGConverter::saveDeviceToStore(const QString &filename, const QRect &imageRect, const qreal xRes, const qreal yRes, KisPaintDeviceSP dev, KoStore *store, KisMetaData::Store* metaData)
{
if (store->open(filename)) {
KoStoreDevice io(store);
if (!io.open(QIODevice::WriteOnly)) {
......@@ -852,6 +854,15 @@ bool KisPNGConverter::saveDeviceToStore(const QString &filename, const QRect &im
options.interlace = false;
options.tryToSaveAsIndexed = false;
options.alpha = true;
options.saveSRGBProfile = false;
if (dev->colorSpace()->id() != "RGBA") {
dev = new KisPaintDevice(*dev.data());
KUndo2Command *cmd = dev->convertTo(KoColorSpaceRegistry::instance()->rgb8());
delete cmd;
}
bool success = pngconv.buildFile(&io, imageRect, xRes, yRes, dev, annotIt, annotIt, options, metaDataStore);
if (success != KisImageBuilder_RESULT_OK) {
dbgFile << "Saving PNG failed:" << filename;
......
......@@ -114,6 +114,10 @@ public:
*/
KisImageWSP image();
/**
* @brief saveDeviceToStore saves the given paint device to the KoStore. If the device is not 8 bits sRGB, it will be converted to 8 bits sRGB.
* @return true if the saving succeeds
*/
static bool saveDeviceToStore(const QString &filename, const QRect &imageRect, const qreal xRes, const qreal yRes, KisPaintDeviceSP dev, KoStore *store, KisMetaData::Store* metaData = 0);
static bool isColorSpaceSupported(const KoColorSpace *cs);
......
......@@ -275,12 +275,6 @@ bool KisKraSaver::saveBinaryData(KoStore* store, KisImageWSP image, const QStrin
if (!autosave) {
KisPaintDeviceSP dev = image->projection();
if (!KisPNGConverter::isColorSpaceSupported(dev->colorSpace())) {
dev = new KisPaintDevice(*dev.data());
KUndo2Command *cmd = dev->convertTo(KoColorSpaceRegistry::instance()->rgb8());
delete cmd;
}
KisPNGConverter::saveDeviceToStore("mergedimage.png", image->bounds(), image->xRes(), image->yRes(), dev, store);
}
......
......@@ -101,11 +101,6 @@ KisImageBuilder_Result OraConverter::buildFile(const QString &filename, KisImage
}
KisPaintDeviceSP dev = image->projection();
if (!KisPNGConverter::isColorSpaceSupported(dev->colorSpace())) {
dev = new KisPaintDevice(*dev.data());
KUndo2Command *cmd = dev->convertTo(KoColorSpaceRegistry::instance()->rgb8());
delete cmd;
}
KisPNGConverter::saveDeviceToStore("mergedimage.png", image->bounds(), image->xRes(), image->yRes(), dev, store);
delete store;
......
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