13#include <QApplication>
15#include <QDomDocument>
101 QDomElement imageElement = doc.createElement(
"IMAGE");
132 const QString mode = [&]() {
141 Q_UNREACHABLE_RETURN(
"custom");
171 QDomElement animationElement = doc.createElement(
"animation");
175 imageElement.appendChild(animationElement);
180 if (beginIt != endIt) {
181 QDomElement annotationsElement = doc.createElement(
ANNOTATIONS);
183 while (it != endIt) {
184 if (!(*it) || (*it)->type().isEmpty()) {
188 QString type = (*it)->type();
192 QString description = (*it)->description();
193 QDomElement annotationElement = doc.createElement(
ANNOTATION);
194 annotationsElement.appendChild(annotationElement);
195 annotationElement.setAttribute(
"type", type);
196 annotationElement.setAttribute(
"description", description);
200 imageElement.appendChild(annotationsElement);
232 if (!store->
open(path +
'/' + fileName)) {
239 QByteArray ba = resource.
data();
243 nwritten = store->
write(ba);
250 if (nwritten != ba.size()) {
268 m_d->
errorMessages << i18nc(
"Error message when saving a .kra file",
"Could not save storyboards.");
273 QDomElement root = storyboardDocument.documentElement();
276 QByteArray ba = storyboardDocument.toByteArray();
279 nwritten = store->
write(ba);
282 qWarning() <<
"Could not save storyboard data to a byte array!";
285 bool r = store->
close();
286 success = success && r && (nwritten == ba.size());
290 m_d->
errorMessages << i18nc(
"Error message when saving a .kra file",
"Could not save storyboards.");
302 m_d->
errorMessages << i18nc(
"Error message when saving a .kra file",
"Could not save animation meta data.");
307 QDomElement root = animationDocument.documentElement();
312 QByteArray ba = animationDocument.toByteArray();
315 nwritten = store->
write(ba);
317 qWarning() <<
"Could not save animation meta data to a byte array!";
321 bool r = store->
close();
323 success = success && r && (nwritten == ba.size());
326 m_d->
errorMessages << i18nc(
"Error message when saving a .kra file",
"Could not save animation meta data.");
339 m_d->
errorMessages << i18nc(
"Error message when saving a .kra file",
"Could not save audio meta data.");
344 QDomElement root = audioDocument.documentElement();
348 QByteArray byteArray = audioDocument.toByteArray();
349 qint64 bytesWriteCount = 0;
350 if (!byteArray.isEmpty()) {
351 bytesWriteCount = store->
write(byteArray);
353 qWarning() <<
"Could not save audio data to a byte array!";
357 bool closeOK = store->
close();
359 success = success && closeOK && (bytesWriteCount == byteArray.size());
362 m_d->
errorMessages << i18nc(
"Error message when saving a .kra file",
"Could not save audio meta data.");
371 QDomElement ePalette = doc.createElement(
PALETTES);
372 QDomElement eResources = doc.createElement(
RESOURCES);
380 QDomElement eResource = doc.createElement(
"resource");
381 eResource.setAttribute(
"type", sig.
type);
382 eResource.setAttribute(
"name", sig.
name);
383 eResource.setAttribute(
"filename", sig.
filename);
384 eResource.setAttribute(
"md5sum", sig.
md5sum);
387 ePalette.appendChild(eResource);
390 eResources.appendChild(eResource);
394 element.appendChild(ePalette);
395 element.appendChild(eResources);
401 QDomElement eCommentList = doc.createElement(
"StoryboardCommentList");
403 QDomElement commentElement = doc.createElement(
"storyboardcomment");
404 commentElement.setAttribute(
"name", comment.name);
405 commentElement.setAttribute(
"visibility", comment.visibility);
406 eCommentList.appendChild(commentElement);
408 element.appendChild(eCommentList);
411 QDomElement eItemList = doc.createElement(
"StoryboardItemList");
413 QDomElement eItem = item->toXML(doc);
414 eItemList.appendChild(eItem);
416 element.appendChild(eItemList);
426 QDomElement exportItemElem = doc.createElement(
"export-settings");
430 element.appendChild(exportItemElem);
436 QMap<const KisNode*, QString>::iterator it;
439 const KisNode *node = it.key();
440 QString filename = it.value();
443 (external ? QString() : uri)
457 QDomElement root = doc.documentElement();
462 root.appendChild(element);
466 if (store->
open(location)) {
467 QByteArray xml = doc.toByteArray();
468 qint64 nwritten = store->
write(xml);
469 bool r = store->
close();
470 success = r && (nwritten == xml.size());
475 m_d->
errorMessages << i18nc(
"Error message on saving a .kra file",
"Could not save keyframes.");
504 bool savingAnnotationsSuccess =
true;
507 location = external ? QString() : uri;
509 if (store->
open(location)) {
510 nwritten = store->
write(annotation->annotation());
512 savingAnnotationsSuccess = savingAnnotationsSuccess && (nwritten == annotation->annotation().size()) && r;
514 savingAnnotationsSuccess =
false;
518 if (!savingAnnotationsSuccess) {
519 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save annotations."));
522 success = success && savingAnnotationsSuccess;
524 bool savingImageProfileSuccess =
true;
529 QByteArray profileRawData = profile->
rawData();
530 if (!profileRawData.isEmpty()) {
531 if (profile->
type() ==
"icc") {
540 location = external ? QString() : uri;
542 if (store->
open(location)) {
543 nwritten = store->
write(annotation->annotation());
545 savingImageProfileSuccess = savingImageProfileSuccess && (nwritten == annotation->annotation().size()) && r;
547 savingImageProfileSuccess =
false;
552 if (!savingImageProfileSuccess) {
553 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save image profile."));
555 success = success && savingImageProfileSuccess;
558 bool savingSoftproofingProfileSuccess =
true;
562 if (proofingProfile && proofingProfile->
valid()) {
563 QByteArray proofingProfileRaw = proofingProfile->
rawData();
564 if (!proofingProfileRaw.isEmpty()) {
569 location = external ? QString() : uri;
571 if (store->
open(location)) {
572 nwritten = store->
write(annotation->annotation());
574 savingSoftproofingProfileSuccess =
575 savingSoftproofingProfileSuccess && (nwritten == annotation->annotation().size()) && r;
577 savingSoftproofingProfileSuccess =
false;
582 if (!savingSoftproofingProfileSuccess) {
583 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save softproofing color profile."));
586 success = success && savingSoftproofingProfileSuccess;
592 bool savingRemainingAnnotationsSuccess =
true;
593 if (beginIt != endIt) {
595 while (it != endIt) {
596 if (!(*it) || (*it)->type().isEmpty()) {
600 QString type = (*it)->type();
603 location = external ? QString() : uri;
605 if (store->
open(location)) {
606 nwritten = store->
write((*it)->annotation());
608 savingRemainingAnnotationsSuccess = savingRemainingAnnotationsSuccess && (nwritten == (*it)->annotation().size()) && r;
610 savingRemainingAnnotationsSuccess =
false;
617 if (!savingRemainingAnnotationsSuccess) {
618 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save additional annotations."));
621 success = success && savingRemainingAnnotationsSuccess;
623 bool savingLayerStylesSuccess =
true;
627 if (stylesClones.size() > 0) {
628 location = external ? QString() : uri;
631 if (store->
open(location)) {
633 if (aslBuffer.open(QIODevice::WriteOnly)) {
637 nwritten = store->
write(aslBuffer.buffer());
638 savingLayerStylesSuccess = savingLayerStylesSuccess && (nwritten == aslBuffer.buffer().size());
640 savingLayerStylesSuccess =
false;
643 savingLayerStylesSuccess = savingLayerStylesSuccess && r;
645 savingLayerStylesSuccess =
false;
650 if (!savingLayerStylesSuccess) {
651 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save layer styles."));
654 success = success && savingLayerStylesSuccess;
656 bool savingMergedImageSuccess =
true;
657 if (addMergedImage) {
661 savingMergedImageSuccess = savingMergedImageSuccess && r;
665 if (!savingMergedImageSuccess) {
666 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save merged image."));
669 success = success && savingMergedImageSuccess;
672 success = success && r;
694 e.setAttribute(
COLORBYTEDATA, QString(colorData.toBase64()));
695 element.appendChild(e);
700 QDomElement colorsElement = doc.createElement(
COLORHISTORY);
703 element.appendChild(colorsElement);
727 hdr.appendChild(clli);
740 hdr.appendChild(cvi);
742 element.appendChild(hdr);
750 element.appendChild(e);
759 element.appendChild(e);
766 QDomElement e = doc.createElement(
"compositions");
768 composition->save(doc, e);
770 element.appendChild(e);
777 QMap<QString, int> assistantcounters;
781 QMap<KisPaintingAssistantHandleSP, int> handlemap;
784 if (!assistants.isEmpty()) {
787 if (!assistantcounters.contains(assist->id())){
788 assistantcounters.insert(assist->id(),0);
790 location = external ? QString() : uri;
792 location += QString(assist->id()+
"%1.assistant").arg(assistantcounters[assist->id()]);
794 data = assist->saveXml(handlemap);
795 if (store->
open(location)) {
796 qint64 nwritten = store->
write(data);
797 bool r = store->
close();
798 success = success && r && (nwritten == data.size());
802 assistantcounters[assist->id()]++;
806 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save assistants."));
813 int count_ellipse = 0,
815 count_perspective = 0,
817 count_vanishingpoint = 0,
818 count_infiniteruler = 0,
819 count_parallelruler = 0,
820 count_concentricellipse = 0,
821 count_fisheyepoint = 0,
823 count_perspectiveellipse = 0,
824 count_curvilinearperspective = 0;
826 if (!assistants.isEmpty()) {
827 QDomElement assistantsElement = doc.createElement(
"assistants");
829 if (assist->id() ==
"ellipse"){
830 assist->saveXmlList(doc, assistantsElement, count_ellipse);
833 else if (assist->id() ==
"spline"){
834 assist->saveXmlList(doc, assistantsElement, count_spline);
837 else if (assist->id() ==
"perspective"){
838 assist->saveXmlList(doc, assistantsElement, count_perspective);
841 else if (assist->id() ==
"vanishing point"){
842 assist->saveXmlList(doc, assistantsElement, count_vanishingpoint);
843 count_vanishingpoint++;
845 else if (assist->id() ==
"infinite ruler"){
846 assist->saveXmlList(doc, assistantsElement, count_infiniteruler);
847 count_infiniteruler++;
849 else if (assist->id() ==
"parallel ruler"){
850 assist->saveXmlList(doc, assistantsElement, count_parallelruler);
851 count_parallelruler++;
853 else if (assist->id() ==
"concentric ellipse"){
854 assist->saveXmlList(doc, assistantsElement, count_concentricellipse);
855 count_concentricellipse++;
857 else if (assist->id() ==
"fisheye-point"){
858 assist->saveXmlList(doc, assistantsElement, count_fisheyepoint);
859 count_fisheyepoint++;
861 else if (assist->id() ==
"two point"){
862 assist->saveXmlList(doc, assistantsElement, count_twopoint);
865 else if (assist->id() ==
"ruler"){
866 assist->saveXmlList(doc, assistantsElement, count_ruler);
869 else if (assist->id() ==
"perspective ellipse"){
870 assist->saveXmlList(doc, assistantsElement, count_perspectiveellipse);
871 count_perspectiveellipse++;
873 else if (assist->id() ==
"curvilinear-perspective"){
874 assist->saveXmlList(doc, assistantsElement, count_curvilinearperspective);
875 count_curvilinearperspective++;
878 element.appendChild(assistantsElement);
889 element.appendChild(gridElement);
900 QDomElement guidesElement = guides.
saveToXml(doc,
"guides");
901 element.appendChild(guidesElement);
913 element.appendChild(mirrorAxisElement);
924 if (!clips.isEmpty()) {
925 QDomElement audioClips = doc.createElement(
"audioClips");
926 Q_FOREACH(
const QFileInfo& file, clips) {
927 QDomElement clip = doc.createElement(QString(
"Clip"));
928 clip.setAttribute(
"filePath", file.absoluteFilePath());
929 clip.setAttribute(
"volume", volume);
930 audioClips.appendChild(clip);
932 element.appendChild(audioClips);
942 Q_FOREACH(
const KoColor & color, colors) {
943 color.
toXML(doc, colorsElement);
const QString DESCRIPTION
A data extension mechanism for Krita.
static QVector< KisPSDLayerStyleSP > collectAllLayerStyles(KisNodeSP root)
void saveToDevice(QIODevice &device)
void setStyles(const QVector< KisPSDLayerStyleSP > &styles)
KisMirrorAxisConfig mirrorAxisConfig
KoDocumentInfo * documentInfo() const
QList< KoColor > colorHistoryColors() const
QDomDocument createDomDocument(const QString &tagName, const QString &version) const
QColor assistantsGlobalColor()
StoryboardItemList getStoryboardItemList()
returns the list of pointers to storyboard Items for the document
KisNodeWSP preActivatedNode
QList< KisPaintingAssistantSP > assistants
QVector< StoryboardComment > getStoryboardCommentsList()
returns the list of comments for the storyboard docker in the document
QVector< QFileInfo > getAudioTracks() const
KisGuidesConfig guidesConfig
QDomElement saveDynamicDataToXml(QDomDocument &doc, const QString &tag) const
QDomElement saveToXml(QDomDocument &doc, const QString &tag) const
QString exportSequenceBaseName()
int currentUITime() const
const KisTimeSpan & documentPlaybackRange() const
documentPlaybackRange
QString exportSequenceFilePath()
int exportInitialFrameNumber()
std::optional< KisRelativeContentLightLevelInformation > relativeContentLightLevelInformation() const
relativeContentLightLevelInformation This returns (optionally) a KisRelativeContentLightLevelInformat...
vKisAnnotationSP_it endAnnotations()
KisGroupLayerSP rootLayer() const
const KoColorSpace * colorSpace() const
KisImageAnimationInterface * animationInterface() const
KisAnnotationSP annotation(const QString &type)
KisPaintDeviceSP projection() const
std::optional< double > hdrReferenceWhiteLightLevel() const
HDR Reference White livel.
QList< KisLayerCompositionSP > compositions()
QRect bounds() const override
KoColor defaultProjectionColor() const
std::optional< KisColorVolumeInformation > colorVolumeInformation() const
colorVolumeInformation
const KoColorProfile * profile() const
vKisAnnotationSP_it beginAnnotations()
KisProofingConfigurationSP proofingConfiguration() const
proofingConfiguration
KisKeyframeChannel stores and manages KisKeyframes. Maps units of time to virtual keyframe values....
virtual QDomElement toXML(QDomDocument doc, const QString &layerFilename)
QStringList errorMessages() const
void setExternalUri(const QString &uri)
bool saveKeyframes(KoStore *store, const QString &uri, bool external)
void saveStoryboardToXML(QDomDocument &doc, QDomElement &element)
bool saveNodeKeyframes(KoStore *store, QString location, const KisNode *node)
bool saveMirrorAxis(QDomDocument &doc, QDomElement &element)
bool saveAssistants(KoStore *store, QString uri, bool external)
QStringList errorMessages() const
QDomElement saveXML(QDomDocument &doc, KisImageSP image)
bool saveAnimationMetadata(KoStore *store, KisImageSP image, const QString &uri)
void saveResourcesToXML(QDomDocument &doc, QDomElement &element)
bool saveAudioXML(QDomDocument &doc, QDomElement &element)
bool saveResources(KoStore *store, KisImageSP image, const QString &uri)
bool saveBinaryData(KoStore *store, KisImageSP image, const QString &uri, bool external, bool addMergedImage)
bool saveAudio(KoStore *store)
void saveHDRMetadata(QDomDocument &doc, QDomElement &element, KisImageSP image)
void saveWarningColor(QDomDocument &doc, QDomElement &element, KisImageSP image)
bool saveKoColors(QDomDocument &doc, QDomElement &element, const QList< KoColor > &colors) const
void saveColorHistory(QDomDocument &doc, QDomElement &element)
bool saveGrid(QDomDocument &doc, QDomElement &element)
bool saveGuides(QDomDocument &doc, QDomElement &element)
KisKraSaver(KisDocument *document, const QString &filename, bool addMergedImage=true)
void saveBackgroundColor(QDomDocument &doc, QDomElement &element, KisImageSP image)
bool saveStoryboard(KoStore *store, KisImageSP image, const QString &uri)
QStringList warningMessages() const
void saveCompositions(QDomDocument &doc, QDomElement &element, KisImageSP image)
bool saveAssistantsList(QDomDocument &doc, QDomElement &element)
void saveAssistantsGlobalColor(QDomDocument &doc, QDomElement &element)
void saveAnimationMetadataToXML(QDomDocument &doc, QDomElement &element, KisImageSP image)
The KisMirrorAxisConfig class stores configuration for the KisMirrorAxis canvas decoration....
QDomElement saveToXml(QDomDocument &doc, const QString &tag) const
saveToXml() function for KisKraSaver
bool isDefault() const
Check whether the config object was changed, or is the class default.
static bool saveDeviceToStore(const QString &filename, const QRect &imageRect, const qreal xRes, const qreal yRes, KisPaintDeviceSP dev, KoStore *store, KisMetaData::Store *metaData=0)
saveDeviceToStore saves the given paint device to the KoStore. If the device is not 8 bits sRGB,...
@ Custom
Let artists configure their own.
@ Paper
Whether to use Paper settings (absolute colorimetric, 0% adaptation.)
@ Monitor
Whether to use monitor rendering intent and flags for the second transform.
QMap< const KisNode *, QString > keyframeFileNames()
QMap< const KisNode *, QString > nodeFileNames()
QStringList errorMessages() const
void setSelectedNodes(vKisNodeSP selectedNodes)
virtual quint32 pixelSize() const =0
void toXML(QDomDocument &doc, QDomElement &colorElt) const
const KoColorSpace * colorSpace() const
return the current colorSpace
QString aboutInfo(const QString &info) const
const KoResourceSignature & signature() const
KoEmbeddedResource embeddedResource() const noexcept
KoResourceSignature signature() const
A simple wrapper object for the main information about the resource.
qint64 write(const QByteArray &data)
virtual void setCompressionEnabled(bool e)
bool open(const QString &name)
This file is part of the Krita application in calligra.
#define KIS_SAFE_ASSERT_RECOVER(cond)
vKisAnnotationSP::iterator vKisAnnotationSP_it
const QString COLORVOLUMEBLUE
const QString CLLI_CALC_RGB_XYZ_FALLBACK
const QString CLLI_CALC_Rec2020
const QString PROOFINGPROFILENAME
const QString COLORHISTORY
const QString CANVASPROJECTIONCOLOR
const QString COLORVOLUMERED
const QString COLORBYTEDATA
const QString PROOFINGBLACKPOINTCOMPENSATION
const QString COLORVOLUMEMAXLUMINANCE
const QString ICC_PROOFING_PATH
const QString Y_RESOLUTION
const QString ASSISTANTS_PATH
const QString PROOFINGDEPTH
const QString ANIMATION_METADATA_PATH
const QString NATIVE_MIMETYPE
const QString LAYER_STYLES_PATH
const QString X_RESOLUTION
const QString STORYBOARD_PATH
const QString ANNOTATIONS_PATH
const QString PROOFINGDISPLAYBLACKPOINTCOMPENSATION
const QString PROOFINGDISPLAYMODE
const QString HDRREFERENCEWHITE
const QString CONTENTLIGHTLEVEL
const QString PROOFINGWARNINGCOLOR
const QString COLORVOLUMEGREEN
const QString COLORVOLUME
const QString PROOFINGDISPLAYINTENT
const QString CLLI_CALC_XYZY
const QString GLOBALASSISTANTSCOLOR
const QString ANNOTATIONS
const QString COLORVOLUMEWHITE
const QString RESOURCE_PATH
const QString PROOFINGMODEL
const QString PALETTE_PATH
const QString COLORVOLUMEMINLUMINANCE
const QString PROOFINGINTENT
const QString HDRMETADATA
const QString ICCPROOFINGPROFILE
const QString MIRROR_AXIS
const QString SIMPLECOLORDATA
const QString PROOFINGADAPTATIONSTATE
const QString COLORSPACE_NAME
const QString CLLI_CALCTYPE
void saveValue(QDomElement *parent, const QString &tag, const QSize &size)
QString qColorToQString(QColor color)
QString toString(const QString &value)
QMap< QString, KisKeyframeChannel * > keyframeChannels
bool accept(KisNodeVisitor &v) override
QMap< const KisNode *, QString > keyframeFilenames
QStringList warningMessages
QList< KoResourceLoadResult > linkedDocumentResources
QStringList errorMessages
QMap< const KisNode *, QString > nodeFileNames
QStringList specialAnnotations
@ XYZLuminance
Calculate luminance by converting to xyz.
@ Rec2020Component
Calculate luminance by converting to rec2020.
@ RGBComponent
Calculate luminance on the RGB components if possible.
double maxFrameAverageLightLevel
maxFrameAverage MaxFrameAverageLightLevel or MaxFALL is the average of average pixel brightnesses in ...
double maxContentLightLevel
virtual QByteArray rawData() const
virtual QString type() const
virtual bool valid() const =0
const KoColorProfile * profileByName(const QString &name) const
static KoColorSpaceRegistry * instance()
QVector2D asVector() const