Back
Casper Boemann
cbr at boemann.dk
Mon Jul 26 15:34:34 CEST 2004
> KisPixelRepresentationMyColorStrategy : public KisPixelRepresentation
> {
>
> KisChannelDouble channel1() { return KisChannelDouble( (double*)
data ); };
> KisChannelDouble channel2() { return KisChannelDouble( (double*) ( data +
> sizeof(double) ) ); };
> KisChannelDouble channel3() { return KisChannelDouble( (double*) ( data +
> 2*sizeof(double) ) ); };
> KisChannelUChar channel4() { return KisChannelUChar ( data + 3
> *sizeof(double) ); };
>
>
> private:
> uchar* data;
>
> }
On the other hand - it is more or less exactly like the class I would use as
a helper class INSIDE the colorstrategy.
..If I could not convince you that *data would require extra copies of
data:
a typical life of a pixelrep:
-------------
-the pixelrep is created. Call of constructor and copy of pointer into
*data;
- the pixelrep is returned from the iterator requireing a copy
constructor(possible optimized away by the compiler but don't count on it)
- the pixelrep is used. a double indirect access to the data:
pixelrep->data->value
With my proposal:
-----------
-the pointer to the pixel is returned from the iterator requireing a copy
- the pixelrep is used. a single indirect access to the data:
pixelrep->value
with my proposal the class would be like:
KisPixelRepresentationMyColorStrategy : public KisPixelRepresentation
{
public:
KisChannelDouble channel1;
KisChannelDouble channel2;
KisChannelDouble channel3;
KisChannelUChar channel4;
}
no need to make them private as only MyColorStrategy would be allowed to use
this class (could be defined in MyColorStrategy.cpp).
In fact, it is nothing more than a struct.
best regards
Casper
More information about the kimageshop
mailing list