#ifdef WIN32
- #ifdef IMAGECOMPOSER_EXPORTS
+ #ifdef IMAGE_COMPOSER_EXPORTS
#define IMAGE_COMPOSER_API __declspec( dllexport )
#else
#define IMAGE_COMPOSER_API __declspec( dllimport )
/**
Constructor
- @param theRefColor the color to the searched (the color for mask)
- @param isMakeTransparent the boolean flag controlling if the pixels with matching color
- should be made transparent or one with non-matching color
- @param theRGBThreshold the threshold for RGB components
- @param theAlphaThreshold the threshold for Alpha component
*/
-ImageComposer_ColorMaskOperator::ImageComposer_ColorMaskOperator( const QColor& theRefColor,
- bool isMakeTransparent,
- int theRGBThreshold,
- int theAlphaThreshold )
-: ImageComposer_Operator( TRANSPARENT ),
- myRefColor( theRefColor ), myIsMakeTransparent( isMakeTransparent ),
- myRGBThreshold( theRGBThreshold ), myAlphaThreshold( theAlphaThreshold )
+ImageComposer_ColorMaskOperator::ImageComposer_ColorMaskOperator()
+: ImageComposer_Operator(),
+ myRefColor( Qt::black ), myIsMakeTransparent( false ),
+ myRGBThreshold( 0 ), myAlphaThreshold( 0 )
{
}
{
}
+/**
+ Set operator arguments
+ @param theRefColor the color to the searched (the color for mask)
+ @param isMakeTransparent the boolean flag controlling if the pixels with matching color
+ should be made transparent or one with non-matching color
+ @param theRGBThreshold the threshold for RGB components
+ @param theAlphaThreshold the threshold for Alpha component
+*/
+void ImageComposer_ColorMaskOperator::setArgs( const QColor& theRefColor,
+ bool isMakeTransparent,
+ int theRGBThreshold,
+ int theAlphaThreshold )
+{
+ myRefColor = theRefColor;
+ myIsMakeTransparent = isMakeTransparent;
+ myRGBThreshold = theRGBThreshold;
+ myAlphaThreshold = theAlphaThreshold;
+}
+
/**
*/
QString ImageComposer_ColorMaskOperator::name() const
aResult.setTransform( theImage1.transform() );
aResult.draw( thePainter );
}
+
+void ImageComposer_ColorMaskOperator::storeArgs( QDataStream& theStream ) const
+{
+ ImageComposer_Operator::storeArgs( theStream );
+ theStream << myRefColor;
+ theStream << myIsMakeTransparent;
+ theStream << myRGBThreshold;
+ theStream << myAlphaThreshold;
+}
+
+void ImageComposer_ColorMaskOperator::restoreArgs( QDataStream& theStream )
+{
+ ImageComposer_Operator::restoreArgs( theStream );
+ theStream >> myRefColor;
+ theStream >> myIsMakeTransparent;
+ theStream >> myRGBThreshold;
+ theStream >> myAlphaThreshold;
+}
class IMAGE_COMPOSER_API ImageComposer_ColorMaskOperator : public ImageComposer_Operator
{
public:
- ImageComposer_ColorMaskOperator( const QColor& theRefColor,
- bool isMakeTransparent,
- int theRGBThreshold,
- int theAlphaThreshold );
+ ImageComposer_ColorMaskOperator();
virtual ~ImageComposer_ColorMaskOperator();
+ void setArgs( const QColor& theRefColor,
+ bool isMakeTransparent,
+ int theRGBThreshold,
+ int theAlphaThreshold );
+
virtual QString name() const;
protected:
virtual void drawResult( QPainter& thePainter, const ImageComposer_Image& theImage1,
const ImageComposer_Image& theImage2 ) const;
+ virtual void storeArgs( QDataStream& theStream ) const;
+ virtual void restoreArgs( QDataStream& theStream );
+
private:
+ friend class ImageComposerTests_TestOperators;
+
QColor myRefColor; ///< the color to the searched (the color for mask)
bool myIsMakeTransparent; ///< the boolean flag controlling if the pixels with matching color
///< should be made transparent or one with non-matching color
/**
Constructor
- @param theBackground the background color for result image
- @param theRect the cropping rectangle (in the global CS)
*/
-ImageComposer_CropOperator::ImageComposer_CropOperator( const QColor& theBackground, const QRect& theRect )
-: ImageComposer_Operator( theBackground )
+ImageComposer_CropOperator::ImageComposer_CropOperator()
+: ImageComposer_Operator()
{
- myClipPath.addRect( theRect );
}
/**
- Constructor
+*/
+ImageComposer_CropOperator::~ImageComposer_CropOperator()
+{
+}
+
+/**
+ Set operator arguments
@param theBackground the background color for result image
- @param thePath the cropping path (in the global CS)
+ @param theRect the cropping rectangle (in the global CS)
*/
-ImageComposer_CropOperator::ImageComposer_CropOperator( const QColor& theBackground, const QPainterPath& thePath )
-: ImageComposer_Operator( theBackground )
+void ImageComposer_CropOperator::setArgs( const QColor& theBackground, const QRect& theRect )
{
- myClipPath = thePath;
+ ImageComposer_Operator::setArgs( theBackground );
+ myClipPath = QPainterPath();
+ myClipPath.addRect( theRect );
}
/**
+ Set operator arguments
+ @param theBackground the background color for result image
+ @param thePath the cropping path (in the global CS)
*/
-ImageComposer_CropOperator::~ImageComposer_CropOperator()
+void ImageComposer_CropOperator::setArgs( const QColor& theBackground, const QPainterPath& thePath )
{
+ ImageComposer_Operator::setArgs( theBackground );
+ myClipPath = thePath;
}
/**
return ImageComposer_Operator::process( theImage1, theImage2 );
}
+
+
+void ImageComposer_CropOperator::storeArgs( QDataStream& theStream ) const
+{
+ ImageComposer_Operator::storeArgs( theStream );
+ theStream << myClipPath;
+}
+
+void ImageComposer_CropOperator::restoreArgs( QDataStream& theStream )
+{
+ ImageComposer_Operator::restoreArgs( theStream );
+ theStream >> myClipPath;
+}
class IMAGE_COMPOSER_API ImageComposer_CropOperator : public ImageComposer_Operator
{
public:
- ImageComposer_CropOperator( const QColor& theBackground, const QRect& );
- ImageComposer_CropOperator( const QColor& theBackground, const QPainterPath& );
+ ImageComposer_CropOperator();
virtual ~ImageComposer_CropOperator();
+ void setArgs( const QColor& theBackground, const QRect& );
+ void setArgs( const QColor& theBackground, const QPainterPath& );
+
QPainterPath clipPath() const;
virtual QString name() const;
virtual void drawResult( QPainter& thePainter, const ImageComposer_Image& theImage1,
const ImageComposer_Image& theImage2 ) const;
+ virtual void storeArgs( QDataStream& theStream ) const;
+ virtual void restoreArgs( QDataStream& theStream );
+
private:
+ friend class ImageComposerTests_TestOperators;
+
QPainterPath myClipPath; ///< the clipping path specified initially
QPainterPath myImgClipPath; ///< the clipping path mapped to first image's local CS
};
/**
Constructor
- @param theBackground the background color for result image
*/
-ImageComposer_CutOperator::ImageComposer_CutOperator( const QColor& theBackground )
- : ImageComposer_Operator( theBackground )
+ImageComposer_CutOperator::ImageComposer_CutOperator()
+ : ImageComposer_Operator()
{
}
class IMAGE_COMPOSER_API ImageComposer_CutOperator : public ImageComposer_Operator
{
public:
- ImageComposer_CutOperator( const QColor& theBackground );
+ ImageComposer_CutOperator();
virtual ~ImageComposer_CutOperator();
virtual QString name() const;
/**
Constructor
- @param theBackground the background color for result image
*/
-ImageComposer_FuseOperator::ImageComposer_FuseOperator( const QColor& theBackground )
- : ImageComposer_Operator( theBackground )
+ImageComposer_FuseOperator::ImageComposer_FuseOperator()
+ : ImageComposer_Operator()
{
}
class IMAGE_COMPOSER_API ImageComposer_FuseOperator : public ImageComposer_Operator
{
public:
- ImageComposer_FuseOperator( const QColor& theBackground );
+ ImageComposer_FuseOperator();
virtual ~ImageComposer_FuseOperator();
virtual QString name() const;
*/
ImageComposer_Image ImageComposer_Image::operator & ( const QRect& theRect ) const
{
- return apply( ImageComposer_CropOperator( myDefaultBackground, theRect ) );
+ ImageComposer_CropOperator anOp;
+ anOp.setArgs( myDefaultBackground, theRect );
+ return apply( anOp );
}
/**
*/
ImageComposer_Image ImageComposer_Image::operator & ( const QPainterPath& thePath ) const
{
- return apply( ImageComposer_CropOperator( myDefaultBackground, thePath ) );
+ ImageComposer_CropOperator anOp;
+ anOp.setArgs( myDefaultBackground, thePath );
+ return apply( anOp );
}
/**
*/
ImageComposer_Image ImageComposer_Image::operator & ( const ImageComposer_Image& theImage ) const
{
- return apply( ImageComposer_CutOperator( myDefaultBackground ), theImage );
+ ImageComposer_CutOperator anOp;
+ anOp.setArgs( myDefaultBackground );
+ return apply( anOp, theImage );
}
/**
*/
ImageComposer_Image ImageComposer_Image::operator | ( const ImageComposer_Image& theImage ) const
{
- return apply( ImageComposer_FuseOperator( myDefaultBackground ), theImage );
+ ImageComposer_FuseOperator anOp;
+ anOp.setArgs( myDefaultBackground );
+ return apply( anOp, theImage );
}
/**
Constructor
- @param theBackground the background color for result image
*/
-ImageComposer_Operator::ImageComposer_Operator( const QColor& theBackground )
-: myBackground( theBackground )
+ImageComposer_Operator::ImageComposer_Operator()
+: myBackground( TRANSPARENT )
{
}
{
}
+/**
+ Set operator arguments
+ @param theBackground the background color for result image
+*/
+void ImageComposer_Operator::setArgs( const QColor& theBackground )
+{
+ myBackground = theBackground;
+}
+
/**
Return name of the operator
@return name of the operator
aResult.setTransform( aResultTransform );
return aResult;
}
+
+/**
+ Get the operator's arguments in the form of a binary array
+ @return the binary array with arguments
+*/
+QByteArray ImageComposer_Operator::getBinArgs() const
+{
+ QByteArray aData;
+ QDataStream aStream( &aData, QIODevice::WriteOnly );
+ storeArgs( aStream );
+ return aData;
+}
+
+/**
+ Set the operator's arguments in the form of a binary array
+ @param theData the binary array with arguments
+*/
+void ImageComposer_Operator::setBinArgs( const QByteArray& theData )
+{
+ QDataStream aStream( theData );
+ restoreArgs( aStream );
+}
+
+/**
+ Store the operator's arguments to the stream
+ @param theStream the stream for storing
+*/
+void ImageComposer_Operator::storeArgs( QDataStream& theStream ) const
+{
+ theStream << myBackground;
+}
+
+/**
+ Restore the operator's arguments from the stream
+ @param theStream the stream for restoring
+*/
+void ImageComposer_Operator::restoreArgs( QDataStream& theStream )
+{
+ theStream >> myBackground;
+}
class IMAGE_COMPOSER_API ImageComposer_Operator
{
public:
- ImageComposer_Operator( const QColor& theBackground );
+ ImageComposer_Operator();
virtual ~ImageComposer_Operator();
+ void setArgs( const QColor& theBackground );
+ QByteArray getBinArgs() const;
+ void setBinArgs( const QByteArray& );
+
virtual QString name() const;
virtual ImageComposer_Image process( const ImageComposer_Image& theImage1,
const ImageComposer_Image& theImage2 ) const;
virtual void drawResult( QPainter& thePainter, const ImageComposer_Image& theImage1,
const ImageComposer_Image& theImage2 ) const = 0;
+ virtual void storeArgs( QDataStream& theStream ) const;
+ virtual void restoreArgs( QDataStream& theStream );
+
private:
+ friend class ImageComposerTests_TestOperators;
+
QColor myBackground; ///< the background color for result image
};