add gifload_source

This commit is contained in:
John Cupitt 2020-01-30 22:15:48 +00:00
parent 63b755e73e
commit acabd2dc08
4 changed files with 99 additions and 0 deletions

View File

@ -5,6 +5,7 @@
- allow \ as an escape character in vips_break_token() [akemrir]
- tiffsave has a "depth" param to set max pyr depth
- libtiff LOGLUV images load and save as libvips XYZ
- add gifload_source
20/6/19 started 8.9.1
- don't use the new source loaders for new_from_file or new_from_buffer, it

View File

@ -2107,6 +2107,7 @@ vips_foreign_operation_init( void )
extern GType vips_foreign_load_gif_file_get_type( void );
extern GType vips_foreign_load_gif_buffer_get_type( void );
extern GType vips_foreign_load_gif_source_get_type( void );
vips_foreign_load_csv_get_type();
vips_foreign_save_csv_get_type();
@ -2158,6 +2159,7 @@ vips_foreign_operation_init( void )
#ifdef HAVE_GIFLIB
vips_foreign_load_gif_file_get_type();
vips_foreign_load_gif_buffer_get_type();
vips_foreign_load_gif_source_get_type();
#endif /*HAVE_GIFLIB*/
#ifdef HAVE_GSF

View File

@ -36,6 +36,7 @@
* - improve early close again
* 30/1/19
* - rework on top of VipsSource
* - add gifload_source
*/
/*
@ -1431,6 +1432,70 @@ vips_foreign_load_gif_buffer_init( VipsForeignLoadGifBuffer *buffer )
{
}
typedef struct _VipsForeignLoadGifSource {
VipsForeignLoadGif parent_object;
/* Load from a source.
*/
VipsSource *source;
} VipsForeignLoadGifSource;
typedef VipsForeignLoadGifClass VipsForeignLoadGifSourceClass;
G_DEFINE_TYPE( VipsForeignLoadGifSource, vips_foreign_load_gif_source,
vips_foreign_load_gif_get_type() );
static int
vips_foreign_load_gif_source_build( VipsObject *object )
{
VipsForeignLoadGif *gif = (VipsForeignLoadGif *) object;
VipsForeignLoadGifSource *source =
(VipsForeignLoadGifSource *) object;
if( source->source ) {
gif->source = source->source;
g_object_ref( gif->source );
}
if( VIPS_OBJECT_CLASS( vips_foreign_load_gif_source_parent_class )->
build( object ) )
return( -1 );
return( 0 );
}
static void
vips_foreign_load_gif_source_class_init(
VipsForeignLoadGifSourceClass *class )
{
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
VipsObjectClass *object_class = (VipsObjectClass *) class;
VipsForeignLoadClass *load_class = (VipsForeignLoadClass *) class;
gobject_class->set_property = vips_object_set_property;
gobject_class->get_property = vips_object_get_property;
object_class->nickname = "gifload_source";
object_class->description = _( "load GIF with giflib" );
object_class->build = vips_foreign_load_gif_source_build;
load_class->is_a_source = vips_foreign_load_gif_is_a_source;
VIPS_ARG_OBJECT( class, "source", 1,
_( "Source" ),
_( "Source to load from" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadGifSource, source ),
VIPS_TYPE_SOURCE );
}
static void
vips_foreign_load_gif_source_init( VipsForeignLoadGifSource *source )
{
}
#endif /*HAVE_GIFLIB*/
/**
@ -1515,3 +1580,32 @@ vips_gifload_buffer( void *buf, size_t len, VipsImage **out, ... )
return( result );
}
/**
* vips_gifload_source:
* @source: source to load
* @out: (out): image to write
* @...: %NULL-terminated list of optional named arguments
*
* Optional arguments:
*
* * @page: %gint, page (frame) to read
* * @n: %gint, load this many pages
*
* Exactly as vips_gifload(), but read from a source.
*
* See also: vips_gifload().
*
* Returns: 0 on success, -1 on error.
*/
int
vips_gifload_source( VipsSource *source, VipsImage **out, ... )
{
va_list ap;
int result;
va_start( ap, out );
result = vips_call_split( "gifload_source", ap, source, out );
va_end( ap );
return( result );
}

View File

@ -597,6 +597,8 @@ int vips_gifload( const char *filename, VipsImage **out, ... )
__attribute__((sentinel));
int vips_gifload_buffer( void *buf, size_t len, VipsImage **out, ... )
__attribute__((sentinel));
int vips_gifload_source( VipsSource *source, VipsImage **out, ... )
__attribute__((sentinel));
int vips_heifload( const char *filename, VipsImage **out, ... )
__attribute__((sentinel));