add svgload_string

simple convenience function for C
This commit is contained in:
John Cupitt 2021-06-28 11:45:56 +01:00
parent 706c2a112d
commit 7512e410ca
3 changed files with 42 additions and 0 deletions

View File

@ -1,5 +1,6 @@
14/6/21 started 8.12
- all tools support `--version`
- add vips_svgload_string() convenience function
14/8/20 started 8.11.1
- add more example code to C docs

View File

@ -805,6 +805,45 @@ vips_svgload_buffer( void *buf, size_t len, VipsImage **out, ... )
return( result );
}
/**
* vips_svgload_string:
* @str: string to load
* @out: (out): image to write
* @...: %NULL-terminated list of optional named arguments
*
* Optional arguments:
*
* * @dpi: %gdouble, render at this DPI
* * @scale: %gdouble, scale render by this factor
* * @unlimited: %gboolean, allow SVGs of any size
*
* Exactly as vips_svgload(), but read from a string. This function takes a
* copy of the string.
*
* See also: vips_svgload().
*
* Returns: 0 on success, -1 on error.
*/
int
vips_svgload_string( const char *str, VipsImage **out, ... )
{
va_list ap;
VipsBlob *blob;
int result;
/* Copy the string.
*/
blob = vips_blob_copy( (const void *) str, strlen( str ) );
va_start( ap, out );
result = vips_call_split( "svgload_buffer", ap, blob, out );
va_end( ap );
vips_area_unref( VIPS_AREA( blob ) );
return( result );
}
/**
* vips_svgload_source:
* @source: source to load from

View File

@ -648,6 +648,8 @@ int vips_svgload( const char *filename, VipsImage **out, ... )
__attribute__((sentinel));
int vips_svgload_buffer( void *buf, size_t len, VipsImage **out, ... )
__attribute__((sentinel));
int vips_svgload_string( const char *str, VipsImage **out, ... )
__attribute__((sentinel));
int vips_svgload_source( VipsSource *source, VipsImage **out, ... )
__attribute__((sentinel));