Document
#include <Document.h>
Detailed Description
The Document class encapsulates a Krita Document/Image.
A Krita document is an Image with a filename. Libkis does not differentiate between a document and an image, like Krita does internally.
Definition at line 33 of file Document.h.
Constructor & Destructor Documentation
◆ Document()
|
explicit |
Definition at line 76 of file Document.cpp.
◆ ~Document()
|
override |
Definition at line 84 of file Document.cpp.
Member Function Documentation
◆ activeNode
|
slot |
activeNode retrieve the node that is currently active in the currently active window
- Returns
- the active node. If there is no active window, the first child node is returned.
Definition at line 115 of file Document.cpp.
◆ animationLength
|
slot |
get total frame range for animation
- Returns
- total frame range for animation
Definition at line 1026 of file Document.cpp.
◆ annotation
|
slot |
annotation the actual data for the annotation for this type.
It's a simple QByteArray, what's in it depends on the type of the annotation
- Parameters
-
type the type of the annotation
- Returns
- a bytearray, possibly empty if this type of annotation doesn't exist
Definition at line 1109 of file Document.cpp.
◆ annotationDescription
annotationDescription gets the pretty description for the current annotation
- Parameters
-
type the type of the annotation
- Returns
- a string that can be presented to the user
Definition at line 1102 of file Document.cpp.
◆ annotationTypes
|
slot |
annotationTypes returns the list of annotations present in the document.
Each annotation type is unique.
Definition at line 1075 of file Document.cpp.
◆ backgroundColor
|
slot |
backgroundColor returns the current background color of the document.
The color will also include the opacity.
- Returns
- QColor
Definition at line 222 of file Document.cpp.
◆ batchmode
|
slot |
Batchmode means that no actions on the document should show dialogs or popups.
- Returns
- true if the document is in batchmode.
Definition at line 103 of file Document.cpp.
◆ bounds
|
slot |
bounds return the bounds of the image
- Returns
- the bounds
Definition at line 942 of file Document.cpp.
◆ clone
|
slot |
clone create a shallow clone of this document.
- Returns
- a new Document that should be identical to this one in every respect.
We set ownsDocument to true, it will be reset automatically as soon as we create the first view for the document
Definition at line 870 of file Document.cpp.
◆ close
|
slot |
close Close the document: remove it from Krita's internal list of documents and close all views.
If the document is modified, you should save it first. There will be no prompt for saving.
After closing the document it becomes invalid.
- Returns
- true if the document is closed.
Definition at line 474 of file Document.cpp.
◆ colorDepth
|
slot |
colorDepth A string describing the color depth of the image:
- U8: unsigned 8 bits integer, the most common type
- U16: unsigned 16 bits integer
- F16: half, 16 bits floating point. Only available if Krita was built with OpenEXR
- F32: 32 bits floating point
- Returns
- the color depth.
Definition at line 178 of file Document.cpp.
◆ colorModel
|
slot |
colorModel retrieve the current color model of this document:
- A: Alpha mask
- RGBA: RGB with alpha channel (The actual order of channels is most often BGR!)
- XYZA: XYZ with alpha channel
- LABA: LAB with alpha channel
- CMYKA: CMYK with alpha channel
- GRAYA: Gray with alpha channel
- YCbCrA: YCbCr with alpha channel
- Returns
- the internal color model string.
Definition at line 184 of file Document.cpp.
◆ colorProfile
|
slot |
- Returns
- the name of the current color profile
Definition at line 190 of file Document.cpp.
◆ createCloneLayer
|
slot |
◆ createColorizeMask
|
slot |
createColorizeMask Creates a colorize mask, which can be used to color fill via keystrokes.
- Parameters
-
name - the name of the layer.
- Returns
- a TransparencyMask
Definition at line 778 of file Document.cpp.
◆ createFileLayer
|
slot |
createFileLayer returns a layer that shows an external image.
- Parameters
-
name name of the file layer. fileName the absolute filename of the file referenced. Symlinks will be resolved. scalingMethod how the dimensions of the file are interpreted can be either "None", "ImageToSize" or "ImageToPPI" scalingFilter filter used to scale the file can be "Bicubic", "Hermite", "NearestNeighbor", "Bilinear", "Bell", "BSpline", "Lanczos3", "Mitchell"
- Returns
- a FileLayer
Definition at line 658 of file Document.cpp.
◆ createFillLayer
|
slot |
createFillLayer creates a fill layer object, which is a layer
- Parameters
-
name generatorName - name of the generation filter. configuration - the configuration for the generation filter. selection - the selection.
- Returns
- a filllayer object.
Definition at line 676 of file Document.cpp.
◆ createFilterLayer
|
slot |
createFilterLayer creates a filter layer, which is a layer that represents a filter applied non-destructively.
- Parameters
-
name name of the filterLayer filter the filter that this filter layer will us. selection the selection.
- Returns
- a filter layer object.
Definition at line 667 of file Document.cpp.
◆ createFilterMask [1/2]
|
slot |
createFilterMask Creates a filter mask object that much like a filterlayer can apply a filter non-destructively.
- Parameters
-
name the name of the layer. filter the filter assigned. selection_source a node from which the selection should be initialized
- Returns
- a FilterMask
Definition at line 714 of file Document.cpp.
◆ createFilterMask [2/2]
|
slot |
createFilterMask Creates a filter mask object that much like a filterlayer can apply a filter non-destructively.
- Parameters
-
name the name of the layer. filter the filter assigned. selection the selection to be used by the filter mask
- Returns
- a FilterMask
Definition at line 736 of file Document.cpp.
◆ createGroupLayer
|
slot |
createGroupLayer Returns a grouplayer object.
Grouplayers are nodes that can have other layers as children and have the passthrough mode.
- Parameters
-
name the name of the layer.
- Returns
- a GroupLayer object.
Definition at line 649 of file Document.cpp.
◆ createNode
@brief createNode create a new node of the given type. The node is not added to the node hierarchy; you need to do that by finding the right parent node, getting its list of child nodes and adding the node in the right place, then calling Node::SetChildNodes @param name The name of the node @param nodeType The type of the node. Valid types are: <ul> <li>paintlayer <li>grouplayer <li>filelayer <li>filterlayer <li>filllayer <li>clonelayer <li>vectorlayer <li>transparencymask <li>filtermask <li>transformmask <li>selectionmask </ul> When relevant, the new Node will have the colorspace of the image by default; that can be changed with Node::setColorSpace. The settings and selections for relevant layer and mask types can also be set after the Node has been created.
- Returns
- the new Node.
Definition at line 601 of file Document.cpp.
◆ createSelectionMask
|
slot |
createSelectionMask Creates a selection mask, which can be used to store selections.
- Parameters
-
name - the name of the layer.
- Returns
- a SelectionMask
Definition at line 751 of file Document.cpp.
◆ createTransformMask
|
slot |
createTransformMask Creates a transform mask, which can be used to apply a transformation non-destructively.
- Parameters
-
name - the name of the layer mask.
- Returns
- a TransformMask
Definition at line 769 of file Document.cpp.
◆ createTransparencyMask
|
slot |
createTransparencyMask Creates a transparency mask, which can be used to assign transparency to regions.
- Parameters
-
name - the name of the layer.
- Returns
- a TransparencyMask
Definition at line 760 of file Document.cpp.
◆ createVectorLayer
|
slot |
createVectorLayer Creates a vector layer that can contain vector shapes.
- Parameters
-
name the name of this layer.
- Returns
- a VectorLayer.
Definition at line 705 of file Document.cpp.
◆ crop
|
slot |
crop the image to rectangle described by x
, y
, w
and h
- Parameters
-
x x coordinate of the top left corner y y coordinate of the top left corner w width h height
Definition at line 497 of file Document.cpp.
◆ currentTime
|
slot |
get current frame selected of animation
- Returns
- current frame selected of animation
Definition at line 1059 of file Document.cpp.
◆ documentInfo
|
slot |
documentInfo creates and XML document representing document and author information.
- Returns
- a string containing a valid XML document with the right information about the document and author. The DTD can be found here:
https://phabricator.kde.org/source/krita/browse/master/krita/dtd/
Definition at line 245 of file Document.cpp.
◆ exportImage
|
slot |
exportImage export the image, without changing its URL to the given path.
- Parameters
-
filename the full path to which the image is to be saved exportConfiguration a configuration object appropriate to the file format. An InfoObject will used to that configuration.
The supported formats have specific configurations that must be used when in batchmode. They are described below:
png
- alpha: bool (True or False)
- compression: int (1 to 9)
- forceSRGB: bool (True or False)
- indexed: bool (True or False)
- interlaced: bool (True or False)
- saveSRGBProfile: bool (True or False)
- transparencyFillcolor: rgb (Ex:[255,255,255])
jpeg
- baseline: bool (True or False)
- exif: bool (True or False)
- filters: bool (['ToolInfo', 'Anonymizer'])
- forceSRGB: bool (True or False)
- iptc: bool (True or False)
- is_sRGB: bool (True or False)
- optimize: bool (True or False)
- progressive: bool (True or False)
- quality: int (0 to 100)
- saveProfile: bool (True or False)
- smoothing: int (0 to 100)
- subsampling: int (0 to 3)
- transparencyFillcolor: rgb (Ex:[255,255,255])
- xmp: bool (True or False)
- Returns
- true if the export succeeded, false if it failed.
Definition at line 507 of file Document.cpp.
◆ fileName
|
slot |
- Returns
- the full path to the document, if it has been set.
Definition at line 263 of file Document.cpp.
◆ flatten
|
slot |
flatten all layers in the image
Definition at line 517 of file Document.cpp.
◆ framesPerSecond
|
slot |
frames per second of document
- Returns
- the fps of the document
Definition at line 975 of file Document.cpp.
◆ fullClipRangeEndTime
|
slot |
get the full clip range end time
- Returns
- full clip range end time
Definition at line 1018 of file Document.cpp.
◆ fullClipRangeStartTime
|
slot |
get the full clip range start time
- Returns
- full clip range start time
Definition at line 1000 of file Document.cpp.
◆ guidesLocked()
bool Document::guidesLocked | ( | ) | const |
guidesLocked Returns guide lockedness.
- Returns
- whether the guides are locked.
Definition at line 865 of file Document.cpp.
◆ guidesVisible()
bool Document::guidesVisible | ( | ) | const |
guidesVisible Returns guide visibility.
- Returns
- whether the guides are visible.
Definition at line 860 of file Document.cpp.
◆ height
|
slot |
- Returns
- the height of the image in pixels
Definition at line 277 of file Document.cpp.
◆ horizontalGuides()
QList< qreal > Document::horizontalGuides | ( | ) | const |
horizontalGuides The horizontal guides.
- Returns
- a list of the horizontal positions of guides.
Definition at line 830 of file Document.cpp.
◆ importAnimation
Import an image sequence of files from a directory.
This will grab all images from the directory and import them with a potential offset (firstFrame) and step (images on 2s, 3s, etc)
- Returns
- whether the animation import was successful
Definition at line 960 of file Document.cpp.
◆ lock
|
slot |
[low-level] Lock the image without waiting for all the internal job queues are processed
WARNING: Don't use it unless you really know what you are doing! Use barrierLock() instead!
Waits for all the currently running internal jobs to complete and locks the image for writing. Please note that this function does not wait for all the internal queues to process, so there might be some non-finished actions pending. It means that you just postpone these actions until you unlock() the image back. Until then, then image might easily be frozen in some inconsistent state.
The only sane usage for this function is to lock the image for emergency processing, when some internal action or scheduler got hung up, and you just want to fetch some data from the image without races.
In all other cases, please use barrierLock() instead!
Definition at line 800 of file Document.cpp.
◆ modified
|
slot |
modified returns true if the document has unsaved modifications.
Definition at line 930 of file Document.cpp.
◆ name
|
slot |
- Returns
- the name of the document. This is the title field in the documentInfo
Definition at line 296 of file Document.cpp.
◆ nodeByName
nodeByName searches the node tree for a node with the given name and returns it
- Parameters
-
name the name of the node
- Returns
- the first node with the given name or 0 if no node is found
Definition at line 157 of file Document.cpp.
◆ nodeByUniqueID
nodeByUniqueID searches the node tree for a node with the given name and returns it.
- Parameters
-
uuid the unique id of the node
- Returns
- the node with the given unique id, or 0 if no node is found.
Definition at line 167 of file Document.cpp.
◆ operator!=()
Definition at line 98 of file Document.cpp.
◆ operator==()
bool Document::operator== | ( | const Document & | other | ) | const |
Definition at line 93 of file Document.cpp.
◆ pixelData
|
slot |
pixelData reads the given rectangle from the image projection and returns it as a byte array.
The pixel data starts top-left, and is ordered row-first.
The byte array can be interpreted as follows: 8 bits images have one byte per channel, and as many bytes as there are channels. 16 bits integer images have two bytes per channel, representing an unsigned short. 16 bits float images have two bytes per channel, representing a half, or 16 bits float. 32 bits float images have four bytes per channel, representing a float.
You can read outside the image boundaries; those pixels will be transparent black.
The order of channels is:
- Integer RGBA: Blue, Green, Red, Alpha
- Float RGBA: Red, Green, Blue, Alpha
- LabA: L, a, b, Alpha
- CMYKA: Cyan, Magenta, Yellow, Key, Alpha
- XYZA: X, Y, Z, A
- YCbCrA: Y, Cb, Cr, Alpha
The byte array is a copy of the original image data. In Python, you can use bytes, bytearray and the struct module to interpret the data and construct, for instance, a Pillow Image object.
- Parameters
-
x x position from where to start reading y y position from where to start reading w row length to read h number of rows to read
- Returns
- a QByteArray with the pixel data. The byte array may be empty.
Definition at line 460 of file Document.cpp.
◆ playBackEndTime
|
slot |
get end time of current playback
- Returns
- end time of current playback
Definition at line 1051 of file Document.cpp.
◆ playBackStartTime
|
slot |
get start time of current playback
- Returns
- start time of current playback
Definition at line 1043 of file Document.cpp.
◆ projection
|
slot |
projection creates a QImage from the rendered image or a cutout rectangle.
Definition at line 787 of file Document.cpp.
◆ refreshProjection
|
slot |
Starts a synchronous recomposition of the projection: everything will wait until the image is fully recomputed.
Definition at line 824 of file Document.cpp.
◆ removeAnnotation
removeAnnotation remove the specified annotation from the image
- Parameters
-
type the type defining the annotation
Definition at line 1129 of file Document.cpp.
◆ resizeImage
|
slot |
resizeImage resizes the canvas to the given left edge, top edge, width and height.
Note: This doesn't scale, use scale image for that.
- Parameters
-
x the new left edge y the new top edge w the new width h the new height
Definition at line 525 of file Document.cpp.
◆ resolution
|
slot |
- Returns
- the resolution in pixels per inch
Definition at line 309 of file Document.cpp.
◆ rootNode
|
slot |
rootNode the root node is the invisible group layer that contains the entire node hierarchy.
- Returns
- the root of the image
Definition at line 332 of file Document.cpp.
◆ rotateImage
|
slot |
rotateImage Rotate the image by the given radians.
- Parameters
-
radians the amount you wish to rotate the image in radians
Definition at line 556 of file Document.cpp.
◆ save
|
slot |
save the image to its currently set path.
The modified flag of the document will be reset
- Returns
- true if saving succeeded, false otherwise.
Definition at line 574 of file Document.cpp.
◆ saveAs
saveAs save the document under the filename
.
The document's filename will be reset to filename
.
- Parameters
-
filename the new filename (full path) for the document
- Returns
- true if saving succeeded, false otherwise.
Definition at line 585 of file Document.cpp.
◆ scaleImage
scaleImage
- Parameters
-
w the new width h the new height xres the new xres yres the new yres strategy the scaling strategy. There's several ones amongst these that aren't available in the regular UI. The list of filters is extensible and can be retrieved with Krita::filter - Hermite
- Bicubic - Adds pixels using the color of surrounding pixels. Produces smoother tonal gradations than Bilinear.
- Box - Replicate pixels in the image. Preserves all the original detail, but can produce jagged effects.
- Bilinear - Adds pixels averaging the color values of surrounding pixels. Produces medium quality results when the image is scaled from half to two times the original size.
- Bell
- BSpline
- Kanczos3 - Offers similar results than Bicubic, but maybe a little bit sharper. Can produce light and dark halos along strong edges.
- Mitchell
Definition at line 540 of file Document.cpp.
◆ selection
|
slot |
selection Create a Selection object around the global selection, if there is one.
- Returns
- the global selection or None if there is no global selection.
Definition at line 341 of file Document.cpp.
◆ setActiveNode
setActiveNode make the given node active in the currently active view and window
- Parameters
-
value the node to make active.
Definition at line 132 of file Document.cpp.
◆ setAnnotation
|
slot |
setAnnotation Add the given annotation to the document
- Parameters
-
type the unique type of the annotation description the user-visible description of the annotation annotation the annotation itself
Definition at line 1121 of file Document.cpp.
◆ setBackgroundColor
setBackgroundColor sets the background color of the document.
It will trigger a projection update.
- Parameters
-
color A QColor. The color will be converted from sRGB.
- Returns
- bool
Definition at line 231 of file Document.cpp.
◆ setBatchmode
|
slot |
Set batchmode to value
.
If batchmode is true, then there should be no popups or dialogs shown to the user.
Definition at line 109 of file Document.cpp.
◆ setColorProfile
setColorProfile set the color profile of the image to the given profile.
The profile has to be registered with krita and be compatible with the current color model and depth; the image data is not converted.
- Parameters
-
colorProfile
- Returns
- false if the colorProfile name does not correspond to to a registered profile or if assigning the profile failed.
Definition at line 196 of file Document.cpp.
◆ setColorSpace
|
slot |
setColorSpace convert the nodes and the image to the given colorspace.
The conversion is done with Perceptual as intent, High Quality and No LCMS Optimizations as flags and no blackpoint compensation.
- Parameters
-
colorModel A string describing the color model of the image: - A: Alpha mask
- RGBA: RGB with alpha channel (The actual order of channels is most often BGR!)
- XYZA: XYZ with alpha channel
- LABA: LAB with alpha channel
- CMYKA: CMYK with alpha channel
- GRAYA: Gray with alpha channel
- YCbCrA: YCbCr with alpha channel
colorDepth A string describing the color depth of the image: - U8: unsigned 8 bits integer, the most common type
- U16: unsigned 16 bits integer
- F16: half, 16 bits floating point. Only available if Krita was built with OpenEXR
- F32: 32 bits floating point
colorProfile a valid color profile for this color model and color depth combination.
- Returns
- false the combination of these arguments does not correspond to a colorspace.
Definition at line 207 of file Document.cpp.
◆ setCurrentTime
|
slot |
set current time of document's animation
Definition at line 1067 of file Document.cpp.
◆ setDocumentInfo
setDocumentInfo set the Document information to the information contained in document
- Parameters
-
document A string containing a valid XML document that conforms to the document-info DTD that can be found here:
https://phabricator.kde.org/source/krita/browse/master/krita/dtd/
Definition at line 253 of file Document.cpp.
◆ setFileName
setFileName set the full path of the document to
- Parameters
-
value
Definition at line 269 of file Document.cpp.
◆ setFramesPerSecond
|
slot |
set frames per second of document
Definition at line 983 of file Document.cpp.
◆ setFullClipRangeEndTime
|
slot |
set full clip range end time
Definition at line 1009 of file Document.cpp.
◆ setFullClipRangeStartTime
|
slot |
set start time of animation
Definition at line 991 of file Document.cpp.
◆ setGuidesLocked
|
slot |
setGuidesLocked set guides locked on this document
- Parameters
-
locked whether or not to lock the guides on this document.
Definition at line 922 of file Document.cpp.
◆ setGuidesVisible
|
slot |
setGuidesVisible set guides visible on this document.
- Parameters
-
visible whether or not the guides are visible.
Definition at line 914 of file Document.cpp.
◆ setHeight
|
slot |
setHeight resize the document to
- Parameters
-
value height. This is a canvas resize, not a scale.
Definition at line 285 of file Document.cpp.
◆ setHorizontalGuides
setHorizontalGuides replace all existing horizontal guides with the entries in the list.
- Parameters
-
lines a list of floats containing the new guides.
Definition at line 882 of file Document.cpp.
◆ setModified
|
slot |
setModified sets the modified status of the document
- Parameters
-
modified if true, the document is considered modified and closing it will ask for saving.
Definition at line 936 of file Document.cpp.
◆ setName
setName sets the name of the document to value
.
This is the title field in the documentInfo
Definition at line 302 of file Document.cpp.
◆ setPlayBackRange
|
slot |
set temporary playback range of document
Definition at line 1034 of file Document.cpp.
◆ setResolution
|
slot |
setResolution set the resolution of the image; this does not scale the image
- Parameters
-
value the resolution in pixels per inch
Definition at line 318 of file Document.cpp.
◆ setSelection
setSelection set or replace the global selection
- Parameters
-
value a valid selection object.
Definition at line 349 of file Document.cpp.
◆ setVerticalGuides
setVerticalGuides replace all existing horizontal guides with the entries in the list.
- Parameters
-
lines a list of floats containing the new guides.
Definition at line 898 of file Document.cpp.
◆ setWidth
|
slot |
setWidth resize the document to
- Parameters
-
value width. This is a canvas resize, not a scale.
Definition at line 370 of file Document.cpp.
◆ setXOffset
|
slot |
setXOffset sets the left edge of the canvas to x
.
Definition at line 389 of file Document.cpp.
◆ setXRes
|
slot |
setXRes set the horizontal resolution of the image to xRes in pixels per inch
Definition at line 426 of file Document.cpp.
◆ setYOffset
|
slot |
setYOffset sets the top edge of the canvas to y
.
Definition at line 408 of file Document.cpp.
◆ setYRes
|
slot |
setYRes set the vertical resolution of the image to yRes in pixels per inch
Definition at line 446 of file Document.cpp.
◆ shearImage
|
slot |
shearImage shear the whole image.
- Parameters
-
angleX the X-angle in degrees to shear by angleY the Y-angle in degrees to shear by
Definition at line 565 of file Document.cpp.
◆ thumbnail
|
slot |
thumbnail create a thumbnail of the given dimensions.
If the requested size is too big a null QImage is created.
- Returns
- a QImage representing the layer contents.
Definition at line 793 of file Document.cpp.
◆ topLevelNodes
toplevelNodes return a list with all top level nodes in the image graph
Definition at line 149 of file Document.cpp.
◆ tryBarrierLock
|
slot |
Tries to lock the image without waiting for the jobs to finish.
Same as barrierLock(), but doesn't block execution of the calling thread until all the background jobs are finished. Instead, in case of presence of unfinished jobs in the queue, it just returns false
- Returns
- whether the lock has been acquired
Definition at line 818 of file Document.cpp.
◆ unlock
|
slot |
Unlocks the image and starts/resumes all the pending internal jobs.
If the image has been locked for a non-readOnly access, then all the internal caches of the image (e.g. lod-planes) are reset and regeneration jobs are scheduled.
Definition at line 806 of file Document.cpp.
◆ verticalGuides()
QList< qreal > Document::verticalGuides | ( | ) | const |
verticalGuides The vertical guide lines.
- Returns
- a list of vertical guides.
Definition at line 845 of file Document.cpp.
◆ waitForDone
|
slot |
Wait for all the internal image jobs to complete and return without locking the image.
This function is handy for tests or other synchronous actions, when one needs to wait for the result of his actions.
Definition at line 812 of file Document.cpp.
◆ width
|
slot |
- Returns
- the width of the image in pixels.
Definition at line 362 of file Document.cpp.
◆ xOffset
|
slot |
- Returns
- the left edge of the canvas in pixels.
Definition at line 381 of file Document.cpp.
◆ xRes
|
slot |
- Returns
- xRes the horizontal resolution of the image in pixels per inch
Definition at line 419 of file Document.cpp.
◆ yOffset
|
slot |
- Returns
- the top edge of the canvas in pixels.
Definition at line 400 of file Document.cpp.
◆ yRes
|
slot |
- Returns
- yRes the vertical resolution of the image in pixels per inch
Definition at line 439 of file Document.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:53 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.