23#include "kis_painter.h"
26#include "kis_paintop.h"
27#include "kis_alpha_mask.h"
29#include "kis_colorspace.h"
30#include "kis_global.h"
31#include "kis_iterators_pixel.h"
38 setSource(painter->
device());
41KisPaintOp::~KisPaintOp()
45KisPaintDeviceSP KisPaintOp::computeDab(KisAlphaMaskSP mask) {
46 return computeDab(mask, m_painter->device()->colorSpace());
49KisPaintDeviceSP KisPaintOp::computeDab(KisAlphaMaskSP mask,
KisColorSpace *cs)
58 if(!m_dab || m_dab->colorSpace() != cs)
59 m_dab =
new KisPaintDevice(cs,
"dab");
62 KisColor kc = m_painter->paintColor();
64 KisColorSpace * colorSpace = m_dab->colorSpace();
66 TQ_INT32 pixelSize = colorSpace->
pixelSize();
68 TQ_INT32 maskWidth = mask->width();
69 TQ_INT32 maskHeight = mask->height();
74 KisHLineIteratorPixel hiter = m_dab->createHLineIterator(0, 0, maskWidth,
true);
75 for (
int y = 0; y < maskHeight; y++)
78 while(! hiter.isDone())
81 colorSpace->
setAlpha(kc.
data(), mask->alphaAt(x++, y), 1);
82 memcpy(hiter.rawData(), kc.
data(), pixelSize);
91void KisPaintOp::splitCoordinate(
double coordinate, TQ_INT32 *whole,
double *fraction)
93 TQ_INT32 i =
static_cast<TQ_INT32
>(coordinate);
101 double f = coordinate - i;
107void KisPaintOp::setSource(KisPaintDeviceSP p) {
A colorspace is the definition of a certain color model in Chalk.
virtual TQ_UINT32 pixelSize() const =0
The size in bytes of a single pixel in this color model.
virtual void setAlpha(TQ_UINT8 *pixels, TQ_UINT8 alpha, TQ_INT32 nPixels) const =0
Set the alpha channel of the given run of pixels to the given value.
void convertTo(KisColorSpace *cs)
Convert this KisColor to the specified colorspace.
TQ_UINT8 * data() const
For easy memcpy'ing etc.
virtual KisPaintOpSettings * settings(TQWidget *parent, const KisInputDevice &inputDevice)
Create and return an (abstracted) widget with options for this paintop when used with the specified i...
KisPainter contains the graphics primitives necessary to draw on a KisPaintDevice.
KisPaintDeviceSP device() const
Returns the current paint device.