本文整理汇总了C++中VIPS_OBJECT函数的典型用法代码示例。如果您正苦于以下问题:C++ VIPS_OBJECT函数的具体用法?C++ VIPS_OBJECT怎么用?C++ VIPS_OBJECT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VIPS_OBJECT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vips_cache_operation_add
/**
* vips_cache_operation_add:
* @operation: (transfer none): pointer to operation to add
*
* Add a built operation to the cache. The cache will ref the operation.
*/
void
vips_cache_operation_add( VipsOperation *operation )
{
g_assert( VIPS_OBJECT( operation )->constructed );
g_mutex_lock( vips_cache_lock );
/* If two threads call the same operation at the same time,
* we can get multiple adds. Let the first one win. See
* https://github.com/jcupitt/libvips/pull/181
*/
if( !g_hash_table_lookup( vips_cache_table, operation ) ) {
VipsOperationFlags flags =
vips_operation_get_flags( operation );
gboolean nocache = flags & VIPS_OPERATION_NOCACHE;
/* Has to be after _build() so we can see output args.
*/
if( vips__cache_trace ) {
if( nocache )
printf( "vips cache : " );
else
printf( "vips cache+: " );
vips_object_print_summary( VIPS_OBJECT( operation ) );
}
if( !nocache )
vips_cache_insert( operation );
}
g_mutex_unlock( vips_cache_lock );
vips_cache_trim();
}
示例2: vips_cache_operation_lookup
/**
* vips_cache_operation_lookup:
* @operation: (transfer none): pointer to operation to lookup
*
* Look up an unbuilt @operation in the cache. If we get a hit, ref and
* return the old operation. If there's no hit, return NULL.
*
* Returns: (transfer full): the cache hit, if any.
*/
VipsOperation *
vips_cache_operation_lookup( VipsOperation *operation )
{
VipsOperationCacheEntry *hit;
VipsOperation *result;
g_assert( VIPS_IS_OPERATION( operation ) );
g_assert( !VIPS_OBJECT( operation )->constructed );
#ifdef VIPS_DEBUG
printf( "vips_cache_operation_lookup: " );
vips_object_print_dump( VIPS_OBJECT( operation ) );
#endif /*VIPS_DEBUG*/
g_mutex_lock( vips_cache_lock );
result = NULL;
if( (hit = g_hash_table_lookup( vips_cache_table, operation )) ) {
if( vips__cache_trace ) {
printf( "vips cache*: " );
vips_object_print_summary( VIPS_OBJECT( operation ) );
}
result = hit->operation;
vips_cache_ref( result );
}
g_mutex_unlock( vips_cache_lock );
return( result );
}
示例3: vips_cache_operation_buildp
/**
* vips_cache_operation_buildp: (skip)
* @operation: pointer to operation to lookup
*
* Look up @operation in the cache. If we get a hit, unref @operation, ref the
* old one and return that through the argument pointer.
*
* If we miss, build and add @operation.
*
* Returns: 0 on success, or -1 on error.
*/
int
vips_cache_operation_buildp( VipsOperation **operation )
{
VipsOperation *hit;
g_assert( VIPS_IS_OPERATION( *operation ) );
#ifdef VIPS_DEBUG
printf( "vips_cache_operation_buildp: " );
vips_object_print_dump( VIPS_OBJECT( *operation ) );
#endif /*VIPS_DEBUG*/
if( (hit = vips_cache_operation_lookup( *operation )) ) {
g_object_unref( *operation );
*operation = hit;
}
else {
if( vips_object_build( VIPS_OBJECT( *operation ) ) )
return( -1 );
vips_cache_operation_add( *operation );
}
return( 0 );
}
示例4: throw
void
VImage::call_option_string( const char *operation_name,
const char *option_string, VOption *options )
throw( VError )
{
VipsOperation *operation;
VIPS_DEBUG_MSG( "vips_call_by_name: starting for %s ...\n",
operation_name );
if( !(operation = vips_operation_new( operation_name )) ) {
if( options )
delete options;
throw( VError() );
}
/* Set str options before vargs options, so the user can't
* override things we set deliberately.
*/
if( option_string &&
vips_object_set_from_string( VIPS_OBJECT( operation ),
option_string ) ) {
vips_object_unref_outputs( VIPS_OBJECT( operation ) );
g_object_unref( operation );
delete options;
throw( VError() );
}
if( options )
options->set_operation( operation );
/* Build from cache.
*/
if( vips_cache_operation_buildp( &operation ) ) {
vips_object_unref_outputs( VIPS_OBJECT( operation ) );
delete options;
throw( VError() );
}
/* Walk args again, writing output.
*/
if( options )
options->get_operation( operation );
/* We're done with options!
*/
delete options;
/* The operation we have built should now have been reffed by
* one of its arguments or have finished its work. Either
* way, we can unref.
*/
g_object_unref( operation );
}
示例5: pyramid_new
static Layer *
pyramid_new( Write *write, Layer *above, int width, int height )
{
Layer *layer;
layer = VIPS_NEW( write->im, Layer );
layer->write = write;
layer->width = width;
layer->height = height;
if( !above )
/* Top of pyramid.
*/
layer->sub = 1;
else
layer->sub = above->sub * 2;
layer->lname = NULL;
layer->tif = NULL;
layer->image = NULL;
layer->write_y = 0;
layer->y = 0;
layer->strip = NULL;
layer->copy = NULL;
layer->below = NULL;
layer->above = above;
if( write->pyramid )
if( layer->width > write->tilew ||
layer->height > write->tileh )
layer->below = pyramid_new( write, layer,
width / 2, height / 2 );
/* The name for the top layer is the output filename.
*
* We need lname to be freed automatically: it has to stay
* alive until after write_gather().
*/
if( !above )
layer->lname = vips_strdup( VIPS_OBJECT( write->im ),
write->filename );
else {
char *lname;
lname = vips__temp_name( "%s.tif" );
layer->lname = vips_strdup( VIPS_OBJECT( write->im ), lname );
g_free( lname );
}
return( layer );
}
示例6: read_new_filename
static Read *
read_new_filename( VipsImage *out, const char *name, gboolean readbehind )
{
Read *read;
if( !(read = read_new( out, readbehind )) )
return( NULL );
read->name = vips_strdup( VIPS_OBJECT( out ), name );
if( !(read->fp = vips__file_open_read( name, NULL, FALSE )) )
return( NULL );
/* Catch PNG errors from png_read_info().
*/
if( setjmp( png_jmpbuf( read->pPng ) ) )
return( NULL );
/* Read enough of the file that png_get_interlace_type() will start
* working.
*/
png_init_io( read->pPng, read->fp );
png_read_info( read->pPng, read->pInfo );
return( read );
}
示例7: read_image
static int
read_image( Read *read, VipsImage *out )
{
VipsImage **t = (VipsImage **)
vips_object_local_array( VIPS_OBJECT( out ), 3 );
t[0] = vips_image_new_memory();
if( read_header( read, t[0] ) )
return( -1 );
if( vips_image_write_prepare( t[0] ) )
return( -1 );
read->config.output.u.RGBA.rgba = VIPS_IMAGE_ADDR( t[0], 0, 0 );
read->config.output.u.RGBA.stride = VIPS_IMAGE_SIZEOF_LINE( t[0] );
read->config.output.u.RGBA.size = VIPS_IMAGE_SIZEOF_IMAGE( t[0] );
read->config.output.is_external_memory = 1;
if( WebPDecode( (uint8_t *) read->data, read->length,
&read->config) != VP8_STATUS_OK ) {
vips_error( "webp2vips", "%s", _( "unable to read pixels" ) );
return( -1 );
}
if( vips_image_write( t[0], out ) )
return( -1 );
return( 0 );
}
示例8: read_mmap
/* Read a ppm/pgm file using mmap().
*/
static int
read_mmap( FILE *fp, const char *filename, int msb_first, VipsImage *out )
{
const guint64 header_offset = ftell( fp );
VipsImage *x = vips_image_new();
VipsImage **t = (VipsImage **)
vips_object_local_array( VIPS_OBJECT( x ), 3 );
if( vips_rawload( filename, &t[0],
out->Xsize, out->Ysize, VIPS_IMAGE_SIZEOF_PEL( out ),
"offset", header_offset,
NULL ) ||
vips_copy( t[0], &t[1],
"bands", out->Bands,
"format", out->BandFmt,
"coding", out->Coding,
NULL ) ||
vips_copy( t[1], &t[2],
"swap", !vips_amiMSBfirst(),
NULL ) ||
vips_image_write( t[2], out ) ) {
g_object_unref( x );
return( -1 );
}
g_object_unref( x );
return( 0 );
}
示例9: vips_cache_unref
static void
vips_cache_unref( VipsOperation *operation )
{
(void) vips_argument_map( VIPS_OBJECT( operation ),
vips_object_unref_arg, NULL, NULL );
g_object_unref( operation );
}
示例10: vo_args
/* Make a vo and supply args from nip2.
*/
static gboolean
vo_args( Vo *vo, PElement *required, PElement *optional )
{
/* Gather supplied required input args list.
*/
if( heap_map_list( required,
(heap_map_list_fn) vo_gather_required, vo, NULL ) )
return( FALSE );
/* Set required input arguments.
*/
if( vips_argument_map( VIPS_OBJECT( vo->object ),
(VipsArgumentMapFn) vo_set_required_input, vo, NULL ) )
return( FALSE );
if( vo->nargs_supplied != vo->nargs_required ) {
error_top( _( "Wrong number of required arguments." ) );
error_sub( _( "Operation \"%s\" has %d required arguments, "
"you supplied %d." ),
vo->name,
vo->nargs_required,
vo->nargs_supplied );
return( FALSE );
}
/* Set all optional input args.
*/
if( !vo_set_optional( vo, optional ) )
return( FALSE );
return( TRUE );
}
示例11: read_image
static int
read_image( Read *read, VipsImage *out )
{
VipsImage **t = (VipsImage **)
vips_object_local_array( VIPS_OBJECT( out ), 3 );
webp_decoder decoder;
t[0] = vips_image_new_memory();
if( read_header( read, t[0] ) )
return( -1 );
if( vips_image_write_prepare( t[0] ) )
return( -1 );
if( t[0]->Bands == 3 )
decoder = WebPDecodeRGBInto;
else
decoder = WebPDecodeRGBAInto;
if( !decoder( (uint8_t *) read->data, read->length,
VIPS_IMAGE_ADDR( t[0], 0, 0 ),
VIPS_IMAGE_SIZEOF_IMAGE( t[0] ),
VIPS_IMAGE_SIZEOF_LINE( t[0] ) ) ) {
vips_error( "webp2vips", "%s", _( "unable to read pixels" ) );
return( -1 );
}
if( vips_image_write( t[0], out ) )
return( -1 );
return( 0 );
}
示例12: png2vips_image
static int
png2vips_image( Read *read, VipsImage *out )
{
int interlace_type = png_get_interlace_type( read->pPng, read->pInfo );
VipsImage **t = (VipsImage **)
vips_object_local_array( VIPS_OBJECT( out ), 3 );
if( interlace_type != PNG_INTERLACE_NONE ) {
/* Arg awful interlaced image. We have to load to a huge mem
* buffer, then copy to out.
*/
t[0] = vips_image_new_memory();
if( png2vips_header( read, t[0] ) ||
png2vips_interlace( read, t[0] ) ||
vips_image_write( t[0], out ) )
return( -1 );
}
else {
t[0] = vips_image_new();
if( png2vips_header( read, t[0] ) ||
vips_image_generate( t[0],
NULL, png2vips_generate, NULL,
read, NULL ) ||
vips_sequential( t[0], &t[1],
"tile_height", 8,
"access", read->readbehind ?
VIPS_ACCESS_SEQUENTIAL :
VIPS_ACCESS_SEQUENTIAL_UNBUFFERED,
NULL ) ||
vips_image_write( t[1], out ) )
return( -1 );
}
return( 0 );
}
示例13: vips__ink_to_vector
/* The inverse: take ink to a vec of double. Used in the vips7 compat
* wrappers. Result valid while im is valid.
*/
double *
vips__ink_to_vector( const char *domain, VipsImage *im, VipsPel *ink, int *n )
{
VipsImage **t = (VipsImage **)
vips_object_local_array( VIPS_OBJECT( im ), 6 );
double *result;
#ifdef VIPS_DEBUG
printf( "vips__ink_to_vector: starting\n" );
#endif /*VIPS_DEBUG*/
/* Wrap a VipsImage around ink.
*/
t[0] = vips_image_new_from_memory( ink,
1, 1, VIPS_IMAGE_SIZEOF_PEL( im ), VIPS_FORMAT_UCHAR );
if( vips_copy( t[0], &t[1],
"bands", im->Bands,
"format", im->BandFmt,
"coding", im->Coding,
"interpretation", im->Type,
NULL ) )
return( NULL );
/* The image may be coded .. unpack to double.
*/
if( vips_image_decode( t[1], &t[2] ) ||
vips_cast( t[2], &t[3], VIPS_FORMAT_DOUBLE, NULL ) )
return( NULL );
/* To a mem buffer, then copy to out.
*/
if( !(t[4] = vips_image_new_memory()) ||
vips_image_write( t[3], t[4] ) )
return( NULL );
if( !(result = VIPS_ARRAY( im, t[4]->Bands, double )) )
return( NULL );
memcpy( result, t[4]->data, VIPS_IMAGE_SIZEOF_PEL( t[4] ) );
*n = t[4]->Bands;
#ifdef VIPS_DEBUG
{
int i;
printf( "vips__ink_to_vector:\n" );
printf( "\tink = " );
for( i = 0; i < n; i++ )
printf( "%d ", ink[i] );
printf( "\n" );
printf( "\tvec = " );
for( i = 0; i < *n; i++ )
printf( "%d ", result[i] );
printf( "\n" );
}
#endif /*VIPS_DEBUG*/
return( result );
}
示例14: vips_cache_ref
/* Ref an operation for the cache. The operation itself, plus all the output
* objects it makes.
*/
static void
vips_cache_ref( VipsOperation *operation )
{
g_object_ref( operation );
(void) vips_argument_map( VIPS_OBJECT( operation ),
vips_object_ref_arg, NULL, NULL );
vips_operation_touch( operation );
}
示例15: vips_interpolate_finalize
static void
vips_interpolate_finalize( GObject *gobject )
{
printf( "vips_interpolate_finalize: " );
vips_object_print( VIPS_OBJECT( gobject ) );
G_OBJECT_CLASS( vips_interpolate_parent_class )->finalize( gobject );
}