diff --git a/ChangeLog b/ChangeLog index cb3f725a..e7eff003 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/libvips/foreign/svgload.c b/libvips/foreign/svgload.c index 8b9106f9..0974f79d 100644 --- a/libvips/foreign/svgload.c +++ b/libvips/foreign/svgload.c @@ -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 diff --git a/libvips/include/vips/foreign.h b/libvips/include/vips/foreign.h index 0d19e38b..8b45bd31 100644 --- a/libvips/include/vips/foreign.h +++ b/libvips/include/vips/foreign.h @@ -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));