This commit is contained in:
John Cupitt 2016-06-11 17:36:06 +01:00
parent 93951fd04a
commit 28efdf1695
4 changed files with 217 additions and 40 deletions

View File

@ -21,6 +21,7 @@
combine many images in bounded memory combine many images in bounded memory
- VImage::write() implementation was missing - VImage::write() implementation was missing
- VImage::write() return value changed from void to VImage to help chaining - VImage::write() return value changed from void to VImage to help chaining
- added C++ arithmetic assignment overloads, += etc.
18/5/16 started 8.3.2 18/5/16 started 8.3.2
- more robust vips image reading - more robust vips image reading

9
TODO
View File

@ -1,11 +1,4 @@
- could add operator+= and friends to allow this - add tests for C++ += etc.
VImage im = ...;
VImage x = ...;
im += x;
unlike Python, C++ will not do this automatically
- add more webp tests to py suite - add more webp tests to py suite

View File

@ -4,6 +4,8 @@
* - allow set enum value from string * - allow set enum value from string
* 10/6/16 * 10/6/16
* - missing implementation of VImage::write() * - missing implementation of VImage::write()
* 11/6/16
* - added arithmetic assignment overloads, += etc.
*/ */
/* /*
@ -766,13 +768,32 @@ operator+( VImage a, std::vector<double> b )
return( a.linear( 1.0, b ) ); return( a.linear( 1.0, b ) );
} }
VImage &
VImage::operator+=( const VImage b )
{
return( *this = *this + b );
}
VImage &
VImage::operator+=( const double b )
{
return( *this = *this + b );
}
VImage &
VImage::operator+=( std::vector<double> b )
{
return( *this = *this + b );
}
VImage VImage
operator-( VImage a, VImage b ) operator-( VImage a, VImage b )
{ {
return( a.subtract( b ) ); return( a.subtract( b ) );
} }
VImage operator-( double a, VImage b ) VImage
operator-( double a, VImage b )
{ {
return( b.linear( -1.0, a ) ); return( b.linear( -1.0, a ) );
} }
@ -795,6 +816,24 @@ operator-( VImage a, std::vector<double> b )
return( a.linear( 1.0, vips::negate( b ) ) ); return( a.linear( 1.0, vips::negate( b ) ) );
} }
VImage &
VImage::operator-=( const VImage b )
{
return( *this = *this - b );
}
VImage &
VImage::operator-=( const double b )
{
return( *this = *this - b );
}
VImage &
VImage::operator-=( std::vector<double> b )
{
return( *this = *this - b );
}
VImage VImage
operator-( VImage a ) operator-( VImage a )
{ {
@ -831,6 +870,24 @@ operator*( VImage a, std::vector<double> b )
return( a.linear( b, 0.0 ) ); return( a.linear( b, 0.0 ) );
} }
VImage &
VImage::operator*=( const VImage b )
{
return( *this = *this * b );
}
VImage &
VImage::operator*=( const double b )
{
return( *this = *this * b );
}
VImage &
VImage::operator*=( std::vector<double> b )
{
return( *this = *this * b );
}
VImage VImage
operator/( VImage a, VImage b ) operator/( VImage a, VImage b )
{ {
@ -861,6 +918,24 @@ operator/( VImage a, std::vector<double> b )
return( a.linear( vips::invert( b ), 0.0 ) ); return( a.linear( vips::invert( b ), 0.0 ) );
} }
VImage &
VImage::operator/=( const VImage b )
{
return( *this = *this / b );
}
VImage &
VImage::operator/=( const double b )
{
return( *this = *this / b );
}
VImage &
VImage::operator/=( std::vector<double> b )
{
return( *this = *this / b );
}
VImage VImage
operator%( VImage a, VImage b ) operator%( VImage a, VImage b )
{ {
@ -879,6 +954,24 @@ operator%( VImage a, std::vector<double> b )
return( a.remainder_const( b ) ); return( a.remainder_const( b ) );
} }
VImage &
VImage::operator%=( const VImage b )
{
return( *this = *this % b );
}
VImage &
VImage::operator%=( const double b )
{
return( *this = *this % b );
}
VImage &
VImage::operator%=( std::vector<double> b )
{
return( *this = *this % b );
}
VImage VImage
operator<( VImage a, VImage b ) operator<( VImage a, VImage b )
{ {
@ -1115,6 +1208,24 @@ operator&( VImage a, std::vector<double> b )
return( a.boolean_const( b, VIPS_OPERATION_BOOLEAN_AND ) ); return( a.boolean_const( b, VIPS_OPERATION_BOOLEAN_AND ) );
} }
VImage &
VImage::operator&=( const VImage b )
{
return( *this = *this & b );
}
VImage &
VImage::operator&=( const double b )
{
return( *this = *this & b );
}
VImage &
VImage::operator&=( std::vector<double> b )
{
return( *this = *this & b );
}
VImage VImage
operator|( VImage a, VImage b ) operator|( VImage a, VImage b )
{ {
@ -1147,6 +1258,24 @@ operator|( VImage a, std::vector<double> b )
return( a.boolean_const( b, VIPS_OPERATION_BOOLEAN_OR ) ); return( a.boolean_const( b, VIPS_OPERATION_BOOLEAN_OR ) );
} }
VImage &
VImage::operator|=( const VImage b )
{
return( *this = *this | b );
}
VImage &
VImage::operator|=( const double b )
{
return( *this = *this | b );
}
VImage &
VImage::operator|=( std::vector<double> b )
{
return( *this = *this | b );
}
VImage VImage
operator^( VImage a, VImage b ) operator^( VImage a, VImage b )
{ {
@ -1179,6 +1308,24 @@ operator^( VImage a, std::vector<double> b )
return( a.boolean_const( b, VIPS_OPERATION_BOOLEAN_EOR ) ); return( a.boolean_const( b, VIPS_OPERATION_BOOLEAN_EOR ) );
} }
VImage &
VImage::operator^=( const VImage b )
{
return( *this = *this ^ b );
}
VImage &
VImage::operator^=( const double b )
{
return( *this = *this ^ b );
}
VImage &
VImage::operator^=( std::vector<double> b )
{
return( *this = *this ^ b );
}
VImage VImage
operator<<( VImage a, VImage b ) operator<<( VImage a, VImage b )
{ {
@ -1198,6 +1345,24 @@ operator<<( VImage a, std::vector<double> b )
return( a.boolean_const( b, VIPS_OPERATION_BOOLEAN_LSHIFT ) ); return( a.boolean_const( b, VIPS_OPERATION_BOOLEAN_LSHIFT ) );
} }
VImage &
VImage::operator<<=( const VImage b )
{
return( *this = *this << b );
}
VImage &
VImage::operator<<=( const double b )
{
return( *this = *this << b );
}
VImage &
VImage::operator<<=( std::vector<double> b )
{
return( *this = *this << b );
}
VImage VImage
operator>>( VImage a, VImage b ) operator>>( VImage a, VImage b )
{ {
@ -1217,4 +1382,22 @@ operator>>( VImage a, std::vector<double> b )
return( a.boolean_const( b, VIPS_OPERATION_BOOLEAN_RSHIFT ) ); return( a.boolean_const( b, VIPS_OPERATION_BOOLEAN_RSHIFT ) );
} }
VImage &
VImage::operator>>=( const VImage b )
{
return( *this = *this << b );
}
VImage &
VImage::operator>>=( const double b )
{
return( *this = *this << b );
}
VImage &
VImage::operator>>=( std::vector<double> b )
{
return( *this = *this << b );
}
VIPS_NAMESPACE_END VIPS_NAMESPACE_END

View File

@ -781,11 +781,9 @@ public:
friend VImage VIPS_CPLUSPLUS_API operator+( std::vector<double> a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator+( std::vector<double> a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator+( VImage a, std::vector<double> b ); friend VImage VIPS_CPLUSPLUS_API operator+( VImage a, std::vector<double> b );
VImage VIPS_CPLUSPLUS_API &operator+=( const VImage &b ) VImage & VIPS_CPLUSPLUS_API operator+=( const VImage b );
VImage & VIPS_CPLUSPLUS_API operator+=( const double b );
friend VImage VIPS_CPLUSPLUS_API operator+=( VImage a ); VImage & VIPS_CPLUSPLUS_API operator+=( const std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator+=( double a );
friend VImage VIPS_CPLUSPLUS_API operator+=( std::vector<double> a );
friend VImage VIPS_CPLUSPLUS_API operator-( VImage a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator-( VImage a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator-( double a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator-( double a, VImage b );
@ -793,9 +791,9 @@ public:
friend VImage VIPS_CPLUSPLUS_API operator-( std::vector<double> a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator-( std::vector<double> a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator-( VImage a, std::vector<double> b ); friend VImage VIPS_CPLUSPLUS_API operator-( VImage a, std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator-=( VImage a ); VImage & VIPS_CPLUSPLUS_API operator-=( const VImage b );
friend VImage VIPS_CPLUSPLUS_API operator-=( double a ); VImage & VIPS_CPLUSPLUS_API operator-=( const double b );
friend VImage VIPS_CPLUSPLUS_API operator-=( std::vector<double> a ); VImage & VIPS_CPLUSPLUS_API operator-=( const std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator-( VImage a ); friend VImage VIPS_CPLUSPLUS_API operator-( VImage a );
@ -805,9 +803,9 @@ public:
friend VImage VIPS_CPLUSPLUS_API operator*( std::vector<double> a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator*( std::vector<double> a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator*( VImage a, std::vector<double> b ); friend VImage VIPS_CPLUSPLUS_API operator*( VImage a, std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator*=( VImage a ); VImage & VIPS_CPLUSPLUS_API operator*=( const VImage b );
friend VImage VIPS_CPLUSPLUS_API operator*=( double a ); VImage & VIPS_CPLUSPLUS_API operator*=( const double b );
friend VImage VIPS_CPLUSPLUS_API operator*=( std::vector<double> a ); VImage & VIPS_CPLUSPLUS_API operator*=( const std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator/( VImage a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator/( VImage a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator/( double a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator/( double a, VImage b );
@ -815,18 +813,18 @@ public:
friend VImage VIPS_CPLUSPLUS_API operator/( std::vector<double> a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator/( std::vector<double> a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator/( VImage a, std::vector<double> b ); friend VImage VIPS_CPLUSPLUS_API operator/( VImage a, std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator/=( VImage a ); VImage & VIPS_CPLUSPLUS_API operator/=( const VImage b );
friend VImage VIPS_CPLUSPLUS_API operator/=( double a ); VImage & VIPS_CPLUSPLUS_API operator/=( const double b );
friend VImage VIPS_CPLUSPLUS_API operator/=( std::vector<double> a ); VImage & VIPS_CPLUSPLUS_API operator/=( const std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator%( VImage a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator%( VImage a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator%( VImage a, double b ); friend VImage VIPS_CPLUSPLUS_API operator%( VImage a, double b );
friend VImage VIPS_CPLUSPLUS_API operator%( VImage a, std::vector<double> b ); friend VImage VIPS_CPLUSPLUS_API operator%( VImage a, std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator%=( VImage a ); VImage & VIPS_CPLUSPLUS_API operator%=( const VImage b );
friend VImage VIPS_CPLUSPLUS_API operator%=( double a ); VImage & VIPS_CPLUSPLUS_API operator%=( const double b );
friend VImage VIPS_CPLUSPLUS_API operator%=( std::vector<double> a ); VImage & VIPS_CPLUSPLUS_API operator%=( const std::vector<double> b );
%
friend VImage VIPS_CPLUSPLUS_API operator<( VImage a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator<( VImage a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator<( double a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator<( double a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator<( VImage a, double b ); friend VImage VIPS_CPLUSPLUS_API operator<( VImage a, double b );
@ -869,9 +867,9 @@ public:
friend VImage VIPS_CPLUSPLUS_API operator&( std::vector<double> a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator&( std::vector<double> a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator&( VImage a, std::vector<double> b ); friend VImage VIPS_CPLUSPLUS_API operator&( VImage a, std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator&=( VImage a ); VImage & VIPS_CPLUSPLUS_API operator&=( const VImage b );
friend VImage VIPS_CPLUSPLUS_API operator&=( double a ); VImage & VIPS_CPLUSPLUS_API operator&=( const double b );
friend VImage VIPS_CPLUSPLUS_API operator&=( std::vector<double> a ); VImage & VIPS_CPLUSPLUS_API operator&=( const std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator|( VImage a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator|( VImage a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator|( double a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator|( double a, VImage b );
@ -879,9 +877,9 @@ public:
friend VImage VIPS_CPLUSPLUS_API operator|( std::vector<double> a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator|( std::vector<double> a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator|( VImage a, std::vector<double> b ); friend VImage VIPS_CPLUSPLUS_API operator|( VImage a, std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator|=( VImage a ); VImage & VIPS_CPLUSPLUS_API operator|=( const VImage b );
friend VImage VIPS_CPLUSPLUS_API operator|=( double a ); VImage & VIPS_CPLUSPLUS_API operator|=( const double b );
friend VImage VIPS_CPLUSPLUS_API operator|=( std::vector<double> a ); VImage & VIPS_CPLUSPLUS_API operator|=( const std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator^( VImage a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator^( VImage a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator^( double a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator^( double a, VImage b );
@ -889,23 +887,25 @@ public:
friend VImage VIPS_CPLUSPLUS_API operator^( std::vector<double> a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator^( std::vector<double> a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator^( VImage a, std::vector<double> b ); friend VImage VIPS_CPLUSPLUS_API operator^( VImage a, std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator^=( VImage a ); VImage & VIPS_CPLUSPLUS_API operator^=( const VImage b );
friend VImage VIPS_CPLUSPLUS_API operator^=( double a ); VImage & VIPS_CPLUSPLUS_API operator^=( const double b );
friend VImage VIPS_CPLUSPLUS_API operator^=( std::vector<double> a ); VImage & VIPS_CPLUSPLUS_API operator^=( const std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator<<( VImage a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator<<( VImage a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator<<( VImage a, double b ); friend VImage VIPS_CPLUSPLUS_API operator<<( VImage a, double b );
friend VImage VIPS_CPLUSPLUS_API operator<<( VImage a, std::vector<double> b ); friend VImage VIPS_CPLUSPLUS_API operator<<( VImage a, std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator<<=( double a ); VImage & VIPS_CPLUSPLUS_API operator<<=( const VImage b );
friend VImage VIPS_CPLUSPLUS_API operator<<=( std::vector<double> a ); VImage & VIPS_CPLUSPLUS_API operator<<=( const double b );
VImage & VIPS_CPLUSPLUS_API operator<<=( const std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator>>( VImage a, VImage b ); friend VImage VIPS_CPLUSPLUS_API operator>>( VImage a, VImage b );
friend VImage VIPS_CPLUSPLUS_API operator>>( VImage a, double b ); friend VImage VIPS_CPLUSPLUS_API operator>>( VImage a, double b );
friend VImage VIPS_CPLUSPLUS_API operator>>( VImage a, std::vector<double> b ); friend VImage VIPS_CPLUSPLUS_API operator>>( VImage a, std::vector<double> b );
friend VImage VIPS_CPLUSPLUS_API operator>>=( double a ); VImage & VIPS_CPLUSPLUS_API operator>>=( const VImage b );
friend VImage VIPS_CPLUSPLUS_API operator>>=( std::vector<double> a ); VImage & VIPS_CPLUSPLUS_API operator>>=( const double b );
VImage & VIPS_CPLUSPLUS_API operator>>=( const std::vector<double> b );
}; };