Add vips_foreign_is_a_buffer() method
This commits adds a vips_foreign_is_a_buffer() method, similar to vips_foreign_is_a().
This commit is contained in:
parent
be5052d0c3
commit
3d067af889
@ -615,6 +615,33 @@ vips_foreign_is_a( const char *loader, const char *filename )
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_foreign_is_a_buffer:
|
||||
* @loader: name of loader to use for test
|
||||
* @data: pointer to the buffer to test
|
||||
* @size: size of the buffer to test
|
||||
*
|
||||
* Return %TRUE if @data can be loaded by @loader. @loader is something
|
||||
* like "tiffload_buffer" or "VipsForeignLoadTiffBuffer".
|
||||
*
|
||||
* Returns: %TRUE if @data can be loaded by @loader.
|
||||
*/
|
||||
gboolean
|
||||
vips_foreign_is_a_buffer( const char *loader, void *data, size_t size )
|
||||
{
|
||||
VipsObjectClass *class;
|
||||
VipsForeignLoadClass *load_class;
|
||||
|
||||
if( !(class = vips_class_find( "VipsForeignLoad", loader )) )
|
||||
return( FALSE );
|
||||
load_class = VIPS_FOREIGN_LOAD_CLASS( class );
|
||||
if( load_class->is_a_buffer &&
|
||||
load_class->is_a_buffer( data, size ) )
|
||||
return( TRUE );
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_foreign_flags:
|
||||
* @loader: name of loader to use for test
|
||||
|
@ -218,6 +218,7 @@ const char *vips_foreign_find_load_buffer( void *data, size_t size );
|
||||
|
||||
VipsForeignFlags vips_foreign_flags( const char *loader, const char *filename );
|
||||
gboolean vips_foreign_is_a( const char *loader, const char *filename );
|
||||
gboolean vips_foreign_is_a_buffer( const char *loader, void *data, size_t size );
|
||||
|
||||
#define VIPS_TYPE_FOREIGN_SAVE (vips_foreign_save_get_type())
|
||||
#define VIPS_FOREIGN_SAVE( obj ) \
|
||||
|
Loading…
Reference in New Issue
Block a user