Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_image.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org>
3 * SPDX-FileCopyrightText: 2007 Boudewijn Rempt <boud@valdyas.org>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7#ifndef KIS_IMAGE_H_
8#define KIS_IMAGE_H_
9
10#include <QObject>
11#include <QString>
12#include <QPainter>
13#include <QRect>
14
16
17#include "kis_types.h"
18#include "kis_shared.h"
20#include "kis_node_facade.h"
23#include "KisLodPreferences.h"
24#include "KisWraparoundAxis.h"
25
26#include <kritaimage_export.h>
27
28class KoColorSpace;
29class KoColor;
30
32class KisUndoStore;
33class KisUndoAdapter;
37class KoColorProfile;
43class KisPaintDevice;
45
48
49namespace KisMetaData
50{
51class MergeStrategy;
52}
53
59class KRITAIMAGE_EXPORT KisImage : public QObject,
60 public KisStrokesFacade,
62 public KisUpdatesFacade,
64 public KisNodeFacade,
66 public KisShared
67{
68
69 Q_OBJECT
70
71public:
73 KisImage(KisUndoStore *undoStore, qint32 width, qint32 height, const KoColorSpace *colorSpace, const QString& name);
74 ~KisImage() override;
75
76 static KisImageSP fromQImage(const QImage &image, KisUndoStore *undoStore);
77
78public: // KisNodeGraphListener implementation
79
80 void aboutToAddANode(KisNode *parent, int index) override;
81 void nodeHasBeenAdded(KisNode *parent, int index, KisNodeAdditionFlags flags) override;
82 void aboutToRemoveANode(KisNode *parent, int index) override;
83 void nodeChanged(KisNode * node) override;
84 void nodeCollapsedChanged(KisNode *node) override;
85 void invalidateAllFrames() override;
86 void notifySelectionChanged() override;
87 void requestProjectionUpdate(KisNode *node, const QVector<QRect> &rects, KisProjectionUpdateFlags flags) override;
88 void invalidateFrames(const KisTimeSpan &range, const QRect &rect) override;
89 void requestTimeSwitch(int time) override;
90 KisNode* graphOverlayNode() const override;
91
92 void keyframeChannelHasBeenAdded(KisNode *node, KisKeyframeChannel *channel) override;
93 void keyframeChannelAboutToBeRemoved(KisNode *node, KisKeyframeChannel *channel) override;
94
95public: // KisProjectionUpdateListener implementation
96 void notifyProjectionUpdated(const QRect &rc) override;
97
98public:
99
103 void setWorkingThreadsLimit(int value);
104
108 int workingThreadsLimit() const;
109
120 KisImage *clone(bool exactCopy = false);
121
122 void copyFromImage(const KisImage &rhs);
123
124private:
125
126 // must specify exactly one from CONSTRUCT or REPLACE.
128 CONSTRUCT = 1,
129 REPLACE = 2,
130 EXACT_COPY = 4,
131 };
132
133 void copyFromImageImpl(const KisImage &rhs, int policy);
134
135public:
136
140 QImage convertToQImage(qint32 x1,
141 qint32 y1,
142 qint32 width,
143 qint32 height,
144 const KoColorProfile * profile);
145
150 QImage convertToQImage(QRect imageRect,
151 const KoColorProfile * profile);
152
153
157 QImage convertToQImage(const QSize& scaledImageSize, const KoColorProfile *profile);
158
176 void immediateLockForReadOnly();
177
183 void unlock();
184
193 bool locked() const;
194
200 void setOverlaySelectionMask(KisSelectionMaskSP mask);
201
205 KisSelectionMaskSP overlaySelectionMask() const;
206
210 bool hasOverlaySelectionMask() const;
211
216 KisSelectionSP globalSelection() const;
217
221 QString nextLayerName(const QString &baseName = "") const;
222
238 void resizeImage(const QRect& newRect);
239
254 void cropImage(const QRect& newRect);
255
263 void purgeUnusedData(bool isCancellable);
264
279 void cropNode(KisNodeSP node, const QRect& newRect, const bool activeFrameOnly = false);
280 void cropNodes(KisNodeList nodes, const QRect& newRect, const bool activeFrameOnly = false);
281
293 void scaleImage(const QSize &size, qreal xres, qreal yres, KisFilterStrategy *filterStrategy);
294
308 void scaleNode(KisNodeSP node, const QPointF &center, qreal scaleX, qreal scaleY, KisFilterStrategy *filterStrategy, KisSelectionSP selection);
309 void scaleNodes(KisNodeList nodes, const QPointF &center, qreal scaleX, qreal scaleY, KisFilterStrategy *filterStrategy, KisSelectionSP selection);
310
322 void rotateImage(double radians);
323
337 void rotateNode(KisNodeSP node, double radians, KisSelectionSP selection);
338 void rotateNodes(KisNodeList nodes, double radians, KisSelectionSP selection);
339
351 void shear(double angleX, double angleY);
352
367 void shearNode(KisNodeSP node, double angleX, double angleY, KisSelectionSP selection);
368 void shearNodes(KisNodeList nodes, double angleX, double angleY, KisSelectionSP selection);
369
373 void convertImageProjectionColorSpace(const KoColorSpace *dstColorSpace);
374
378 void convertImageColorSpace(const KoColorSpace *dstColorSpace,
380 KoColorConversionTransformation::ConversionFlags conversionFlags);
381
388 void unifyLayersColorSpace();
389
393 void convertLayerColorSpace(KisNodeSP node,
394 const KoColorSpace *dstColorSpace,
396 KoColorConversionTransformation::ConversionFlags conversionFlags);
397
398
399 // Get the profile associated with this image
400 const KoColorProfile * profile() const;
401
411 bool assignLayerProfile(KisNodeSP node, const KoColorProfile *profile);
412
423 bool assignImageProfile(const KoColorProfile *profile, bool blockAllUpdates = false);
424
432 KisUndoAdapter* undoAdapter() const;
433
441
446 const KUndo2Command* lastExecutedCommand() const override;
447
454 void setUndoStore(KisUndoStore *undoStore);
455
459 KisUndoStore* undoStore();
460
471 void setModifiedWithoutUndo();
472
477 const KoColorSpace * colorSpace() const;
478
482 double xRes() const;
483
487 double yRes() const;
488
492 void setResolution(double xres, double yres);
493
499 QPointF documentToPixel(const QPointF &documentCoord) const;
500
506 QPoint documentToImagePixelFloored(const QPointF &documentCoord) const;
507
513 QRectF documentToPixel(const QRectF &documentRect) const;
514
520 QPointF pixelToDocument(const QPointF &pixelCoord) const;
521
528 QPointF pixelToDocument(const QPoint &pixelCoord) const;
529
535 QRectF pixelToDocument(const QRectF &pixelCoord) const;
536
540 qint32 width() const;
541
545 qint32 height() const;
546
550 QSize size() const {
551 return QSize(width(), height());
552 }
553
557 KisGroupLayerSP rootLayer() const;
558
563 KisPaintDeviceSP projection() const;
564
569 qint32 nlayers() const;
570
575 qint32 nHiddenLayers() const;
576
577 /*
578 * Return the number of layers (not other node types) that are
579 * descendants of the rootLayer in this image.
580 */
581 qint32 nChildLayers() const;
582
586 void flatten(KisNodeSP activeNode);
587
592 void mergeDown(KisLayerSP l, const KisMetaData::MergeStrategy* strategy);
593
599 void flattenLayer(KisLayerSP layer);
600
605 void mergeMultipleLayers(QList<KisNodeSP> mergedLayers, KisNodeSP putAfter);
606
608 QRect bounds() const override;
609
615 QRect effectiveLodBounds() const;
616
618 void notifyLayersChanged();
619
624 void setDefaultProjectionColor(const KoColor &color);
625
629 KoColor defaultProjectionColor() const;
630
631 void setRootLayer(KisGroupLayerSP rootLayer);
632
638 void addAnnotation(KisAnnotationSP annotation);
639
641 KisAnnotationSP annotation(const QString& type);
642
644 void removeAnnotation(const QString& type);
645
649 vKisAnnotationSP_it beginAnnotations();
650
652 vKisAnnotationSP_it endAnnotations();
653
657 void notifyAboutToBeDeleted();
658
659 KisImageSignalRouter* signalRouter();
660
666 bool canReselectGlobalSelection();
667
671 QList<KisLayerCompositionSP> compositions();
672
676 void addComposition(KisLayerCompositionSP composition);
677
681 void removeComposition(KisLayerCompositionSP composition);
682
686 void moveCompositionUp(KisLayerCompositionSP composition);
687
691 void moveCompositionDown(KisLayerCompositionSP composition);
692
700 void setWrapAroundModePermitted(bool value);
701
710 bool wrapAroundModePermitted() const;
711
715 void setWrapAroundModeAxis(WrapAroundAxis value);
721 WrapAroundAxis wrapAroundModeAxis() const;
722
723
730 bool wrapAroundModeActive() const;
731
737 int currentLevelOfDetail() const;
738
744 QPointF mirrorAxesCenter() const;
745
750 void setMirrorAxesCenter(const QPointF &value) const;
751
757 void setAllowMasksOnRootNode(bool value);
758
762 bool allowMasksOnRootNode() const;
763
764public Q_SLOTS:
765
771 void explicitRegenerateLevelOfDetail();
772
773public:
774
780 void setLodPreferences(const KisLodPreferences &value);
781
788 KisLodPreferences lodPreferences() const;
789
790 KisImageAnimationInterface *animationInterface() const;
791
797 void setProofingConfiguration(KisProofingConfigurationSP proofingConfig);
802 KisProofingConfigurationSP proofingConfiguration() const;
803
804
805 bool startIsolatedMode(KisNodeSP node, bool isolateLayer, bool isolateGroup);
806
814 std::optional<KisRelativeContentLightLevelInformation> relativeContentLightLevelInformation() const;
815
816 void setRelativeContentLightLevelInformation(const std::optional<KisRelativeContentLightLevelInformation> clli);
823 std::optional<KisColorVolumeInformation> colorVolumeInformation() const;
824
826 void setColorVolumeInformation(const std::optional<KisColorVolumeInformation> cvi);
827
835 std::optional<double> hdrReferenceWhiteLightLevel() const;
836
838 void setHdrReferenceWhiteLightLevel(const std::optional<double> value);
839
840public Q_SLOTS:
841 void stopIsolatedMode();
842
843
844public:
845 KisNodeSP isolationRootNode() const;
846 bool isIsolatingLayer() const;
847 bool isIsolatingGroup() const;
848
849Q_SIGNALS:
850
855 void sigImageUpdated(const QRect &);
856
862
868
885 void sigSizeChanged(const QPointF &oldStillPoint, const QPointF &newStillPoint);
886
887 void sigProfileChanged(const KoColorProfile * profile);
889 void sigResolutionChanged(double xRes, double yRes);
890 void sigRequestNodeReselection(KisNodeSP activeNode, const KisNodeList &selectedNodes);
891
896
901
914 void sigNodeAddedAsync(KisNodeSP node, KisNodeAdditionFlags flags);
915
926
934
946
955
968
981
987
996
1002
1008
1014
1015public:
1016 KisCompositeProgressProxy* compositeProgressProxy();
1017
1018 bool isIdle(bool allowLocked = false);
1019
1036 void barrierLock(bool readOnly = false);
1037
1048 bool tryBarrierLock(bool readOnly = false);
1049
1055 void waitForDone();
1056
1057 KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override;
1058 void addJob(KisStrokeId id, KisStrokeJobData *data) override;
1059 void endStroke(KisStrokeId id) override;
1060 bool cancelStroke(KisStrokeId id) override;
1061
1065 void blockUpdates() override;
1066
1071 void unblockUpdates() override;
1072
1083 void disableUIUpdates() override;
1084
1090 void notifyBatchUpdateStarted() override;
1091
1096 void notifyBatchUpdateEnded() override;
1097
1106 void notifyUIUpdateCompleted(const QRect &rc) override;
1107
1112
1130 void disableDirtyRequests() override;
1131
1135 void enableDirtyRequests() override;
1136
1161
1176
1183
1185 void refreshGraphAsync(KisNodeSP root, const QVector<QRect> &rects, const QRect &cropRect, KisProjectionUpdateFlags flags = KisProjectionUpdateFlag::None) override;
1186
1195 void initialRefreshGraph();
1196
1204 void addSpontaneousJob(KisSpontaneousJob *spontaneousJob);
1205
1212 bool hasUpdatesRunning() const override;
1213
1214public Q_SLOTS:
1215
1226 void requestUndoDuringStroke();
1227
1238 void requestRedoDuringStroke();
1239
1249 void requestStrokeCancellation();
1250
1258 UndoResult tryUndoUnfinishedLod0Stroke();
1259
1266 void requestStrokeEnd();
1267
1275 void requestStrokeEndActiveNode();
1276
1280 KisImageGlobalSelectionManagementInterface* globalSelectionManagementInterface() const;
1281
1282private:
1283
1284 KisImage(const KisImage& rhs, KisUndoStore *undoStore, bool exactCopy);
1286
1288
1289 void resizeImageImpl(const QRect& newRect, bool cropLayers);
1290 void rotateImpl(const KUndo2MagicString &actionName, KisNodeSP rootNode, double radians,
1291 bool resizeImage, KisSelectionSP selection);
1292 void rotateImpl(const KUndo2MagicString &actionName, KisNodeList nodes, double radians,
1293 bool resizeImage, KisSelectionSP selection);
1294 void shearImpl(const KUndo2MagicString &actionName, KisNodeSP rootNode,
1295 bool resizeImage, double angleX, double angleY, KisSelectionSP selection);
1296 void shearImpl(const KUndo2MagicString &actionName, KisNodeList nodes,
1297 bool resizeImage, double angleX, double angleY, KisSelectionSP selection);
1298
1300
1301 void refreshHiddenArea(KisNodeSP rootNode, const QRect &preparedArea);
1302
1304 void setSize(const QSize& size);
1305
1306 void setProjectionColorSpace(const KoColorSpace * colorSpace);
1307
1309
1310private:
1311 class KisImagePrivate;
1313};
1314
1315#endif // KIS_IMAGE_H_
float value(const T *src, size_t ch)
WrapAroundAxis
void sigLayersChangedAsync()
void refreshHiddenArea(KisNodeSP rootNode, const QRect &preparedArea)
void sigNodeCollapsedChanged()
KisImagePrivate * m_d
Definition kis_image.h:1312
void sigProfileChanged(const KoColorProfile *profile)
void emitSizeChanged()
void sigRequestNodeReselection(KisNodeSP activeNode, const KisNodeList &selectedNodes)
void sigStrokeCancellationRequested()
void sigRedoDuringStrokeRequested()
void sigImageModified()
void sigInternalStopIsolatedModeRequested()
void sigIsolatedModeChanged()
void safeRemoveTwoNodes(KisNodeSP node1, KisNodeSP node2)
void sigRemoveNodeAsync(KisNodeSP node)
void sigResolutionChanged(double xRes, double yRes)
void sigColorSpaceChanged(const KoColorSpace *cs)
QSize size() const
Definition kis_image.h:550
void sigStrokeEndRequested()
void sigUndoDuringStrokeRequested()
void sigNodeChanged(KisNodeSP node)
void sigAboutToBeDeleted()
void sigStrokeEndRequestedActiveNodeFiltered()
void cropNodes(KisNodeList nodes, const QRect &newRect, const bool activeFrameOnly=false)
void sigImageModifiedWithoutUndo()
void sigProofingConfigChanged()
void sigImageUpdated(const QRect &)
void sigNodeAddedAsync(KisNodeSP node, KisNodeAdditionFlags flags)
KisImage & operator=(const KisImage &rhs)
void sigSizeChanged(const QPointF &oldStillPoint, const QPointF &newStillPoint)
KisKeyframeChannel stores and manages KisKeyframes. Maps units of time to virtual keyframe values....
virtual void notifyProjectionUpdated(const QRect &rc)=0
The KisProofingConfiguration struct Little struct that stores the proofing configuration for a given ...
virtual const KUndo2Command * lastExecutedCommand() const =0
virtual KisPostExecutionUndoAdapter * postExecutionUndoAdapter() const =0
virtual KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy)=0
virtual void endStroke(KisStrokeId id)=0
virtual void addJob(KisStrokeId id, KisStrokeJobData *data)=0
virtual bool cancelStroke(KisStrokeId id)=0
virtual KisProjectionUpdatesFilterCookie addProjectionUpdatesFilter(KisProjectionUpdatesFilterSP filter)=0
virtual void enableDirtyRequests()=0
virtual void notifyBatchUpdateStarted()=0
virtual void disableDirtyRequests()=0
virtual bool hasUpdatesRunning() const =0
virtual void notifyBatchUpdateEnded()=0
virtual void blockUpdates()=0
virtual KisProjectionUpdatesFilterCookie currentProjectionUpdatesFilter() const =0
virtual KisProjectionUpdatesFilterSP removeProjectionUpdatesFilter(KisProjectionUpdatesFilterCookie cookie)=0
virtual void disableUIUpdates()=0
virtual void notifyUIUpdateCompleted(const QRect &rc)=0
virtual void unblockUpdates()=0
void refreshGraphAsync(KisNodeSP root=nullptr, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
virtual QVector< QRect > enableUIUpdates()=0
static QImage convertToQImage(char *buffer, qint32 width, qint32 height)
save the QImages as png files to directory image_tests
#define bounds(x, a, b)
vKisAnnotationSP::iterator vKisAnnotationSP_it
Definition kis_types.h:181
void * KisProjectionUpdatesFilterCookie
Definition kis_types.h:285
The KisColorVolumeInformation class is a struct that represents the 'mastering' display....
virtual void keyframeChannelHasBeenAdded(KisNode *node, KisKeyframeChannel *channel)
virtual KisNode * graphOverlayNode() const
virtual void aboutToRemoveANode(KisNode *parent, int index)
virtual void keyframeChannelAboutToBeRemoved(KisNode *node, KisKeyframeChannel *channel)
virtual void aboutToAddANode(KisNode *parent, int index)
virtual void requestProjectionUpdate(KisNode *node, const QVector< QRect > &rects, KisProjectionUpdateFlags flags)
virtual void nodeHasBeenAdded(KisNode *parent, int index, KisNodeAdditionFlags flags)
virtual void nodeChanged(KisNode *node)
virtual void invalidateFrames(const KisTimeSpan &range, const QRect &rect)
virtual void requestTimeSwitch(int time)
virtual void nodeCollapsedChanged(KisNode *node)