Two Krita technical questions at
Tue Jun 22 15:49:21 CEST 2010

On Tuesday, June 22, 2010 15:30:02 JL VT wrote:
> First of all sorry if the questions had obvious answers, they're not
> so obvious to me!.
> Question(s) one, for the Scratch Off algorithm:
> I have a paintop, and want to store image data in a place where: 1.-
> it is invisible to the user  2.- survives the destruction and
> reinvocation of the paintop.
> std::clog tells me that paintops are created when the user presses
> down the mouse button, and destroyed when he releases it. That leads
> me to think that anything I create inside the paintop won't survive
> till the next creation-destruction cycle, but maybe I'm missing
> something.
> I want to know: how can I achieve (1) and (2)?. If there's a place in
> the code where someone does something similar, just point me to that
> file, I can learn from it. Or tell me what classes to use or roughly
> what's the principle of what to do with them (i.e.: if you use this,
> it will survive the paintop destruction, just be sure to erase it when
> you stop using it or it will leak memory).
> If there's more than one way to do it(tm), please point me to the most
> "orthodox" or most "desirable" way to do it. I already refactored my
> code and prefer to keep it clean and shiny.

So far there isn't any clear&shiny solution I know. 

You might try luck with kis_duplicateop_settings.cpp - it stores 
position of the alt+click so maybe solution in this way could work.
> Question(s) two, for general hatching:
> I have a hatching KisBrushBasedPaintOp. I have a nice BrushTip
> dialogue, that gives me a bitmap with a pre-made dab.
> What I don't have is an idea of how to use that dab as a transparency
> mask for my hatching.
> My idea is to first hatch a little paint device just like I'm doing
> now --let's call it "DabHatch"--, then to access the mask stored in
> m_brush (the one we customize in the BrushTip popup dialogue) --let's
> call it "DabMask"--, and use it to determine the transparency of
> pixels in "DabHatch", creating a new image ready to be potato-stamped
> on the image, let's call it "DabHappiness". The creation of
> DabHappiness should follow these rules:
> --Assume opacity can be represented with a number ranging from 0 to 1,
> where 0 is "transparent" and 1 is "opaque". Then...
> --opacity_of_pixels_in_DabHappiness = opacity_of_pixels_in_DabHatch *
> opacity_of_pixels_in_DabMask
> How can I do that?, is there a command?, an easily accessible method?.
> Please, just like in the last question, point me to a file where it is
> done if it is already done in a file; otherwise show me the principle
> and the classes used to do it, and let me know what's the most
> "orthodox" and "desirable" way to do it.

Check kis_smudgeop.cpp

dab is converted to alpha mask 8 colorspace which is used as selection when 
bitBlt and the selection is doing something like you describe.

> Thank you very much for your time.
> PS: I assumed Lukas wouldn't want answers like this to go to waste so
> I went forward and asked here for the answer to be publicly stored  :]

I'm cool with this, I'm slowly building tutorial 
on wiki based on your questions.

More information about the kimageshop mailing list