import-kra.diff (12,869 bytes)
Index: scribus/CMakeLists.txt
===================================================================
--- scribus/CMakeLists.txt (revision 21425)
+++ scribus/CMakeLists.txt (working copy)
@@ -690,6 +690,7 @@
imagedataloaders/scimgdataloader.cpp
imagedataloaders/scimgdataloader_gimp.cpp
imagedataloaders/scimgdataloader_jpeg.cpp
+ imagedataloaders/scimgdataloader_kra.cpp
imagedataloaders/scimgdataloader_ora.cpp
imagedataloaders/scimgdataloader_pdf.cpp
imagedataloaders/scimgdataloader_pgf.cpp
Index: scribus/imagedataloaders/scimgdataloader_kra.cpp
===================================================================
--- scribus/imagedataloaders/scimgdataloader_kra.cpp (nonexistent)
+++ scribus/imagedataloaders/scimgdataloader_kra.cpp (working copy)
@@ -0,0 +1,180 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+#include <QFile>
+#include <QFileInfo>
+#include <QByteArray>
+#include <QList>
+#include "scimgdataloader_kra.h"
+#include "util_formats.h"
+
+ScImgDataLoader_KRA::ScImgDataLoader_KRA(void) : ScImgDataLoader()
+{
+ initSupportedFormatList();
+}
+
+void ScImgDataLoader_KRA::initSupportedFormatList(void)
+{
+ m_supportedFormats.clear();
+ m_supportedFormats.append("kra");
+}
+
+void ScImgDataLoader_KRA::loadEmbeddedProfile(const QString& fn, int /*page*/)
+{
+ m_embeddedProfile.resize(0);
+ m_profileComponents = 0;
+}
+
+bool ScImgDataLoader_KRA::loadPicture(const QString& fn, int /*page*/, int /*res*/, bool thumbnail)
+{
+ if (!QFile::exists(fn))
+ return false;
+ bool valid = m_imageInfoRecord.isRequest;
+ QMap<int, ImageLoadRequest> req = m_imageInfoRecord.RequestProps;
+ initialize();
+ m_imageInfoRecord.RequestProps = req;
+ m_imageInfoRecord.isRequest = valid;
+ m_imageInfoRecord.type = ImageTypeOther;
+ m_imageInfoRecord.exifDataValid = false;
+ m_imageInfoRecord.layerInfo.clear();
+ m_imageInfoRecord.PDSpathData.clear();
+ ScZipHandler *uz = new ScZipHandler();
+
+ if (!uz->open(fn))
+ {
+ delete uz;
+ return false;
+ }
+
+ // if thumbnail is set to true, this function is loading the thumbnail image into the preview area
+ // if thumbnail is set to false, this function is loading the main image
+
+ if (thumbnail)
+ {
+ if (uz->contains("preview.png"))
+ {
+ QByteArray im;
+
+ if (uz->read("preview.png", im))
+ {
+ m_image = QImage::fromData(im);
+
+ if (uz->contains("maindoc.xml"))
+ {
+ QByteArray f;
+ if (uz->read("maindoc.xml", f))
+ {
+ QDomDocument designMapDom;
+ if(designMapDom.setContent(f))
+ {
+ QDomElement docElem = designMapDom.documentElement().firstChildElement("IMAGE");
+ m_imageInfoRecord.exifInfo.height = docElem.attribute("height", "0").toInt();
+ m_imageInfoRecord.exifInfo.width = docElem.attribute("width", "0").toInt();
+
+ // sanitize values for x-res and y-res. some older versions of Krita had resolutions like "76,0000023"
+ QString xResClean = docElem.attribute("x-res", "72").replace(",", ".");
+ QString yResClean = docElem.attribute("y-res", "72").replace(",", ".");
+
+ // strip out all decimal stuff since we cannot have that.
+ xResClean = xResClean.split(".").at(0);
+ yResClean = yResClean.split(".").at(0);
+
+ m_imageInfoRecord.xres = xResClean.toInt();
+ m_imageInfoRecord.yres = yResClean.toInt();
+ }
+ }
+ }
+ m_imageInfoRecord.exifDataValid = true;
+ m_imageInfoRecord.exifInfo.thumbnail = m_image;
+ }
+ else
+ {
+
+ delete uz;
+ return false;
+ }
+ }
+ }
+ else
+ {
+ if (uz->contains("maindoc.xml"))
+ {
+ QByteArray f;
+ if (uz->read("maindoc.xml", f))
+ {
+ QDomDocument designMapDom;
+ if(designMapDom.setContent(f))
+ {
+ QDomElement docElem = designMapDom.documentElement().firstChildElement("IMAGE");
+ m_imageInfoRecord.exifInfo.height = docElem.attribute("height", "0").toInt();
+ m_imageInfoRecord.exifInfo.width = docElem.attribute("width", "0").toInt();
+
+
+
+ // sanitize values for x-res and y-res. some older versions of Krita had resolutions like "76,0000023"
+ QString xResClean = docElem.attribute("x-res", "72").replace(",", ".");
+ QString yResClean = docElem.attribute("y-res", "72").replace(",", ".");
+
+ // strip out all decimal stuff since we cannot have that.
+ xResClean = xResClean.split(".").at(0);
+ yResClean = yResClean.split(".").at(0);
+
+
+ m_imageInfoRecord.xres = xResClean.toInt();
+ m_imageInfoRecord.yres = yResClean.toInt();
+
+
+ m_image = QImage(m_imageInfoRecord.exifInfo.width, m_imageInfoRecord.exifInfo.height, QImage::Format_ARGB32_Premultiplied);
+ if (m_image.isNull())
+ {
+ uz->close();
+ delete uz;
+ return false;
+ }
+
+ // load the mergedimage.png into the painter
+ if (uz->contains("mergedimage.png"))
+ {
+ QByteArray im;
+
+ if (uz->read("mergedimage.png", im))
+ {
+ m_image.fill( qRgba(0, 0, 0, 0) );
+ m_image = QImage::fromData(im);
+ }
+ }
+
+ m_image = m_image.convertToFormat(QImage::Format_ARGB32);
+ m_imageInfoRecord.valid = true;
+ m_image.setDotsPerMeterX((int) (m_imageInfoRecord.xres / 0.0254));
+ m_image.setDotsPerMeterY((int) (m_imageInfoRecord.yres / 0.0254));
+ m_imageInfoRecord.BBoxX = 0;
+ m_imageInfoRecord.BBoxH = m_image.height();
+ m_imageInfoRecord.colorspace = ColorSpaceRGB;
+ m_pixelFormat = Format_BGRA_8;
+ }
+ }
+ }
+ }
+ uz->close();
+ delete uz;
+ return true; //TODO: I think this should be false!
+}
+
+bool ScImgDataLoader_KRA::preloadAlphaChannel(const QString& fn, int /*page*/, int res, bool& hasAlpha)
+{
+ hasAlpha = false;
+ if (loadPicture(fn, 0, 0, false))
+ {
+ hasAlpha = m_image.hasAlphaChannel();
+ if (m_image.hasAlphaChannel())
+ m_image = m_image.convertToFormat(QImage::Format_ARGB32);
+ else
+ m_image = QImage(); // Discard data immediately
+ return true;
+ }
+ return false;
+}
Index: scribus/imagedataloaders/scimgdataloader_kra.h
===================================================================
--- scribus/imagedataloaders/scimgdataloader_kra.h (nonexistent)
+++ scribus/imagedataloaders/scimgdataloader_kra.h (working copy)
@@ -0,0 +1,28 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+#ifndef SCIMGDATALOADER_KRA_H
+#define SCIMGDATALOADER_KRA_H
+
+#include "scimgdataloader.h"
+#include "scpainter.h"
+#include "third_party/zip/scribus_zip.h"
+#include <QDomDocument>
+#include <QDomElement>
+
+class ScImgDataLoader_KRA : public ScImgDataLoader
+{
+public:
+ ScImgDataLoader_KRA(void);
+
+ virtual bool preloadAlphaChannel(const QString& fn, int page, int res, bool& hasAlpha);
+ virtual void loadEmbeddedProfile(const QString& fn, int page = 0);
+ virtual bool loadPicture(const QString& fn, int page, int res, bool thumbnail);
+protected:
+ void initSupportedFormatList();
+};
+
+#endif
Index: scribus/scimage.cpp
===================================================================
--- scribus/scimage.cpp (revision 21425)
+++ scribus/scimage.cpp (working copy)
@@ -17,6 +17,7 @@
#endif
#include "imagedataloaders/scimgdataloader_jpeg.h"
#include "imagedataloaders/scimgdataloader_ora.h"
+#include "imagedataloaders/scimgdataloader_kra.h"
#include "imagedataloaders/scimgdataloader_pict.h"
#include "imagedataloaders/scimgdataloader_ps.h"
#include "imagedataloaders/scimgdataloader_psd.h"
@@ -2010,6 +2011,12 @@
if (pDataLoader.get())
pDataLoader->setRequest(imgInfo.isRequest, imgInfo.RequestProps);
}
+ else if (ext == "kra")
+ {
+ pDataLoader.reset( new ScImgDataLoader_KRA() );
+ if (pDataLoader.get())
+ pDataLoader->setRequest(imgInfo.isRequest, imgInfo.RequestProps);
+ }
else if (ext == "pat")
pDataLoader.reset( new ScImgDataLoader_GIMP() );
else if (ext == "pgf")
@@ -2284,6 +2291,11 @@
pDataLoader.reset( new ScImgDataLoader_ORA() );
pDataLoader->setRequest(imgInfo.isRequest, imgInfo.RequestProps);
}
+ else if (ext == "kra")
+ {
+ pDataLoader.reset( new ScImgDataLoader_KRA() );
+ pDataLoader->setRequest(imgInfo.isRequest, imgInfo.RequestProps);
+ }
#ifdef GMAGICK_FOUND
else if (fmtImg.contains(ext))
pDataLoader.reset( new ScImgDataLoader_QT() );
Index: scribus/util_formats.cpp
===================================================================
--- scribus/util_formats.cpp (revision 21425)
+++ scribus/util_formats.cpp (working copy)
@@ -31,6 +31,7 @@
m_fmts.insert(FormatsManager::GIF, QStringList() << "gif");
m_fmts.insert(FormatsManager::JPEG, QStringList() << "jpg" << "jpeg");
m_fmts.insert(FormatsManager::ORA, QStringList() << "ora");
+ m_fmts.insert(FormatsManager::KRA, QStringList() << "kra");
m_fmts.insert(FormatsManager::PAT, QStringList() << "pat");
m_fmts.insert(FormatsManager::PCT, QStringList() << "pct" << "pic" << "pict");
m_fmts.insert(FormatsManager::PDF, QStringList() << "pdf");
@@ -84,6 +85,7 @@
m_fmtNames[FormatsManager::GIF] = QObject::tr("GIF");
m_fmtNames[FormatsManager::JPEG] = QObject::tr("JPEG");
m_fmtNames[FormatsManager::ORA] = QObject::tr("Open Raster");
+ m_fmtNames[FormatsManager::KRA] = QObject::tr("Krita");
m_fmtNames[FormatsManager::PAT] = QObject::tr("Pattern Files");
m_fmtNames[FormatsManager::PDF] = QObject::tr("PDF Document");
m_fmtNames[FormatsManager::PGF] = QObject::tr("PGF");
@@ -111,6 +113,7 @@
m_fmtMimeTypes.insert(FormatsManager::GIF, QStringList() << "image/gif");
m_fmtMimeTypes.insert(FormatsManager::JPEG, QStringList() << "image/jpeg");
m_fmtMimeTypes.insert(FormatsManager::ORA, QStringList() << "");
+ m_fmtMimeTypes.insert(FormatsManager::KRA, QStringList() << "application/x-krita");
m_fmtMimeTypes.insert(FormatsManager::PAT, QStringList() << "");
m_fmtMimeTypes.insert(FormatsManager::PCT, QStringList() << "");
m_fmtMimeTypes.insert(FormatsManager::PDF, QStringList() << "application/pdf");
Index: scribus/util_formats.h
===================================================================
--- scribus/util_formats.h (revision 21425)
+++ scribus/util_formats.h (working copy)
@@ -37,14 +37,14 @@
enum ScImageFormatType
{
- ALLIMAGES = 1|2|4|8|16|32|64|128|256|512|1024|2048|4096|8192|16384|32768|524288|1048576|2097152|4194304,
+ ALLIMAGES = 1|2|4|8|16|32|64|128|256|512|1024|2048|4096|8192|16384|32768|524288|1048576|2097152|4194304|8388608,
#ifdef GMAGICK_FOUND
- IMAGESIMGFRAME = 1|2|4|16|32|64|128|256|512|65536|1048576|2097152|4194304, // all Types suitable for Image Frames
+ IMAGESIMGFRAME = 1|2|4|16|32|64|128|256|512|65536|1048576|2097152|4194304|8388608, // all Types suitable for Image Frames
#else
- IMAGESIMGFRAME = 1|2|4|16|32|64|128|256|512|262144|524288|1048576|2097152|4194304, // all Types suitable for Image Frames
+ IMAGESIMGFRAME = 1|2|4|16|32|64|128|256|512|262144|524288|1048576|2097152|4194304|8388608, // all Types suitable for Image Frames
#endif
VECTORIMAGES = 1|64|1024|2048|16384|32768|131072|262144|4194304, // All pure vector image types
- RASTORIMAGES = 2|4|8|32|128|256|512|65536|524288|1048576|2097152, // All pure rastor image types
+ RASTORIMAGES = 2|4|8|32|128|256|512|65536|524288|1048576|2097152|8388608, // All pure rastor image types
EPS = 1, // Encapsulated PostScript
GIF = 2, // GIF files
JPEG = 4, // JPEG
@@ -69,7 +69,8 @@
BMP = 524288, // BMP
PGF = 1048576, // PGF
ORA = 2097152, // ORA
- QT = 4194304 // Qt
+ QT = 4194304, // Qt
+ KRA = 8388608 // Krita
};
/*