Merge pull request #1209 from kleisauke/add-missing-cpp-functions

Add missing C++ functions
This commit is contained in:
John Cupitt 2019-01-11 14:21:45 +00:00 committed by GitHub
commit f0439fbb65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 9 deletions

View File

@ -32,8 +32,6 @@
#endif /*HAVE_CONFIG_H*/ #endif /*HAVE_CONFIG_H*/
#include <vips/intl.h> #include <vips/intl.h>
#include <iostream>
#include <vips/vips8> #include <vips/vips8>
VIPS_NAMESPACE_START VIPS_NAMESPACE_START

View File

@ -563,7 +563,7 @@ VImage::new_from_file( const char *name, VOption *options )
} }
VImage VImage
VImage::new_from_buffer( void *buf, size_t len, const char *option_string, VImage::new_from_buffer( const void *buf, size_t len, const char *option_string,
VOption *options ) VOption *options )
{ {
const char *operation_name; const char *operation_name;
@ -588,6 +588,13 @@ VImage::new_from_buffer( void *buf, size_t len, const char *option_string,
return( out ); return( out );
} }
VImage
VImage::new_from_buffer( const std::string &buf, const char *option_string,
VOption *options )
{
return( new_from_buffer( buf.c_str(), buf.size(), option_string, options ) );
}
VImage VImage
VImage::new_matrix( int width, int height ) VImage::new_matrix( int width, int height )
{ {

View File

@ -31,8 +31,8 @@
#ifndef VIPS_VERROR_H #ifndef VIPS_VERROR_H
#define VIPS_VERROR_H #define VIPS_VERROR_H
#include <string> #include <cstring>
#include <iosfwd> #include <ostream>
#include <exception> #include <exception>
#include <vips/vips.h> #include <vips/vips.h>
@ -43,7 +43,7 @@ class VIPS_CPLUSPLUS_API VError : public std::exception {
std::string _what; std::string _what;
public: public:
VError( std::string what ) : _what( what ) {} VError( const std::string &what ) : _what( what ) {}
VError() : _what( vips_error_buffer() ) {} VError() : _what( vips_error_buffer() ) {}
virtual ~VError() throw() {} virtual ~VError() throw() {}

View File

@ -34,7 +34,7 @@
#include <complex> #include <complex>
#include <vector> #include <vector>
#include <string.h> #include <cstring>
#include <vips/vips.h> #include <vips/vips.h>
@ -327,6 +327,12 @@ public:
return( vips_image_get_yoffset( get_image() ) ); return( vips_image_get_yoffset( get_image() ) );
} }
bool
has_alpha() const
{
return( vips_image_hasalpha( get_image() ) );
}
const char * const char *
filename() const filename() const
{ {
@ -416,6 +422,12 @@ public:
return( value ); return( value );
} }
bool
remove( const char *name ) const
{
return( vips_image_remove( get_image(), name ) );
}
static VOption * static VOption *
option() option()
{ {
@ -458,7 +470,10 @@ public:
return( VImage( image ) ); return( VImage( image ) );
} }
static VImage new_from_buffer( void *buf, size_t len, static VImage new_from_buffer( const void *buf, size_t len,
const char *option_string, VOption *options = 0 );
static VImage new_from_buffer( const std::string &buf,
const char *option_string, VOption *options = 0 ); const char *option_string, VOption *options = 0 );
static VImage new_matrix( int width, int height ); static VImage new_matrix( int width, int height );
@ -495,6 +510,17 @@ public:
return( new_from_image( to_vectorv( 1, pixel ) ) ); return( new_from_image( to_vectorv( 1, pixel ) ) );
} }
VImage
copy_memory() const
{
VipsImage *image;
if( !(image = vips_image_copy_memory( this->get_image() )) )
throw( VError() );
return( VImage( image ) );
}
VImage write( VImage out ) const; VImage write( VImage out ) const;
void write_to_file( const char *name, VOption *options = 0 ) const; void write_to_file( const char *name, VOption *options = 0 ) const;

View File

@ -34,7 +34,7 @@
#include <complex> #include <complex>
#include <vector> #include <vector>
#include <string.h> #include <cstring>
#include <vips/vips.h> #include <vips/vips.h>