예제 #1
0
static void
vips_leak( void ) 
{
	char txt[1024];
	VipsBuf buf = VIPS_BUF_STATIC( txt );

	vips_object_print_all();

	if( vips_tracked_get_allocs() || 
		vips_tracked_get_mem() ||
		vips_tracked_get_files() ) {
		vips_buf_appendf( &buf, "memory: %d allocations, %zd bytes\n",
			vips_tracked_get_allocs(), vips_tracked_get_mem() );
		vips_buf_appendf( &buf, "files: %d open\n",
			vips_tracked_get_files() );
	}

	vips_buf_appendf( &buf, "memory: high-water mark " );
	vips_buf_append_size( &buf, vips_tracked_get_mem_highwater() );
	vips_buf_appends( &buf, "\n" );

	fprintf( stderr, "%s", vips_buf_all( &buf ) );

	vips__type_leak();
}
예제 #2
0
static void
vips_leak( void ) 
{
	char txt[1024];
	VipsBuf buf = VIPS_BUF_STATIC( txt );

	vips_object_print_all();

	if( vips_tracked_get_allocs() || 
		vips_tracked_get_mem() ||
		vips_tracked_get_files() ) {
		vips_buf_appendf( &buf, "memory: %d allocations, %zd bytes\n",
			vips_tracked_get_allocs(), vips_tracked_get_mem() );
		vips_buf_appendf( &buf, "files: %d open\n",
			vips_tracked_get_files() );
	}

	vips_buf_appendf( &buf, "memory: high-water mark " );
	vips_buf_append_size( &buf, vips_tracked_get_mem_highwater() );
	vips_buf_appends( &buf, "\n" );

	if( strlen( vips_error_buffer() ) > 0 ) 
		vips_buf_appendf( &buf, "error buffer: %s", 
			vips_error_buffer() );

	fprintf( stderr, "%s", vips_buf_all( &buf ) );


#ifdef DEBUG
	vips_buffer_dump_all();
#endif /*DEBUG*/
}
예제 #3
0
static void 
expressionview_refresh( vObject *vobject )
{
	Expressionview *expressionview = EXPRESSIONVIEW( vobject );
	Expression *expression = 
		EXPRESSION( VOBJECT( expressionview )->iobject );
	iText *itext = expression_get_itext( expression );
	Row *row = HEAPMODEL( expression )->row;

#ifdef DEBUG
	printf( "expressionview_refresh: " );
	row_name_print( row );
	printf( " (%p)\n", vobject );
#endif /*DEBUG*/

	formula_set_edit( expressionview->formula, 
		row->ws->mode == WORKSPACE_MODE_FORMULA );
	if( itext ) 
		formula_set_value_expr( expressionview->formula,
			vips_buf_all( &itext->value ), itext->formula );
	if( vobject->iobject->caption )
		formula_set_caption( expressionview->formula,
			vobject->iobject->caption );

	VOBJECT_CLASS( parent_class )->refresh( vobject );
}
예제 #4
0
파일: exif.c 프로젝트: jcupitt/libvips
static void
vips_exif_exif_entry( ExifEntry *entry, VipsExifRemove *ve )
{
	const char *tag_name;
	char vips_name_txt[256];
	VipsBuf vips_name = VIPS_BUF_STATIC( vips_name_txt );

	if( !(tag_name = vips_exif_entry_get_name( entry )) )
		return;

	vips_buf_appendf( &vips_name, "exif-ifd%d-%s", 
		exif_entry_get_ifd( entry ), tag_name );

	/* Does this field exist on the image? If not, schedule it for
	 * removal.
	 */
	if( !vips_image_get_typeof( ve->image, vips_buf_all( &vips_name ) ) ) 
		ve->to_remove = g_slist_prepend( ve->to_remove, entry );

	/* Orientation is really set from the vips
	 * VIPS_META_ORIENTATION tag. If that's been deleted, we must delete
	 * any matching EXIF tags too.
	 */
	if( strcmp( tag_name, "Orientation" ) == 0 &&
		vips_image_get_typeof( ve->image, VIPS_META_ORIENTATION ) )
		ve->to_remove = g_slist_prepend( ve->to_remove, entry );

	/* If this is a string tag, we must also remove it ready for
	 * recreation, see the comment below.
	 */
	if( tag_is_encoding( entry->tag ) ||
		tag_is_ascii( entry->tag ) ||
		tag_is_utf16( entry->tag ) )
		ve->to_remove = g_slist_prepend( ve->to_remove, entry );
}
예제 #5
0
/**
 * im_system:
 * @im: image to run command on
 * @cmd: command to run
 * @out: stdout of command is returned here
 *
 * im_system() runs a command on an image, returning the command's output as a
 * string. The command is executed with popen(), the first '%%s' in the 
 * command being substituted for a filename.
 *
 * If the IMAGE is a file on disc, then the filename will be the name of the 
 * real file. If the image is in memory, or the result of a computation, 
 * then a new file is created in the temporary area called something like 
 * "vips_XXXXXX.v", and that filename given to the command. The file is 
 * deleted when the command finishes.
 *
 * The environment variable TMPDIR can be used to set the temporary 
 * directory. If it is not set, it defaults to "/tmp".
 *
 * In all cases, @log must be freed with im_free().
 *
 * See also: im_system_image().
 *
 * Returns: 0 on success, -1 on error
 */
int
im_system( IMAGE *im, const char *cmd, char **out )
{
	FILE *fp;

	if( !im_isfile( im ) ) {
		IMAGE *disc;

		if( !(disc = im__open_temp( "%s.v" )) )
			return( -1 );
		if( im_copy( im, disc ) ||
			im_system( disc, cmd, out ) ) {
			im_close( disc );
			return( -1 );
		}
		im_close( disc );
	}
	else if( (fp = im_popenf( cmd, "r", im->filename )) ) {
		char line[IM_MAX_STRSIZE];
		char txt[IM_MAX_STRSIZE];
		VipsBuf buf = VIPS_BUF_STATIC( txt );

		while( fgets( line, IM_MAX_STRSIZE, fp ) ) 
			if( !vips_buf_appends( &buf, line ) )
				break; 
		pclose( fp );

		if( out )
			*out = im_strdup( NULL, vips_buf_all( &buf ) );
	}

	return( 0 );
}
예제 #6
0
파일: stringview.c 프로젝트: DINKIN/nip2
static void 
stringview_refresh( vObject *vobject )
{
	Stringview *stringview = STRINGVIEW( vobject );
	String *string = STRING( VOBJECT( stringview )->iobject );

#ifdef DEBUG
	Row *row = HEAPMODEL( string )->row;

	printf( "stringview_refresh: " );
	row_name_print( row );
	printf( " (%p)\n", vobject );
#endif /*DEBUG*/

	if( string->value ) {
		char txt[MAX_STRSIZE];
		VipsBuf buf = VIPS_BUF_STATIC( txt );

		vips_buf_appendsc( &buf, FALSE, string->value );
		editview_set_entry( EDITVIEW( stringview ), 
			"%s", vips_buf_all( &buf ) );
	}

	VOBJECT_CLASS( parent_class )->refresh( vobject );
}
예제 #7
0
파일: jpeg2vips.c 프로젝트: jieah/libvips
static void
attach_exif_entry( ExifEntry *entry, VipsExif *ve )
{
    char name_txt[256];
    VipsBuf name = VIPS_BUF_STATIC( name_txt );
    char value_txt[256];
    VipsBuf value = VIPS_BUF_STATIC( value_txt );

    vips_buf_appendf( &name, "exif-ifd%d-%s",
                      exif_entry_get_ifd( entry ),
                      exif_tag_get_title( entry->tag ) );
    vips_exif_to_s( ve->ed, entry, &value );

    /* Can't do anything sensible with the error return.
     */
    (void) vips_image_set_string( ve->image,
                                  vips_buf_all( &name ), vips_buf_all( &value ) );
}
예제 #8
0
파일: workspaceview.c 프로젝트: DINKIN/nip2
static void
workspaceview_drag_data_received( GtkWidget *widget, GdkDragContext *context,
	gint x, gint y, GtkSelectionData *selection_data,
	guint info, guint time ) 
{
	Workspaceview *wview = WORKSPACEVIEW( widget );
	Workspace *ws = WORKSPACE( VOBJECT( wview )->iobject );
	const char *from_row_path = (const char *) selection_data->data;
	Row *from_row;

#ifdef DEBUG
	printf( "workspaceview_drag_data_received:\n" );
#endif /*DEBUG*/

	/* We seem to rx drag events with x/y relative to the viewport.
	 */
	x += wview->vp.left;
	y += wview->vp.top;

	if( info == TARGET_SYMBOL && selection_data->length > 0 && 
		selection_data->format == 8 &&
		workspaceview_is_background( wview, 
			GTK_WIDGET( wview->fixed )->window, x, y ) &&
		(from_row = row_parse_name( main_workspaceroot->sym, 
			from_row_path )) ) {
		char new_name[MAX_STRSIZE];
		Column *col;
		char vips_buf_text[256];
		VipsBuf buf = VIPS_BUF_STATIC( vips_buf_text );
		Symbol *sym;

		workspace_column_name_new( ws, new_name );
		col = column_new( ws, new_name );

		col->x = x;
		col->y = y;
		workspace_column_select( ws, col );

		/* Qualify relative to us. We don't want to embed
		 * workspace names unless we have to.
		 */
		row_qualified_name_relative( ws->sym, from_row, &buf );

		if( !(sym = workspace_add_def( ws, vips_buf_all( &buf ) )) ) 
			iwindow_alert( widget, GTK_MESSAGE_ERROR );

		symbol_recalculate_all();

		/* Usually the drag-from row will be selected, very
		 * annoying. Select the drag-to row.
		 */
		if( sym && 
			sym->expr && 
			sym->expr->row )
			row_select( sym->expr->row );
	}
}
예제 #9
0
파일: error.c 프로젝트: Ikulagin/transmem
/**
 * im_error_buffer: 
 *
 * Get a pointer to the start of the error buffer as a C string.
 * The string is owned by the error system and must not be freed.
 *
 * See also: im_error_clear().
 *
 * Returns: the error buffer as a C string which must not be freed
 */
const char *
im_error_buffer( void )
{
	const char *msg;

	g_mutex_lock( im__global_lock );
	msg = vips_buf_all( &im_error_buf );
	g_mutex_unlock( im__global_lock );

	return( msg );
}
예제 #10
0
파일: workspacedefs.c 프로젝트: DINKIN/nip2
static void
workspacedefs_refresh( vObject *vobject )
{
	Workspacedefs *workspacedefs = WORKSPACEDEFS( vobject );
	Workspace *ws = workspacedefs->ws;
	char txt[256];
	VipsBuf buf = VIPS_BUF_STATIC( txt );

#ifdef DEBUG
	printf( "workspacedefs_refresh:\n" );
#endif /*DEBUG*/

	if( !workspacedefs->changed ) {
		guint text_hash = g_str_hash( ws->local_defs );

		if( text_hash != workspacedefs->text_hash ) {
			g_signal_handlers_block_by_func( 
				gtk_text_view_get_buffer( 
					GTK_TEXT_VIEW( workspacedefs->text ) ),
				workspacedefs_text_changed, workspacedefs );
			text_view_set_text( 
				GTK_TEXT_VIEW( workspacedefs->text ), 
				ws->local_defs, TRUE );
			g_signal_handlers_unblock_by_func( 
				gtk_text_view_get_buffer( 
					GTK_TEXT_VIEW( workspacedefs->text ) ),
				workspacedefs_text_changed, workspacedefs );

			workspacedefs->text_hash = text_hash;
		}
	}

	if( ws->local_kit ) {
		int n = icontainer_get_n_children( ICONTAINER( 
			ws->local_kit ) );

		vips_buf_appendf( &buf, ngettext( "%d definition", 
			"%d definitions", n ), n );
	}
	if( workspacedefs->errors ) {
		if( !vips_buf_is_empty( &buf ) )
			vips_buf_appendf( &buf, ", " ); 
		vips_buf_appendf( &buf, _( "errors" ) ); 
	}
	if( workspacedefs->changed ) {
		if( !vips_buf_is_empty( &buf ) )
			vips_buf_appendf( &buf, ", " ); 
		vips_buf_appendf( &buf, _( "modified" ) ); 
	}
	set_glabel( workspacedefs->status, "%s", vips_buf_all( &buf ) );

	VOBJECT_CLASS( parent_class )->refresh( vobject );
}
예제 #11
0
static void *
vips_cache_print_fn( void *value, void *a, void *b )
{
	char str[32768];
	VipsBuf buf = VIPS_BUF_STATIC( str );

	vips_object_to_string( VIPS_OBJECT( value ), &buf );

	printf( "%p - %s\n", value, vips_buf_all( &buf ) );

	return( NULL );
}
예제 #12
0
파일: exif.c 프로젝트: jcupitt/libvips
static void
vips_exif_attach_entry( ExifEntry *entry, VipsExifParams *params )
{
	const char *tag_name;
	char vips_name_txt[256];
	VipsBuf vips_name = VIPS_BUF_STATIC( vips_name_txt );
	char value_txt[256];
	VipsBuf value = VIPS_BUF_STATIC( value_txt );

	if( !(tag_name = vips_exif_entry_get_name( entry )) )
		return;

	vips_buf_appendf( &vips_name, "exif-ifd%d-%s", 
		exif_entry_get_ifd( entry ), tag_name );
	vips_exif_to_s( params->ed, entry, &value ); 

	/* Can't do anything sensible with the error return.
	 */
	(void) vips_image_set_string( params->image, 
		vips_buf_all( &vips_name ), vips_buf_all( &value ) );
}
예제 #13
0
파일: builtin.c 프로젝트: DINKIN/nip2
/* Do "print".
 */
static void
apply_print_call( Reduce *rc, const char *name, HeapNode **arg, PElement *out )
{
	PElement rhs;
	char txt[MAX_STRSIZE];
	VipsBuf buf = VIPS_BUF_STATIC( txt );

	PEPOINTRIGHT( arg[0], &rhs );
	itext_value_ev( rc, &buf, &rhs );

	if( !heap_managedstring_new( rc->heap, vips_buf_all( &buf ), out ) )
		reduce_throw( rc );
}
예제 #14
0
static void
attach_exif_entry( ExifEntry *entry, IMAGE *im )
{
	char name_text[256];
	VipsBuf name;
	char value_text[256];
	VipsBuf value;
	char exif_value[256];

	vips_buf_init_static( &name, name_text, 256 );
	vips_buf_init_static( &value, value_text, 256 );

	vips_buf_appendf( &name, "exif-%s", exif_tag_get_title( entry->tag ) );
	vips_buf_appendf( &value, "%s (%s, %d bytes)", 
		exif_entry_get_value( entry, exif_value, 256 ),
		exif_format_get_name( entry->format ),
		entry->size );

	/* Can't do anything sensible with the error return.
	 */
	(void) im_meta_set_string( im, 
		vips_buf_all( &name ), vips_buf_all( &value ) );
}
예제 #15
0
static void *
vips_cache_print_fn( void *value, void *a, void *b )
{
	VipsOperationCacheEntry *entry = value;

	char str[32768];
	VipsBuf buf = VIPS_BUF_STATIC( str );

	vips_object_to_string( VIPS_OBJECT( entry->operation ), &buf );

	printf( "%p - %s\n", value, vips_buf_all( &buf ) );

	return( NULL );
}
예제 #16
0
파일: workspace.c 프로젝트: imclab/nip2
/* Load a matrix or image. Don't recalc: you need to recalc later to test for
 * success/fail. See eg. workspace_add_def_recalc()
 */
Symbol *
workspace_load_file( Workspace *ws, const char *filename )
{
	char txt[MAX_STRSIZE];
	VipsBuf buf = VIPS_BUF_STATIC( txt );
	Symbol *sym;

	if( !workspace_load_file_buf( &buf, filename ) )
		return( NULL );
	if( !(sym = workspace_add_def( ws, vips_buf_all( &buf ) )) ) 
		return( NULL );
	mainw_recent_add( &mainw_recent_image, filename );

	return( sym );
}
예제 #17
0
파일: row.c 프로젝트: imclab/nip2
/* Convenience ... print a row name out, identifying by tally heirarchy.
 */
void *
row_name_print( Row *row )
{
	if( row ) {
		char txt[100];
		VipsBuf buf = VIPS_BUF_STATIC( txt );

		row_qualified_name( row, &buf );
		printf( "%s ", vips_buf_all( &buf ) );
	}
	else
		printf( "(null)" );

	return( NULL );
}
예제 #18
0
파일: colourview.c 프로젝트: DINKIN/nip2
static void 
colourview_refresh( vObject *vobject )
{
	Colourview *colourview = COLOURVIEW( vobject );
	Colour *colour = COLOUR( vobject->iobject );

#ifdef DEBUG
	printf( "colourview_refresh\n" );
#endif /*DEBUG*/

	conversion_set_image( colourview->conv, colour_ii_new( colour ) );
	set_gcaption( colourview->label, "%s", vips_buf_all( &colour->caption ) );

	VOBJECT_CLASS( parent_class )->refresh( vobject );
}
예제 #19
0
파일: vipsobject.c 프로젝트: jcupitt/nip2
/* Make a VipsObject.
 */
void
vo_object_new( Reduce *rc, const char *name, 
	PElement *required, PElement *optional, PElement *out )
{
	Vo *vo;
	Managedgobject *managedgobject;

	if( !(vo = vo_new( rc, name )) ) 
		reduce_throw( rc );

	if( !vo_args( vo, required, optional ) ) {
		vo_free( vo );
		reduce_throw( rc );
	}

	/* Ask the object to construct.
	 */
	if( vips_object_build( vo->object ) ) {
		error_top( _( "VIPS library error." ) );
		error_sub( "%s", im_error_buffer() );
		im_error_clear();
		vo_free( vo );
		reduce_throw( rc );
	}

	/* Return the constructed object.
	 */
	if( !(managedgobject = managedgobject_new( vo->rc->heap, 
		G_OBJECT( vo->object ) )) ) {
		vo_free( vo );
		reduce_throw( rc );
	}

	PEPUTP( out, ELEMENT_MANAGED, managedgobject );

#ifdef DEBUG
{
	char txt[1000];
	VipsBuf buf = VIPS_BUF_STATIC( txt );

	vips_object_to_string( vo->object, &buf );
	printf( "vo_object_new: built %s\n", vips_buf_all( &buf ) );
}
#endif /*DEBUG*/

	vo_free( vo );
}
예제 #20
0
파일: builtin.c 프로젝트: DINKIN/nip2
/* Do a graph_export_image call.
 */
static void
apply_graph_export_image_call( Reduce *rc, 
	const char *name, HeapNode **arg, PElement *out )
{
#ifdef HAVE_LIBGOFFICE
	PElement rhs;
	double dpi;
	Plot *plot;
	Imageinfo *ii;

	PEPOINTRIGHT( arg[1], &rhs );
	dpi = PEGETREAL( &rhs );

	PEPOINTRIGHT( arg[0], &rhs );
	if( !reduce_is_instanceof( rc, CLASS_PLOT, &rhs ) ) {
		char txt[100];
		VipsBuf buf = VIPS_BUF_STATIC( txt );

		itext_value_ev( rc, &buf, &rhs );
		error_top( _( "Bad argument." ) );
		error_sub( _( "Argument 2 to \"%s\" should "
			"be instance of \"%s\", you passed:\n  %s" ),
			name, CLASS_PLOT,
			vips_buf_all( &buf ) );
		reduce_throw( rc );
	}

	plot = g_object_new( TYPE_PLOT, NULL );

	if( !classmodel_update_members( CLASSMODEL( plot ), &rhs ) ) {
		UNREF( plot );
		reduce_throw( rc );
	}

	if( !(ii = plot_to_image( plot, rc, dpi )) ) {
		UNREF( plot );
		reduce_throw( rc );
	}
	UNREF( plot );

	PEPUTP( out, ELEMENT_MANAGED, ii );
#else /*!HAVE_LIBGOFFICE*/
	PEPUTP( out, ELEMENT_BOOL, TRUE );
#endif /*HAVE_LIBGOFFICE*/
}
예제 #21
0
파일: row.c 프로젝트: imclab/nip2
/* Mark a row as containing an error ... called from expr_error_set()
 * ... don't call this directly.
 */
void
row_error_set( Row *row )
{
	if( !row->err ) {
		Workspace *ws = row->ws;
		gboolean was_clear = ws->errors == NULL;

		ws->errors = g_slist_prepend( ws->errors, row );
		row->err = TRUE;

#ifdef DEBUG_ERROR
		printf( "row_error_set: " );
		row_name_print( row );
		printf( "\n" );
#endif /*DEBUG_ERROR*/

		iobject_changed( IOBJECT( row ) );

		/* First error? State change on workspace.
		 */
		if( was_clear )
			iobject_changed( IOBJECT( ws ) );

		/* If this is a local row, mark the top row in error too to end
		 * recomp on this tree.
		 */
		if( row != row->top_row ) {
			char txt[100];
			VipsBuf buf = VIPS_BUF_STATIC( txt );

			row_qualified_name( row, &buf );

			error_top( _( "Error in row." ) );
			/* Elements are name of row, principal error,
			 * secondary error.
			 */
			error_sub( _( "Error in row %s: %s\n%s" ),	
				vips_buf_all( &buf ),
				row->expr->error_top,
				row->expr->error_sub );

			expr_error_set( row->top_row->expr );
		}
	}
}
예제 #22
0
파일: type.c 프로젝트: alon/libvips
static void
transform_array_double_g_string( const GValue *src_value, GValue *dest_value )
{
	int n;
	double *array = vips_value_get_array_double( src_value, &n );

	char txt[1024];
	VipsBuf buf = VIPS_BUF_STATIC( txt );
	int i;

	for( i = 0; i < n; i++ ) 
		/* Use space as a separator since ',' may be a decimal point
		 * in this locale.
		 */
		vips_buf_appendf( &buf, "%g ", array[i] );

	g_value_set_string( dest_value, vips_buf_all( &buf ) );
}
예제 #23
0
파일: iimage.c 프로젝트: DINKIN/nip2
/* Return the main caption. 
 */
static const char *
iimage_generate_caption( iObject *iobject ) 
{
	iImage *iimage = IIMAGE( iobject );
	Imageinfo *ii = iimage->value.ii;
	VipsBuf *buf = &iimage->caption_buffer;

	vips_buf_rewind( buf );

	image_value_caption( &iimage->value, buf );

	if( ii ) {
		vips_buf_appends( buf, ", " );
		iobject_info( IOBJECT( iimage->value.ii ), buf );
	}

	return( vips_buf_all( buf ) );
}
예제 #24
0
/* similarity+tbmerge.
 */
int
im__tbmerge1( IMAGE *ref, IMAGE *sec, IMAGE *out,
	double a, double b, double dx, double dy, int mwidth )
{
	VipsTransformation trn;
	IMAGE *t1 = im_open_local( out, "im_lrmosaic1:2", "p" );
	VipsBuf buf;
	char text[1024];

	/* Scale, rotate and displace sec.
	 */
	if( !t1 || apply_similarity( &trn, sec, t1, a, b, dx, dy ) )
		return( -1 );

	/* And join to ref.
	 */
	if( im__tbmerge( ref, t1, out, 
		-trn.oarea.left, -trn.oarea.top, mwidth ) )
		return( -1 );

	/* Note parameters in history file ... for global balance to pick up
	 * later.
	 */
	im__add_mosaic_name( out );
	vips_buf_init_static( &buf, text, 1024 );
	vips_buf_appendf( &buf, "#TBROTSCALE <%s> <%s> <%s> <",
		im__get_mosaic_name( ref ), 
		im__get_mosaic_name( sec ), 
		im__get_mosaic_name( out ) );  
	vips_buf_appendg( &buf, a );
	vips_buf_appendf( &buf, "> <" );
	vips_buf_appendg( &buf, b );
	vips_buf_appendf( &buf, "> <" );
	vips_buf_appendg( &buf, dx );
	vips_buf_appendf( &buf, "> <" );
	vips_buf_appendg( &buf, dy );
	vips_buf_appendf( &buf, "> <%d>", mwidth );
	if( im_histlin( out, "%s", vips_buf_all( &buf ) ) )
		return( -1 );

	return( 0 );
}
예제 #25
0
파일: exif.c 프로젝트: jcupitt/libvips
static void *
vips_exif_exif_remove( ExifEntry *entry, VipsExifRemove *ve )
{
#ifdef DEBUG
{
	const char *tag_name;
	char vips_name_txt[256];
	VipsBuf vips_name = VIPS_BUF_STATIC( vips_name_txt );

	tag_name = vips_exif_entry_get_name( entry );
	vips_buf_appendf( &vips_name, "exif-ifd%d-%s", 
		exif_entry_get_ifd( entry ), tag_name );

	printf( "vips_exif_exif_remove: %s\n", vips_buf_all( &vips_name ) );
}
#endif /*DEBUG*/

	exif_content_remove_entry( ve->content, entry );

	return( NULL );
}
예제 #26
0
파일: iimage.c 프로젝트: DINKIN/nip2
gboolean
iimage_replace( iImage *iimage, const char *filename )
{
	Row *row = HEAPMODEL( iimage )->row;
	iText *itext = ITEXT( HEAPMODEL( iimage )->rhs->itext );
	char txt[MAX_STRSIZE];
	VipsBuf buf = VIPS_BUF_STATIC( txt );

	vips_buf_appends( &buf, "Image_file \"" );
	vips_buf_appendsc( &buf, TRUE, filename );
	vips_buf_appends( &buf, "\"" );

	if( itext_set_formula( itext, vips_buf_all( &buf ) ) ) {
		itext_set_edited( itext, TRUE );
		workspace_set_modified( row->ws, TRUE );
		(void) expr_dirty( row->expr, link_serial_new() );

		mainw_recent_add( &mainw_recent_image, filename );
	}

	return( TRUE );
}
예제 #27
0
파일: imageheader.c 프로젝트: DINKIN/nip2
static void *
imageheader_add_item( IMAGE *im, 
	const char *field, GValue *value, Imageheader *imageheader )
{
	char txt[256];
	VipsBuf buf = VIPS_BUF_STATIC( txt );
	GtkTreeIter iter;
        char *value_str;
	const char *extra;

	value_str = g_strdup_value_contents( value );
	vips_buf_appendf( &buf, "%s", value_str );

	/* Look for enums and decode them.
	 */
	extra = NULL;
	if( strcmp( field, "coding" ) == 0 )
		extra = vips_enum_nick( VIPS_TYPE_CODING, 
			g_value_get_int( value ) );
	else if( strcmp( field, "format" ) == 0 )
		extra = vips_enum_nick( VIPS_TYPE_BAND_FORMAT, 
			g_value_get_int( value ) );
	else if( strcmp( field, "interpretation" ) == 0 )
		extra = vips_enum_nick( VIPS_TYPE_INTERPRETATION, 
			g_value_get_int( value ) );
	if( extra )
		vips_buf_appendf( &buf, " - %s", extra );

	gtk_list_store_append( imageheader->store, &iter );
	gtk_list_store_set( imageheader->store, &iter,
		NAME_COLUMN, field,
		VALUE_COLUMN, vips_buf_all( &buf ),
		-1 );

	g_free( value_str );

	return( NULL );
}
예제 #28
0
파일: iimage.c 프로젝트: DINKIN/nip2
void
iimage_header( GtkWidget *parent, Model *model )
{
        iImage *iimage = IIMAGE( model );
	Row *row = HEAPMODEL( iimage )->row;
	Workspace *ws = row_get_workspace( row );

	GtkWidget *imageheader;
	char txt[512];
	VipsBuf buf = VIPS_BUF_STATIC( txt );

	imageheader = imageheader_new( iimage );
	row_qualified_name_relative( ws->sym, row, &buf );
	iwindow_set_title( IWINDOW( imageheader ), 
		_( "Header for \"%s\"" ), vips_buf_all( &buf ) );
	idialog_set_callbacks( IDIALOG( imageheader ), NULL, NULL, NULL, NULL );
	idialog_add_ok( IDIALOG( imageheader ), iwindow_true_cb, _( "OK" ) );
	iwindow_set_parent( IWINDOW( imageheader ), parent );
	idialog_set_iobject( IDIALOG( imageheader ), IOBJECT( iimage ) );
	iwindow_build( IWINDOW( imageheader ) );

	gtk_widget_show( imageheader );
}
예제 #29
0
static int
parse_header( Read *read )
{
	VipsImage *im = read->im;
	Image *image = read->image;

	Image *p;
	int i;

#ifdef DEBUG
	printf( "parse_header: filename = %s\n", read->filename );
	printf( "GetImageChannelDepth(AllChannels) = %zd\n",
		GetImageChannelDepth( image, AllChannels, &image->exception ) );
	printf( "GetImageDepth() = %zd\n",
		GetImageDepth( image, &image->exception ) );
	printf( "image->depth = %zd\n", image->depth );
	printf( "GetImageType() = %d\n",
		GetImageType( image, &image->exception ) );
	printf( "IsGrayImage() = %d\n",
		IsGrayImage( image, &image->exception ) );
	printf( "IsMonochromeImage() = %d\n",
		IsMonochromeImage( image, &image->exception ) );
	printf( "IsOpaqueImage() = %d\n",
		IsOpaqueImage( image, &image->exception ) );
	printf( "image->columns = %zd\n", image->columns ); 
	printf( "image->rows = %zd\n", image->rows ); 
#endif /*DEBUG*/

	im->Xsize = image->columns;
	im->Ysize = image->rows;
	read->frame_height = image->rows;
	if( (im->Bands = get_bands( image )) < 0 )
		return( -1 );

	/* Depth can be 'fractional'. You'd think we should use
	 * GetImageDepth() but that seems unreliable. 16-bit mono DICOM images 
	 * are reported as depth 1, for example.
	 */
	im->BandFmt = -1;
	if( image->depth >= 1 && image->depth <= 8 ) 
		im->BandFmt = VIPS_FORMAT_UCHAR;
	if( image->depth >= 9 && image->depth <= 16 ) 
		im->BandFmt = VIPS_FORMAT_USHORT;
#ifdef UseHDRI
	if( image->depth == 32 )
		im->BandFmt = VIPS_FORMAT_FLOAT;
	if( image->depth == 64 )
		im->BandFmt = VIPS_FORMAT_DOUBLE;
#else /*!UseHDRI*/
	if( image->depth == 32 )
		im->BandFmt = VIPS_FORMAT_UINT;
#endif /*UseHDRI*/

	if( im->BandFmt == -1 ) {
		vips_error( "magick2vips", _( "unsupported bit depth %d" ),
			(int) image->depth );
		return( -1 );
	}

	switch( image->colorspace ) {
	case GRAYColorspace:
		if( im->BandFmt == VIPS_FORMAT_USHORT )
			im->Type = VIPS_INTERPRETATION_GREY16;
		else
			im->Type = VIPS_INTERPRETATION_B_W;
		break;

	case RGBColorspace:
		if( im->BandFmt == VIPS_FORMAT_USHORT )
			im->Type = VIPS_INTERPRETATION_RGB16;
		else
			im->Type = VIPS_INTERPRETATION_RGB;
		break;

	case sRGBColorspace:
		if( im->BandFmt == VIPS_FORMAT_USHORT )
			im->Type = VIPS_INTERPRETATION_RGB16;
		else
			im->Type = VIPS_INTERPRETATION_sRGB;
		break;

	case CMYKColorspace:
		im->Type = VIPS_INTERPRETATION_CMYK;
		break;

	default:
		vips_error( "magick2vips", _( "unsupported colorspace %d" ),
			(int) image->colorspace );
		return( -1 );
	}

	switch( image->units ) {
	case PixelsPerInchResolution:
		im->Xres = image->x_resolution / 25.4;
		im->Yres = image->y_resolution / 25.4;
		break;

	case PixelsPerCentimeterResolution:
		im->Xres = image->x_resolution / 10.0;
		im->Yres = image->y_resolution / 10.0;
		break;

	default:
		im->Xres = 1.0;
		im->Yres = 1.0;
		break;
	}

	/* Other fields.
	 */
	im->Coding = VIPS_CODING_NONE;

	vips_image_pipelinev( im, VIPS_DEMAND_STYLE_SMALLTILE, NULL );

	/* Three ways to loop over attributes / properties :-(
	 */

#ifdef HAVE_RESETIMAGEPROPERTYITERATOR
{
	char *key;

	/* This is the most recent imagemagick API, test for this first.
	 */
	ResetImagePropertyIterator( image );
	while( (key = GetNextImageProperty( image )) ) {
		char name_text[256];
		VipsBuf name = VIPS_BUF_STATIC( name_text );

		vips_buf_appendf( &name, "magick-%s", key );
		vips_image_set_string( im, 
			vips_buf_all( &name ), GetImageProperty( image, key ) );
	}
}
#elif defined(HAVE_RESETIMAGEATTRIBUTEITERATOR)
{
	const ImageAttribute *attr;

	/* magick6.1-ish and later, deprecated in 6.5ish.
	 */
	ResetImageAttributeIterator( image );
	while( (attr = GetNextImageAttribute( image )) ) {
		char name_text[256];
		VipsBuf name = VIPS_BUF_STATIC( name_text );

		vips_buf_appendf( &name, "magick-%s", attr->key );
		vips_image_set_string( im, vips_buf_all( &name ), attr->value );
	}
}
#else
{
	const ImageAttribute *attr;

	/* GraphicsMagick is missing the iterator: we have to loop ourselves.
	 * ->attributes is marked as private in the header, but there's no
	 * getter so we have to access it directly.
	 */
	for( attr = image->attributes; attr; attr = attr->next ) {
		char name_text[256];
		VipsBuf name = VIPS_BUF_STATIC( name_text );

		vips_buf_appendf( &name, "magick-%s", attr->key );
		vips_image_set_string( im, vips_buf_all( &name ), attr->value );
	}
}
#endif 

	/* Do we have a set of equal-sized frames? Append them.

	   	FIXME ... there must be an attribute somewhere from dicom read 
		which says this is a volumetric image

	 */
	read->n_frames = 0;
	for( p = image; p; (p = GetNextImageInList( p )) ) {
		if( p->columns != (unsigned int) im->Xsize ||
			p->rows != (unsigned int) im->Ysize ||
			get_bands( p ) != im->Bands )
			break;

		read->n_frames += 1;
	}
	if( p ) 
		/* Nope ... just do the first image in the list.
		 */
		read->n_frames = 1;

#ifdef DEBUG
	printf( "image has %d frames\n", read->n_frames );
#endif /*DEBUG*/

	/* If all_frames is off, just get the first one.
	 */
	if( !read->all_frames )
		read->n_frames = 1;

	/* Record frame pointers.
	 */
	im->Ysize *= read->n_frames;
	if( !(read->frames = VIPS_ARRAY( NULL, read->n_frames, Image * )) )
		return( -1 );
	p = image;
	for( i = 0; i < read->n_frames; i++ ) {
		read->frames[i] = p;
		p = GetNextImageInList( p );
	}

	return( 0 );
}
예제 #30
0
파일: object.c 프로젝트: aturcotte/libvips
	printf( "vips_object_build: " );
	vips_object_print_name( object );
	printf( "\n" );
#endif /*DEBUG*/

	return( object_class->build( object ) );
}

void
vips_object_print_class( VipsObjectClass *class )
{
	char str[1000];
	VipsBuf buf = VIPS_BUF_STATIC( str );

	class->print_class( class, &buf );
	printf( "%s\n", vips_buf_all( &buf ) );
}

void
vips_object_print( VipsObject *object )
{
	VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );

	/* This is used for printing image headers, so we may need lots of
	 * space. See header.c.
	 */
	char str[32768];
	VipsBuf buf = VIPS_BUF_STATIC( str );

	vips_object_print_class( class );
	class->print( object, &buf );