krita

KisPaintDevice Class Reference

#include <kis_paint_device.h>

Inheritance diagram for KisPaintDevice:

KisSelection

List of all members.


Detailed Description

A paint device contains the actual pixel data and offers methods to read and write pixels.

A paint device has an integer x,y position (i.e., are not positioned on the image with sub-pixel accuracy). A KisPaintDevice doesn't have any fixed size, the size change dynamicaly when pixels are accessed by an iterator.

Definition at line 73 of file kis_paint_device.h.


Signals

void positionChanged (KisPaintDeviceSP device)
void ioProgress (Q_INT8 percentage)
void profileChanged (KisProfile *profile)

Public Member Functions

 KisPaintDevice (KisColorSpace *colorSpace, const char *name=0)
 KisPaintDevice (KisLayer *parentLayer, KisColorSpace *colorSpace, const char *name=0)
 KisPaintDevice (const KisPaintDevice &rhs)
virtual DCOPObject * dcopObject ()
void lock (bool lock)
virtual bool write (KoStore *store)
virtual bool read (KoStore *store)
virtual void move (Q_INT32 x, Q_INT32 y)
virtual void move (const QPoint &pt)
virtual KNamedCommand * moveCommand (Q_INT32 x, Q_INT32 y)
bool contains (Q_INT32 x, Q_INT32 y) const
bool contains (const QPoint &pt) const
virtual void extent (Q_INT32 &x, Q_INT32 &y, Q_INT32 &w, Q_INT32 &h) const
virtual QRect extent () const
bool extentIsValid () const
void setExtentIsValid (bool isValid)
virtual void exactBounds (Q_INT32 &x, Q_INT32 &y, Q_INT32 &w, Q_INT32 &h) const
virtual QRect exactBounds () const
virtual QRect exactBoundsOldMethod () const
virtual QRect exactBoundsImprovedOldMethod () const
void crop (Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h)
void crop (QRect r)
virtual void clear ()
void fill (Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h, const Q_UINT8 *fillPixel)
virtual void readBytes (Q_UINT8 *data, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h)
virtual void writeBytes (const Q_UINT8 *data, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h)
Q_INT32 numContiguousColumns (Q_INT32 x, Q_INT32 minY, Q_INT32 maxY)
Q_INT32 numContiguousRows (Q_INT32 y, Q_INT32 minX, Q_INT32 maxX)
Q_INT32 rowStride (Q_INT32 x, Q_INT32 y)
KDE_DEPRECATED const Q_UINT8 * pixel (Q_INT32 x, Q_INT32 y)
KDE_DEPRECATED Q_UINT8 * writablePixel (Q_INT32 x, Q_INT32 y)
virtual void convertTo (KisColorSpace *dstColorSpace, Q_INT32 renderingIntent=INTENT_PERCEPTUAL)
virtual void setProfile (KisProfile *profile)
virtual void convertFromQImage (const QImage &img, const QString &srcProfileName, Q_INT32 offsetX=0, Q_INT32 offsetY=0)
virtual QImage convertToQImage (KisProfile *dstProfile, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h, float exposure=0.0f)
virtual QImage convertToQImage (KisProfile *dstProfile, float exposure=0.0f)
KisPaintDeviceSP createThumbnailDevice (Q_INT32 w, Q_INT32 h)
virtual QImage createThumbnail (Q_INT32 maxw, Q_INT32 maxh)
bool pixel (Q_INT32 x, Q_INT32 y, QColor *c, Q_UINT8 *opacity)
bool pixel (Q_INT32 x, Q_INT32 y, KisColor *kc)
KisColor colorAt (Q_INT32 x, Q_INT32 y)
bool setPixel (Q_INT32 x, Q_INT32 y, const QColor &c, Q_UINT8 opacity)
bool setPixel (Q_INT32 x, Q_INT32 y, const KisColor &kc)
KisColorSpacecolorSpace () const
KisDataManagerSP dataManager () const
void setData (KisDataManagerSP data, KisColorSpace *colorSpace)
Q_INT32 getX () const
Q_INT32 getY () const
void setX (Q_INT32 x)
void setY (Q_INT32 y)
virtual Q_INT32 pixelSize () const
virtual Q_INT32 nChannels () const
KisImage * image () const
KisLayerparentLayer () const
void setParentLayer (KisLayer *parentLayer)
virtual void setDirty (const QRect &rc)
virtual void setDirty ()
void mirrorX ()
void mirrorY ()
KisMementoSP getMemento ()
void rollback (KisMementoSP memento)
void rollforward (KisMementoSP memento)
KisRectIteratorPixel createRectIterator (Q_INT32 left, Q_INT32 top, Q_INT32 w, Q_INT32 h, bool writable)
KisHLineIteratorPixel createHLineIterator (Q_INT32 x, Q_INT32 y, Q_INT32 w, bool writable)
KisVLineIteratorPixel createVLineIterator (Q_INT32 x, Q_INT32 y, Q_INT32 h, bool writable)
KisRandomAccessorPixel createRandomAccessor (Q_INT32 x, Q_INT32 y, bool writable)
KisRandomSubAccessorPixel createRandomSubAccessor ()
KisSelectionSP selection ()
void addSelection (KisSelectionSP selection)
void subtractSelection (KisSelectionSP selection)
bool hasSelection ()
bool selectionDeselected ()
void deselect ()
void reselect ()
void clearSelection ()
void applySelectionMask (KisSelectionSP mask)
KisSelectionSP setSelection (KisSelectionSP selection)
void emitSelectionChanged ()
void emitSelectionChanged (const QRect &r)
KisUndoAdapter * undoAdapter () const
KisExifInfo * exifInfo ()
bool hasExifInfo ()

Protected Attributes

KisDataManagerSP m_datamanager

Constructor & Destructor Documentation

KisPaintDevice::KisPaintDevice ( KisColorSpace colorSpace,
const char *  name = 0 
)

Create a new paint device with the specified colorspace.

Parameters:
colorSpace the colorspace of this paint device
name for debugging purposes

Definition at line 204 of file kis_paint_device.cc.

KisPaintDevice::KisPaintDevice ( KisLayer parentLayer,
KisColorSpace colorSpace,
const char *  name = 0 
)

Create a new paint device with the specified colorspace.

The parentLayer will be notified of changes to this paint device.

Parameters:
parentLayer the layer that contains this paint device.
colorSpace the colorspace of this paint device
name for debugging purposes

Definition at line 239 of file kis_paint_device.cc.


Member Function Documentation

bool KisPaintDevice::write ( KoStore *  store  )  [virtual]

Write the pixels of this paint device into the specified file store.

Definition at line 700 of file kis_paint_device.cc.

bool KisPaintDevice::read ( KoStore *  store  )  [virtual]

Fill this paint device with the pixels from the specified file store.

Definition at line 708 of file kis_paint_device.cc.

void KisPaintDevice::move ( Q_INT32  x,
Q_INT32  y 
) [virtual]

Moves the device to these new coordinates (so no incremental move or so).

Definition at line 376 of file kis_paint_device.cc.

void KisPaintDevice::move ( const QPoint &  pt  )  [virtual]

Convenience method for the above.

Definition at line 396 of file kis_paint_device.cc.

KNamedCommand * KisPaintDevice::moveCommand ( Q_INT32  x,
Q_INT32  y 
) [virtual]

Move the paint device to the specified location and make it possible to undo the move.

Definition at line 401 of file kis_paint_device.cc.

bool KisPaintDevice::contains ( Q_INT32  x,
Q_INT32  y 
) const

Returns true of x,y is within the extent of this paint device.

bool KisPaintDevice::contains ( const QPoint &  pt  )  const

Convenience method for the above.

void KisPaintDevice::extent ( Q_INT32 &  x,
Q_INT32 &  y,
Q_INT32 &  w,
Q_INT32 &  h 
) const [virtual]

Retrieve the bounds of the paint device.

The size is not exact, but may be larger if the underlying datamanager works that way. For instance, the tiled datamanager keeps the extent to the nearest multiple of 64.

Definition at line 409 of file kis_paint_device.cc.

bool KisPaintDevice::extentIsValid (  )  const

XXX: This should be a temporay hack, awaiting a proper fix.

Indicates whether the extent really represents the extent. For example, the KisBackground checkerboard pattern is generated by filling the default tile but it will return an empty extent.

Definition at line 423 of file kis_paint_device.cc.

void KisPaintDevice::setExtentIsValid ( bool  isValid  ) 

Convience method for the above.

Definition at line 428 of file kis_paint_device.cc.

void KisPaintDevice::exactBounds ( Q_INT32 &  x,
Q_INT32 &  y,
Q_INT32 &  w,
Q_INT32 &  h 
) const [virtual]

Get the exact bounds of this paint device.

This may be very slow, especially on larger paint devices because it does a linear scanline search.

Definition at line 433 of file kis_paint_device.cc.

void KisPaintDevice::crop ( Q_INT32  x,
Q_INT32  y,
Q_INT32  w,
Q_INT32  h 
)

Cut the paint device down to the specified rect.

Definition at line 610 of file kis_paint_device.cc.

void KisPaintDevice::crop ( QRect  r  ) 

Convience method for the above.

Definition at line 616 of file kis_paint_device.cc.

void KisPaintDevice::clear (  )  [virtual]

Complete erase the current paint device.

Its size will become 0.

Reimplemented in KisSelection.

Definition at line 621 of file kis_paint_device.cc.

void KisPaintDevice::fill ( Q_INT32  x,
Q_INT32  y,
Q_INT32  w,
Q_INT32  h,
const Q_UINT8 *  fillPixel 
)

Fill the given rectangle with the given pixel.

Definition at line 626 of file kis_paint_device.cc.

void KisPaintDevice::readBytes ( Q_UINT8 *  data,
Q_INT32  x,
Q_INT32  y,
Q_INT32  w,
Q_INT32  h 
) [virtual]

Read the bytes representing the rectangle described by x, y, w, h into data.

If data is not big enough, Krita will gladly overwrite the rest of your precious memory.

Since this is a copy, you need to make sure you have enough memory.

Reading from areas not previously initialized will read the default pixel value into data but not initialize that region.

Definition at line 1243 of file kis_paint_device.cc.

void KisPaintDevice::writeBytes ( const Q_UINT8 *  data,
Q_INT32  x,
Q_INT32  y,
Q_INT32  w,
Q_INT32  h 
) [virtual]

Copy the bytes in data into the rect specified by x, y, w, h.

If the data is too small or uninitialized, Krita will happily read parts of memory you never wanted to be read.

If the data is written to areas of the paint device not previously initialized, the paint device will grow.

Definition at line 1248 of file kis_paint_device.cc.

Q_INT32 KisPaintDevice::numContiguousColumns ( Q_INT32  x,
Q_INT32  minY,
Q_INT32  maxY 
)

Get the number of contiguous columns starting at x, valid for all values of y between minY and maxY.

Definition at line 1203 of file kis_paint_device.cc.

Q_INT32 KisPaintDevice::numContiguousRows ( Q_INT32  y,
Q_INT32  minX,
Q_INT32  maxX 
)

Get the number of contiguous rows starting at y, valid for all values of x between minX and maxX.

Definition at line 1208 of file kis_paint_device.cc.

Q_INT32 KisPaintDevice::rowStride ( Q_INT32  x,
Q_INT32  y 
)

Get the row stride at pixel (x, y).

This is the number of bytes to add to a pointer to pixel (x, y) to access (x, y + 1).

Definition at line 1213 of file kis_paint_device.cc.

const Q_UINT8 * KisPaintDevice::pixel ( Q_INT32  x,
Q_INT32  y 
)

Get a read-only pointer to pixel (x, y).

Definition at line 1218 of file kis_paint_device.cc.

Q_UINT8 * KisPaintDevice::writablePixel ( Q_INT32  x,
Q_INT32  y 
)

Get a read-write pointer to pixel (x, y).

Definition at line 1223 of file kis_paint_device.cc.

void KisPaintDevice::convertTo ( KisColorSpace dstColorSpace,
Q_INT32  renderingIntent = INTENT_PERCEPTUAL 
) [virtual]

Converts the paint device to a different colorspace.

Definition at line 716 of file kis_paint_device.cc.

void KisPaintDevice::setProfile ( KisProfile *  profile  )  [virtual]

Changes the profile of the colorspace of this paint device to the given profile.

If the given profile is 0, nothing happens.

Definition at line 771 of file kis_paint_device.cc.

void KisPaintDevice::convertFromQImage ( const QImage &  img,
const QString &  srcProfileName,
Q_INT32  offsetX = 0,
Q_INT32  offsetY = 0 
) [virtual]

Fill this paint device with the data from img; starting at (offsetX, offsetY).

Parameters:
srcProfileName name of the RGB profile to interpret the img as. "" is interpreted as sRGB

Definition at line 804 of file kis_paint_device.cc.

QImage KisPaintDevice::convertToQImage ( KisProfile *  dstProfile,
Q_INT32  x,
Q_INT32  y,
Q_INT32  w,
Q_INT32  h,
float  exposure = 0.0f 
) [virtual]

Create an RGBA QImage from a rectangle in the paint device.

Parameters:
x Left coordinate of the rectangle
y Top coordinate of the rectangle
w Width of the rectangle in pixels
h Height of the rectangle in pixels
dstProfile RGB profile to use in conversion. May be 0, in which case it's up to the colour strategy to choose a profile (most like sRGB).
exposure The exposure setting used to render a preview of a high dynamic range image.

Definition at line 853 of file kis_paint_device.cc.

QImage KisPaintDevice::convertToQImage ( KisProfile *  dstProfile,
float  exposure = 0.0f 
) [virtual]

Create an RGBA QImage from a rectangle in the paint device.

The rectangle is defined by the parent image's bounds.

Parameters:
dstProfile RGB profile to use in conversion. May be 0, in which case it's up to the colour strategy to choose a profile (most like sRGB).
exposure The exposure setting used to render a preview of a high dynamic range image.

Definition at line 831 of file kis_paint_device.cc.

KisPaintDeviceSP KisPaintDevice::createThumbnailDevice ( Q_INT32  w,
Q_INT32  h 
)

Creates a paint device thumbnail of the paint device, retaining the aspect ratio.

The width and height of the returned device won't exceed maxw and maxw, but they may be smaller.

Definition at line 873 of file kis_paint_device.cc.

QImage KisPaintDevice::createThumbnail ( Q_INT32  maxw,
Q_INT32  maxh 
) [virtual]

Creates a thumbnail of the paint device, retaining the aspect ratio.

The width and height of the returned QImage won't exceed maxw and maxw, but they may be smaller. The colors are not corrected for display!

Definition at line 921 of file kis_paint_device.cc.

bool KisPaintDevice::pixel ( Q_INT32  x,
Q_INT32  y,
QColor *  c,
Q_UINT8 *  opacity 
)

Fill c and opacity with the values found at x and y.

The color values will be transformed from the profile of this paint device to the display profile.

Returns:
true if the operation was succesful.

Definition at line 1142 of file kis_paint_device.cc.

bool KisPaintDevice::pixel ( Q_INT32  x,
Q_INT32  y,
KisColor kc 
)

Fill kc with the values found at x and y.

This method differs from the above in using KisColor, which can be of any colorspace

The color values will be transformed from the profile of this paint device to the display profile.

Returns:
true if the operation was succesful.

Definition at line 1156 of file kis_paint_device.cc.

KisColor KisPaintDevice::colorAt ( Q_INT32  x,
Q_INT32  y 
)

Return the KisColor of the pixel at x,y.

Definition at line 1169 of file kis_paint_device.cc.

bool KisPaintDevice::setPixel ( Q_INT32  x,
Q_INT32  y,
const QColor &  c,
Q_UINT8  opacity 
)

Set the specified pixel to the specified color.

Note that this bypasses KisPainter. the PaintDevice is here used as an equivalent to QImage, not QPixmap. This means that this is not undoable; also, there is no compositing with an existing value at this location.

The color values will be transformed from the display profile to the paint device profile.

Note that this will use 8-bit values and may cause a significant degradation when used on 16-bit or hdr quality images.

Returns:
true if the operation was succesful

Definition at line 1176 of file kis_paint_device.cc.

void KisPaintDevice::setData ( KisDataManagerSP  data,
KisColorSpace colorSpace 
)

Replace the pixel data, color strategy, and profile.

Definition at line 783 of file kis_paint_device.cc.

Q_INT32 KisPaintDevice::getX (  )  const [inline]

The X offset of the paint device.

Definition at line 585 of file kis_paint_device.h.

Q_INT32 KisPaintDevice::getY (  )  const [inline]

The Y offset of the paint device.

Definition at line 590 of file kis_paint_device.h.

void KisPaintDevice::setX ( Q_INT32  x  ) 

Return the X offset of the paint device.

Definition at line 1228 of file kis_paint_device.cc.

void KisPaintDevice::setY ( Q_INT32  y  ) 

Return the Y offset of the paint device.

Definition at line 1235 of file kis_paint_device.cc.

Q_INT32 KisPaintDevice::pixelSize (  )  const [inline, virtual]

Return the number of bytes a pixel takes.

Definition at line 565 of file kis_paint_device.h.

Q_INT32 KisPaintDevice::nChannels (  )  const [inline, virtual]

Return the number of channels a pixel takes.

Definition at line 571 of file kis_paint_device.h.

KisImage * KisPaintDevice::image (  )  const

Return the image that contains this paint device, or 0 if it is not part of an image.

This is the same as calling parentLayer()->image().

Definition at line 366 of file kis_paint_device.cc.

KisLayer * KisPaintDevice::parentLayer (  )  const

Returns the KisLayer that contains this paint device, or 0 if this is not part of a layer.

Definition at line 346 of file kis_paint_device.cc.

void KisPaintDevice::setParentLayer ( KisLayer parentLayer  ) 

Set the KisLayer that contains this paint device, or 0 if this is not part of a layer.

Definition at line 351 of file kis_paint_device.cc.

void KisPaintDevice::setDirty ( const QRect &  rc  )  [virtual]

Add the specified rect top the parent layer (if present).

Reimplemented in KisSelection.

Definition at line 356 of file kis_paint_device.cc.

void KisPaintDevice::setDirty (  )  [virtual]

Set the parent layer completely dirty, if this paint device has one.

Reimplemented in KisSelection.

Definition at line 361 of file kis_paint_device.cc.

void KisPaintDevice::mirrorX (  ) 

Mirror the device along the X axis.

Definition at line 631 of file kis_paint_device.cc.

void KisPaintDevice::mirrorY (  ) 

Mirror the device along the Y axis.

Definition at line 661 of file kis_paint_device.cc.

KisRectIteratorPixel KisPaintDevice::createRectIterator ( Q_INT32  left,
Q_INT32  top,
Q_INT32  w,
Q_INT32  h,
bool  writable 
)

This function return an iterator which points to the first pixel of an rectangle.

Definition at line 969 of file kis_paint_device.cc.

KisHLineIteratorPixel KisPaintDevice::createHLineIterator ( Q_INT32  x,
Q_INT32  y,
Q_INT32  w,
bool  writable 
)

This function return an iterator which points to the first pixel of a horizontal line.

Definition at line 977 of file kis_paint_device.cc.

KisVLineIteratorPixel KisPaintDevice::createVLineIterator ( Q_INT32  x,
Q_INT32  y,
Q_INT32  h,
bool  writable 
)

This function return an iterator which points to the first pixel of a vertical line.

Definition at line 985 of file kis_paint_device.cc.

KisRandomAccessorPixel KisPaintDevice::createRandomAccessor ( Q_INT32  x,
Q_INT32  y,
bool  writable 
)

This function creates a random accessor which allow to randomly access any pixels on the paint device.

Note: random access is way slower than iterators, allways use iterators whenever you can

Definition at line 994 of file kis_paint_device.cc.

KisRandomSubAccessorPixel KisPaintDevice::createRandomSubAccessor (  ) 

This function create a random accessor which can easily access to sub pixel values.

Definition at line 1001 of file kis_paint_device.cc.

KisSelectionSP KisPaintDevice::selection (  ) 

Get the current selection or create one if this paintdevice hasn't got a selection yet.

Definition at line 1020 of file kis_paint_device.cc.

void KisPaintDevice::addSelection ( KisSelectionSP  selection  ) 

Adds the specified selection to the currently active selection for this paintdevice.

Definition at line 1062 of file kis_paint_device.cc.

void KisPaintDevice::subtractSelection ( KisSelectionSP  selection  ) 

Subtracts the specified selection from the currently active selection for this paindevice.

Definition at line 1070 of file kis_paint_device.cc.

bool KisPaintDevice::hasSelection (  ) 

Whether there is a valid selection for this paintdevice.

Definition at line 1037 of file kis_paint_device.cc.

bool KisPaintDevice::selectionDeselected (  ) 

Whether the previous selection was deselected.

Definition at line 1042 of file kis_paint_device.cc.

void KisPaintDevice::deselect (  ) 

Deselect the selection for this paintdevice.

Definition at line 1048 of file kis_paint_device.cc.

void KisPaintDevice::reselect (  ) 

Reinstates the old selection.

Definition at line 1056 of file kis_paint_device.cc.

void KisPaintDevice::clearSelection (  ) 

Clear the selected pixels from the paint device.

Definition at line 1081 of file kis_paint_device.cc.

void KisPaintDevice::applySelectionMask ( KisSelectionSP  mask  ) 

Apply a mask to the image data, i.e.

multiply each pixel's opacity by its selectedness in the mask.

Definition at line 1110 of file kis_paint_device.cc.

KisSelectionSP KisPaintDevice::setSelection ( KisSelectionSP  selection  ) 

Sets the selection of this paint device to the new selection, returns the old selection, if there was an old selection, otherwise 0.

Definition at line 1131 of file kis_paint_device.cc.

void KisPaintDevice::emitSelectionChanged (  ) 

Notify the owning image that the current selection has changed.

Definition at line 1006 of file kis_paint_device.cc.

void KisPaintDevice::emitSelectionChanged ( const QRect &  r  ) 

Notify the owning image that the current selection has changed.

Parameters:
r the area for which the selection has changed

Definition at line 1013 of file kis_paint_device.cc.

KisExifInfo * KisPaintDevice::exifInfo (  ) 

Return the exifInfo associated with this layer.

If no exif infos are available, the function will create it.

Definition at line 1259 of file kis_paint_device.cc.

bool KisPaintDevice::hasExifInfo (  )  [inline]

This function return true if the layer has exif info associated with it.

Definition at line 516 of file kis_paint_device.h.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys