create output images in _build()
new idea: output image get made in _build(), we copy them out after calling the operation's build, see TODO vips_image_new() param removed, it just always makes "p" images now
This commit is contained in:
parent
c4804b6fb3
commit
79a7a37d71
@ -71,13 +71,16 @@ G_DEFINE_ABSTRACT_TYPE( VipsArithmetic, vips_arithmetic, VIPS_TYPE_OPERATION );
|
||||
static int
|
||||
vips_arithmetic_build( VipsObject *object )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
VipsArithmetic *arithmetic = VIPS_ARITHMETIC( object );
|
||||
#endif /*DEBUG*/
|
||||
VipsImage *out;
|
||||
|
||||
if( VIPS_OBJECT_CLASS( vips_arithmetic_parent_class )->build( object ) )
|
||||
return( -1 );
|
||||
|
||||
if( !(out = vips_image_new()) )
|
||||
return( -1 );
|
||||
g_object_set( arithmetic, "out", out, NULL );
|
||||
|
||||
/* Should we _generate() here? We should keep the params in the object
|
||||
* ready to be dropped in.
|
||||
*
|
||||
|
@ -192,7 +192,7 @@ im_init( const char *filename )
|
||||
{
|
||||
VipsImage *image;
|
||||
|
||||
image = vips_image_new( "p" );
|
||||
image = vips_image_new();
|
||||
VIPS_SETSTR( image->filename, filename );
|
||||
|
||||
return( image );
|
||||
|
@ -475,14 +475,14 @@ im_fits2vips( const char *filename, VipsImage *out )
|
||||
* separately then join them.
|
||||
*/
|
||||
|
||||
if( !(t = vips_image_new( "p" )) ||
|
||||
if( !(t = vips_image_new()) ||
|
||||
vips_object_local( out, t ) ||
|
||||
fits2vips_header( filename, t ) )
|
||||
return( -1 );
|
||||
n_bands = t->Bands;
|
||||
|
||||
if( n_bands == 1 ) {
|
||||
if( !(t = vips_image_new( "p" )) ||
|
||||
if( !(t = vips_image_new()) ||
|
||||
vips_object_local( out, t ) ||
|
||||
fits2vips( filename, t, 0 ) )
|
||||
return( -1 );
|
||||
@ -493,7 +493,7 @@ im_fits2vips( const char *filename, VipsImage *out )
|
||||
|
||||
acc = NULL;
|
||||
for( i = 0; i < n_bands; i++ ) {
|
||||
if( !(t = vips_image_new( "p" )) ||
|
||||
if( !(t = vips_image_new()) ||
|
||||
vips_object_local( out, t ) ||
|
||||
fits2vips( filename, t, i ) )
|
||||
return( -1 );
|
||||
@ -503,7 +503,7 @@ im_fits2vips( const char *filename, VipsImage *out )
|
||||
else {
|
||||
VipsImage *t2;
|
||||
|
||||
if( !(t2 = vips_image_new( "p" )) ||
|
||||
if( !(t2 = vips_image_new()) ||
|
||||
vips_object_local( out, t2 ) ||
|
||||
im_bandjoin( acc, t, t2 ) )
|
||||
return( -1 );
|
||||
@ -582,7 +582,7 @@ vips_fits_new_write( VipsImage *in, const char *filename )
|
||||
|
||||
/* Cast to a supported format.
|
||||
*/
|
||||
if( !(type = vips_image_new( "p" )) ||
|
||||
if( !(type = vips_image_new()) ||
|
||||
vips_object_local( in, type ) ||
|
||||
im_clip2fmt( in, type, vips_fits_bandfmt[in->BandFmt] ) )
|
||||
return( NULL );
|
||||
@ -590,7 +590,7 @@ vips_fits_new_write( VipsImage *in, const char *filename )
|
||||
|
||||
/* FITS has (0,0) in the bottom left, we need to flip.
|
||||
*/
|
||||
if( !(flip = vips_image_new( "p" )) ||
|
||||
if( !(flip = vips_image_new()) ||
|
||||
vips_object_local( in, flip ) ||
|
||||
im_flipver( in, flip ) )
|
||||
return( NULL );
|
||||
|
@ -285,7 +285,7 @@ typedef struct _VipsImageClass {
|
||||
void (*posteval)( VipsImage *image, VipsProgress *progress );
|
||||
|
||||
/* An image has been written to.
|
||||
* Used by eg. vips_image_new_from_file("x.jpg", "w") to do the
|
||||
* Used by eg. vips_image_open("x.jpg", "w") to do the
|
||||
* final write to jpeg.
|
||||
* Set *result to non-zero to indicate an error on write.
|
||||
*/
|
||||
@ -355,7 +355,7 @@ void vips_image_set_progress( VipsImage *image, gboolean progress );
|
||||
gboolean vips_image_get_kill( VipsImage *image );
|
||||
void vips_image_set_kill( VipsImage *image, gboolean kill );
|
||||
|
||||
VipsImage *vips_image_new( const char *mode );
|
||||
VipsImage *vips_image_new( void );
|
||||
int vips_image_new_array( VipsObject *parent, VipsImage **images, int n );
|
||||
VipsImage *vips_image_new_from_file( const char *filename, const char *mode );
|
||||
VipsImage *vips_image_new_from_file_raw( const char *filename,
|
||||
|
@ -673,7 +673,7 @@ lazy_real_image( Lazy *lazy )
|
||||
/* Otherwise, fall back to a "p".
|
||||
*/
|
||||
if( !real &&
|
||||
!(real = vips_image_new( "p" )) )
|
||||
!(real = vips_image_new()) )
|
||||
return( NULL );
|
||||
|
||||
return( real );
|
||||
@ -897,7 +897,7 @@ vips_image_build( VipsObject *object )
|
||||
else {
|
||||
VipsImage *x;
|
||||
|
||||
if( !(x = vips_image_new( "p" )) )
|
||||
if( !(x = vips_image_new()) )
|
||||
return( -1 );
|
||||
vips_object_local( image, x );
|
||||
if( vips_image_open_input( x ) )
|
||||
@ -1431,38 +1431,23 @@ vips_image_temp_name( void )
|
||||
|
||||
/**
|
||||
* vips_image_new:
|
||||
* @mode: mode to open with
|
||||
*
|
||||
* vips_image_new() examines the mode string and creates an
|
||||
* appropriate #VipsImage.
|
||||
* vips_image_new() creates a "glue" descriptor you can use to join two image
|
||||
* processing operations together.
|
||||
*
|
||||
* <itemizedlist>
|
||||
* <listitem>
|
||||
* <para>
|
||||
* <emphasis>"t"</emphasis>
|
||||
* creates a temporary memory buffer image.
|
||||
* </para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para>
|
||||
* <emphasis>"p"</emphasis>
|
||||
* creates a "glue" descriptor you can use to join two image
|
||||
* processing operations together.
|
||||
* </para>
|
||||
* </listitem>
|
||||
* </itemizedlist>
|
||||
* It is the equivalent of vips_image_new_from_file("xxx", "p").
|
||||
*
|
||||
* Returns: the new #VipsImage, or %NULL on error.
|
||||
*/
|
||||
VipsImage *
|
||||
vips_image_new( const char *mode )
|
||||
vips_image_new( void )
|
||||
{
|
||||
VipsImage *image;
|
||||
|
||||
image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) );
|
||||
g_object_set( image,
|
||||
"filename", vips_image_temp_name(),
|
||||
"mode", mode,
|
||||
"mode", "p",
|
||||
NULL );
|
||||
if( vips_object_build( VIPS_OBJECT( image ) ) ) {
|
||||
VIPS_UNREF( image );
|
||||
@ -1505,7 +1490,7 @@ vips_image_new_array( VipsObject *parent, VipsImage **images, int n )
|
||||
int i;
|
||||
|
||||
for( i = 0; i < n; i++ ) {
|
||||
if( !(images[i] = vips_image_new( "p" )) )
|
||||
if( !(images[i] = vips_image_new()) )
|
||||
return( -1 );
|
||||
vips_object_local( parent, images[i] );
|
||||
}
|
||||
@ -1524,6 +1509,19 @@ vips_image_new_array( VipsObject *parent, VipsImage **images, int n )
|
||||
* <itemizedlist>
|
||||
* <listitem>
|
||||
* <para>
|
||||
* <emphasis>"t"</emphasis>
|
||||
* creates a temporary memory buffer image.
|
||||
* </para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para>
|
||||
* <emphasis>"p"</emphasis>
|
||||
* creates a "glue" descriptor you can use to join operations, see also
|
||||
* vips_image_new().
|
||||
* </para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para>
|
||||
* <emphasis>"r"</emphasis>
|
||||
* opens the named file for reading. If the file is not in the native
|
||||
* VIPS format for your machine, vips_image_new_from_file()
|
||||
@ -2006,7 +2004,7 @@ vips_image_wio_input( VipsImage *image )
|
||||
/* Change to VIPS_IMAGE_SETBUF. First, make a memory
|
||||
* buffer and copy into that.
|
||||
*/
|
||||
if( !(t1 = vips_image_new( "t" )) )
|
||||
if( !(t1 = vips_image_new_from_file( "vips_image_wio_input", "t" )) )
|
||||
return( -1 );
|
||||
if( im_copy( image, t1 ) ) {
|
||||
g_object_unref( t1 );
|
||||
|
@ -227,7 +227,7 @@ sink_init( Sink *sink,
|
||||
sink->a = a;
|
||||
sink->b = b;
|
||||
|
||||
if( !(sink->t = vips_image_new( "p" )) ||
|
||||
if( !(sink->t = vips_image_new()) ||
|
||||
im_copy( sink->sink_base.im, sink->t ) ) {
|
||||
sink_free( sink );
|
||||
return( -1 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user