added std::vector init for masks

This commit is contained in:
John Cupitt 2008-07-28 16:50:19 +00:00
parent f78816e00f
commit 5695c65e46
3 changed files with 46 additions and 2 deletions

View File

@ -34,6 +34,7 @@
- added man page for im_resize_linear
- better jpeg-in-tiff YCbCr read (thanks Ole)
- oops, invalidatefns were not being freed on im__close()
- VMask() can init from std::vector, so Python can init from []
25/1/08 started 7.14.0
- bump all version numbers for new stable

View File

@ -241,6 +241,13 @@ public:
va_end( ap );
}
VIMask( int xsize, int ysize, int scale, int offset,
std::vector<int> coeff )
{
ref->pmask = new _private_detail::VPIMask( xsize, ysize,
scale, offset, coeff );
}
VIMask( const char *name )
{
ref->pmask = new _private_detail::VPIMask( name );
@ -314,6 +321,13 @@ public:
va_end( ap );
}
VDMask( int xsize, int ysize, double scale, double offset,
std::vector<double> coeff )
{
ref->pmask = new _private_detail::VPDMask( xsize, ysize,
scale, offset, coeff );
}
VDMask( const char *name )
{
ref->pmask = new _private_detail::VPDMask( name );

View File

@ -164,7 +164,7 @@ _private_detail::VPIMask::VPIMask( int xsize, int ysize ) throw( VError )
type = _private_detail::VPMask::INT;
}
// Init from data
// Init from varargs
_private_detail::VPIMask::VPIMask( int xsize, int ysize,
int scale, int offset, va_list ap )
throw( VError )
@ -179,6 +179,21 @@ _private_detail::VPIMask::VPIMask( int xsize, int ysize,
data.iptr->coeff[i] = va_arg( ap, int );
}
// Init from vector
_private_detail::VPIMask::VPIMask( int xsize, int ysize,
int scale, int offset, std::vector<int> coeff )
throw( VError )
{
if( !(data.iptr = im_create_imask( "VPIMask::VPIMask", xsize, ysize )) )
verror();
type = _private_detail::VPMask::INT;
data.iptr->scale = scale;
data.iptr->offset = offset;
for( int i = 0; i < xsize * ysize; i++ )
data.iptr->coeff[i] = coeff[i];
}
// Create from filename
_private_detail::VPIMask::VPIMask( const char *name ) throw( VError )
{
@ -310,7 +325,7 @@ _private_detail::VPDMask::VPDMask( int xsize, int ysize ) throw( VError )
type = _private_detail::VPMask::DOUBLE;
}
// Create from args
// Create from varargs
_private_detail::VPDMask::VPDMask( int xsize, int ysize,
double scale, double offset, va_list ap ) throw( VError )
{
@ -324,6 +339,20 @@ _private_detail::VPDMask::VPDMask( int xsize, int ysize,
data.dptr->coeff[i] = va_arg( ap, double );
}
// Create from vector
_private_detail::VPDMask::VPDMask( int xsize, int ysize,
double scale, double offset, std::vector<double> coeff ) throw( VError )
{
if( !(data.dptr = im_create_dmask( "VPDMask::VPDMask", xsize, ysize )) )
verror();
type = _private_detail::VPMask::DOUBLE;
data.dptr->scale = scale;
data.dptr->offset = offset;
for( int i = 0; i < xsize * ysize; i++ )
data.dptr->coeff[i] = coeff[i];
}
// Create from filename
_private_detail::VPDMask::VPDMask( const char *name ) throw( VError )
{