koffice/krita

Boudewijn Rempt boud at valdyas.org
Fri Aug 27 15:00:04 CEST 2004


On Friday 27 August 2004 14:43, Bart Coppens wrote:
> Quoting Boudewijn Rempt <boud at valdyas.org>:
> > Since the composite ops that can be used with a particular color strategy
> > can be listed beforehand (and, for instance, used in the composite op
> > combobox for tools and layer props, I think it would be not just an error
> > condition, but a bug in the code if an unsupported composite op was used
> > in the call.
>
> That's true for regular tools, but what if someone wrote a script or
> something, that needs a certain composite operation. Of course he should
> check this, but I can imagine that it would become quite annoying to loop
> over the list beforehand.

On the other hand, people don't check their return values all that 
religiously, do they :-). It's easy enough to add one, though.

>
> > Oh, I think I was unclear. I was only writing about the composite op part
> > of the API, not the rest.
>
> Ah, then I misunderstood.
>

I've attached the complete API that I see as useful, with some comments for 
consideration & discussion. Note that I have kept the nativeColor and 
toKoColor methods, but suggest name changes. I suspect that nativeColor/toKoColor
do the same thing as convertTo/convertToRGBA/convertFromRGBA. RGB isn't the
best choice for an intermediate format, so I propose using koColor, using the LAB
constructor as intermediate format where needed.

class KisStrategyColorSpace : public KShared {

public:
 KisStrategyColorSpace(const QString& name);
 virtual ~KisStrategyColorSpace();

public:
 /**
  * Fill dst with the color described by koColor c. If KoColor
  * does not support the current colour strategy directly,
  * assume the LAB version is the most accurate.
  *
  * XXX: rename 'toNativeColor'?
  */
 virtual void nativeColor(const KoColor& c, QUANTUM *dst) = 0;
 virtual void nativeColor(const KoColor& c, QUANTUM opacity, QUANTUM *dst) = 0;
 virtual void nativeColor(const QColor& c, QUANTUM *dst) = 0;
 virtual void nativeColor(const QColor& c, QUANTUM opacity, QUANTUM *dst) = 0;
 virtual void nativeColor(QRgb rgb, QUANTUM *dst) = 0;
 virtual void nativeColor(QRgb rgb, QUANTUM opacity, QUANTUM *dst) = 0;

 /**
  * Convert the src to a KoColor c. If koColor doesn't support
  * this color model directly, use littleCMS and profiles to
  * convert to LAB, initialize koCOlor with that
  *
  * XXX: rename to 'fromNativeColor'?
	 */
	virtual void toKoColor(const QUANTUM *src, KoColor *c) = 0;
	virtual void toKoColor(const QUANTUM *src, KoColor *c, QUANTUM *opacity) = 0;

	// XXX: make this a proper vector. Pointers to arrays are _so_ seventies, and
	// Stroustrup assures us a vector is as effecient a mem array anyway.
	virtual ChannelInfo * channelsInfo() const = 0;

	/**
	 * Number of channels this color model uses, including the alpha channel,
	 * if there is one.
	 */
	virtual Q_INT32 depth() const = 0;

	/**
	 * Returns true if this color model has an alpha channel.
	 */
	virtual bool alpha() const = 0;

	/**
	 * The user-visible name of this color model
	 */
	inline QString name() { return m_name; };

	/**
	 * Render the contents of the projection image onto painter.
	 */
	virtual void render(KisImageSP projection, QPainter& painter, Q_INT32 x, Q_INT32 y, Q_INT32 width, Q_INT32 height) = 0;

	/**
	 * Create a QImage from the specified Krita image.
	 */
	virtual QImage convertToImage(KisImageSP image, Q_INT32 x, Q_INT32 y, Q_INT32 width, Q_INT32 height) const = 0;

	/**
	 * Create a QImage from the data in the specified tile manager.
	 */
	virtual QImage convertToImage(KisTileMgrSP tm, Q_UINT32 depth, Q_INT32 x, Q_INT32 y, Q_INT32 width, Q_INT32 height) const = 0;

	/**
	 * Opaquely composite src with dest using the specified
	 * composite operation. dst and src must have the same color
	 * model.
	 */
	virtual void bitBlt(Q_INT32 stride,
			    QUANTUM *dst, 
			    Q_INT32 dststride,
			    QUANTUM *src, 
			    Q_INT32 srcstride,
			    Q_INT32 rows, 
			    Q_INT32 cols, 
			    CompositeOp op) const = 0;
	
	/**
	 * Composite src with dest using the specified composite
	 * operation and opacity.
	 *
	 * dst and src must have the same color model.
	 * 
	 */
	virtual void bitBlt(Q_INT32 stride,
			    QUANTUM *dst, 
			    Q_INT32 dststride,
			    QUANTUM *src, 
			    Q_INT32 srcstride,
			    QUANTUM opacity,
			    Q_INT32 rows, 
			    Q_INT32 cols, 
			    CompositeOp op) const = 0;

	/**
	 * Opaquely Composite src with dest using the specified
	 * composite operation.
	 *
	 * If dst and src have not the same color model, then a conversion
	 * via koColor and littleCMS should be done.
  * 
  */
 virtual void bitBlt(Q_INT32 stride,
       QUANTUM *dst, 
       Q_INT32 dststride,
       KisStrategyColorSpaceSP dstModel,
       QUANTUM *src, 
       Q_INT32 srcstride,
       KisStrategyColorSpaceSP srcModel,
       Q_INT32 rows, 
       Q_INT32 cols, 
       CompositeOp op) const = 0;


 /**
  * Composite src with dest using the specified composite
  * operation and opacity.
  *
  * If dst and src have not the same color model, then a conversion
  * via koColor and littleCMS should be done.
  * 
  */
 virtual void bitBlt(Q_INT32 stride,
       QUANTUM *dst, 
       Q_INT32 dststride,
       KisStrategyColorSpaceSP dstModel,
       QUANTUM *src, 
       Q_INT32 srcstride,
       KisStrategyColorSpaceSP srcModel,
       QUANTUM opacity,
       Q_INT32 rows, 
       Q_INT32 cols, 
       CompositeOp op) const = 0;
 
 /**
  * XXX Documentation? Is this really the job of the color model?
  */
 virtual void computeDuplicatePixel(KisIteratorPixel* dst, KisIteratorPixel* dab, KisIteratorPixel* src) = 0;
 
};


-- 
Boudewijn Rempt | http://www.valdyas.org/fading/index.cgi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kimageshop/attachments/20040827/f7189dbf/attachment-0001.pgp


More information about the kimageshop mailing list