Design ideas about iterators

Patrick Julien freak at codepimps.org
Wed Mar 3 13:07:21 CET 2004


On March 3, 2004 06:59 am, Boudewijn Rempt wrote:
> On Wednesday 03 March 2004 12:47, Patrick Julien wrote:
> > > > To store 16 bits use two quantum...
> > > > One RGBA pixel four (or eight) quantum.
> > >
> > > hum, yes but if we use two quantum to do a quantum16, we will have to
> > > write a brand new colorstrategy, but if we use template, we can share
> > > some code between colors strategy.
> >
> > That is an incorrect assumption.  What you need is for the channel depth
> > to be a property of the paint device instead of a compile time option.
>
> Shouldn't channel depth be a property of the image type -- and the image
> type a property of the channel depth? (On a related note -- I really want
> to make Krita flexible enough that it is possible to have layers of
> different image types in the same image.)

Internally, yes, you can easily make a flyweight out of the image type 
descriptor, but for easy access *AND* better encapsulation you want them to 
be a property of the paint device.  This way, when you get the current paint 
device, you don't have to backtrack back to the image to get the information 
you need to reliably paint on it.  You do, however, get a the same object 
back that if you we're painting on another paint device of on another image 
of the same type.

This way, the API stays powerful and *usable*, but correct pattern usage keeps 
the code lean.



More information about the kimageshop mailing list