Iterators and memory management

Adrian Page adrian at pagenet.plus.com
Mon Apr 5 17:57:55 CEST 2004


On Monday 05 April 2004 3:59 pm, Cyrille Berger wrote:
> ** Selection tools **
>
> I see two ways to store the shape of the selection :
>  - either we store it in a 2bits mask, it's easy to modify the selection,
> and it's easy to use for graphical operations, but it's painfull for the
> drawing of the selection box on the screen
>  - or we can store the border of the selection zone in a broken line, it's
> easy for drawing on the screen, we can convert it to a 2bits mask for
> graphical operation, but it's painfull to modify the selection

I think we should use both of these schemes together: store the selection as 
an n-bit mask so it's easy to modify and we get the speed we need for using 
it in graphical operations; generate the outline used to display it each time 
we modify it, so it's easy to display.

Generating the outline from the mask is not too hard. I've got some code for 
doing just this that I was developing with kiconedit in mind. It generates a 
list of line segments from an arbritary mask bitmap.

I think storing the mask as a bitmap is the simplest practical way of allowing 
arbritary selections - more than just rectangles and ellipses - particularly 
if we want to use the selection as a mask while painting, i.e. the tool only 
affects pixels lying within the selection. I also think we should make it at 
least 8 bits - maybe the same as the channel depth - so that we can have 
anti-aliased selections, i.e. soft edges.

Adrian


More information about the kimageshop mailing list