Skip to content

Commit fd0a090

Browse files
committed
note VImage::new_from_memory_steal() in ChangeLog
plus doxy commnets etc., see #1758
1 parent 62e1cb4 commit fd0a090

File tree

4 files changed

+31
-18
lines changed

4 files changed

+31
-18
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- integrate doxygen in build system to generate C++ API docs
44
- improve C++ API doc comments
55
- add VipsInterpolate and guint64 support to C++ API
6+
- add VImage::new_from_memory_steal [Zeranoe]
67

78
6/9/20 started 8.10.2
89
- update magicksave/load profile handling [kelilevi]

cplusplus/VImage.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,22 @@ VImage::new_from_source( VSource source, const char *option_string,
641641
return( out );
642642
}
643643

644+
VImage
645+
VImage::new_from_memory_steal( void *data, size_t size,
646+
int width, int height, int bands, VipsBandFormat format )
647+
{
648+
VipsImage *image;
649+
650+
if( !(image = vips_image_new_from_memory( data, size,
651+
width, height, bands, format )) )
652+
throw( VError() );
653+
654+
g_signal_connect( image, "postclose",
655+
G_CALLBACK( vips_image_free_buffer ), data);
656+
657+
return( VImage( image ) );
658+
}
659+
644660
VImage
645661
VImage::new_matrix( int width, int height )
646662
{

cplusplus/include/vips/VImage8.h

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -862,11 +862,23 @@ class VImage : public VObject
862862
return( VImage( image ) );
863863
}
864864

865+
/**
866+
* Create a new VImage object from an area of memory containing a
867+
* C-style array.
868+
*
869+
* The VImage steals ownership of @data and will free() it when it
870+
* goes out of scope.
871+
*/
872+
static VImage
873+
new_from_memory_steal( void *data, size_t size,
874+
int width, int height, int bands, VipsBandFormat format );
875+
865876
/**
866877
* Create a matrix image of a specified size. All elements will be
867878
* zero.
868879
*/
869-
static VImage new_matrix( int width, int height );
880+
static VImage
881+
new_matrix( int width, int height );
870882

871883
/**
872884
* Create a matrix image of a specified size, initialized from the
@@ -917,22 +929,6 @@ class VImage : public VObject
917929
return( new_from_image( to_vectorv( 1, pixel ) ) );
918930
}
919931

920-
static VImage
921-
new_from_memory_steal( void *data, size_t size,
922-
int width, int height, int bands, VipsBandFormat format )
923-
{
924-
VipsImage *image;
925-
926-
if( !(image = vips_image_new_from_memory( data, size,
927-
width, height, bands, format )) )
928-
throw( VError() );
929-
930-
g_signal_connect( image, "postclose",
931-
G_CALLBACK(vips_image_free_buffer), data);
932-
933-
return( VImage( image ) );
934-
}
935-
936932
/**
937933
* Make a new image by rendering self to a large memory area,
938934
* wrapping a VImage around it, and copying all metadata over from

libvips/iofuncs/image.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3878,7 +3878,7 @@ vips_band_format_iscomplex( VipsBandFormat format )
38783878
* @buffer: the orignal buffer that was stolen
38793879
*
38803880
* Free the externally allocated buffer found in the input image. This function
3881-
* is intened to be used with g_signal_connect.
3881+
* is intended to be used with g_signal_connect.
38823882
*/
38833883
void
38843884
vips_image_free_buffer( VipsImage *image, void *buffer )

0 commit comments

Comments
 (0)