add RefString getter

to python now unpacks VipsRefString on get_value()
This commit is contained in:
John Cupitt 2015-06-02 13:32:48 +01:00
parent baf78fc04a
commit c35e2e5427
5 changed files with 32 additions and 0 deletions

View File

@ -6,6 +6,7 @@
- vips_copy() can turn 1xN or Nx1 M-band images into MxN one-band images
- added bandand() bandor() bandeor() convenience funcs to Python
- oops, base64 encode could pad by up to two zero bytes
- added VipsRefString as a thing that gi bindings can unpack
7/5/15 started 8.0.3
- dzsave and tif pyr write could fail for some image dimensions, thanks Jonas

2
TODO
View File

@ -1,3 +1,5 @@
- does ruby need to unpack RefString as well? what about C++?
- how about something like vips_grid() which turns a tall thin one-band
image into a much smaller many-band image?

View File

@ -135,6 +135,12 @@ GType vips_save_string_get_type( void );
* The #GType for a #VipsRefString.
*/
#define VIPS_TYPE_REF_STRING (vips_ref_string_get_type())
typedef struct _VipsRefString {
VipsArea area;
} VipsRefString;
const char *vips_ref_string_get( VipsRefString *refstr, size_t *length );
GType vips_ref_string_get_type( void );
/**

View File

@ -502,6 +502,28 @@ transform_save_string_ref_string( const GValue *src_value, GValue *dest_value )
vips_value_get_save_string( src_value ) );
}
/**
* vips_ref_string_get:
* @refstr: the #VipsRefString to fetch from
* @length: (allow-none): return length here, optionally
*
* Get a pointer to the private string inside a refstr. Handy for language
* bindings.
*
* See also: vips_value_get_ref_string().
*
* Returns: (transfer none): The C string held by @refstr.
*/
const char *
vips_ref_string_get( VipsRefString *refstr, size_t *length )
{
VipsArea *area = VIPS_AREA( refstr );
g_assert( area->type == G_TYPE_DOUBLE );
return( vips_area_get_data( area, length, NULL, NULL, NULL ) );
}
GType
vips_ref_string_get_type( void )
{

View File

@ -95,6 +95,7 @@ def imageize(match_image, value):
# bytes().
unpack_types = [[Vips.Blob, lambda x: bytes(x.get())],
[Vips.RefString, lambda x: x.get()],
[Vips.ArrayDouble, lambda x: x.get()],
[Vips.ArrayImage, lambda x: x.get()],
[Vips.ArrayInt, lambda x: x.get()]]