PaintOp and accessing pixels

Boudewijn Rempt boud at
Fri Oct 17 09:32:43 CEST 2008

On Thursday 16 October 2008, at wrote:
> Hello,
> I started to develop deform paintop (something like iWrap in gimp) and I
> got problems with accessing pixels from current node.
> The brush deform image with inverse wrapping, it just move with pixels
> and should produce fun results from photos. I have implemented it these
> days in OpenCV,
> so I decided to implement it like a brush in Krita. I respect feature
> freeze.

It's fine if you commit your work, as long as it isn't compiled by default.

> But how do i access that pixels?
> The actual status is that e.g. my hairy brush is trying to access pixels
> from layer using
> painter->device() method which is invoked inside paintLine in
> kis_sumiebrush
> The results are two:
> a) Paint incrementaly in GUI not checked
> Brush produce just black pixels which are bitblt on the layer -- I
> suppose, that no pixels are read from layer and I don't know why
> the color of hairs is black.
> b) Paint incrementaly checked in GUI
> Brush (when paint in brush.cpp uses mixCMYK) access just pixels that has
> already painted through the one stroke and is able to mix them together.

The paint incrementally checkbox in the tool palette will be removed Really 
Soon Now -- there is already an option ready for use in the paintops, I just
need to move some code from kislayer to kisnode to make it work. Would have 
done that during the dev days, but I had to fix a rather nasty bug with 
painting that only showed up when compiling with -O2 first. So this difference 
is a non-issue for you: your paintop just shouldn't include this option.

> Now I investigate sources and I was trying to do this:
> I'm painting with method myPaint(KisPaintDeviceSP dab, KisPaintDeviceSP
> layer, KisInfo...)
> I created two random accessors, one used for reading (random accessor
> for layer) and one for writing (random accessor for dab).
> The result is that when i use layer as painter->device(), I don't get
> access to pixels in current layer...
> I was trying to use KisPaintOpSettings::node(), but that returns
> KisNodeSP. What is KisNode used for?

Look at the inheritance hierarchy: KisNode is a base class for KisLayer and 
KisMask. Since it should be possible to paint on masks, too, you get a node, 
not a layer.

> I also found currentNode()->paintDevice() in freehand tool . I was not
> able to understand how do I send it to my paintOp...

You can use paintopsettings->node->paintdevice, of course.

Boudewijn Rempt |

More information about the kimageshop mailing list