Move vips__ink_to_vector and im__vector_to_ink to compat (#2488)
It was only used by getpoint in vips8, which is simpler to inline.
This commit is contained in:
parent
96604dba10
commit
1044dd46eb
@ -88,28 +88,35 @@ G_DEFINE_TYPE( VipsGetpoint, vips_getpoint, VIPS_TYPE_OPERATION );
|
|||||||
static int
|
static int
|
||||||
vips_getpoint_build( VipsObject *object )
|
vips_getpoint_build( VipsObject *object )
|
||||||
{
|
{
|
||||||
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
|
|
||||||
VipsGetpoint *getpoint = (VipsGetpoint *) object;
|
VipsGetpoint *getpoint = (VipsGetpoint *) object;
|
||||||
VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 );
|
VipsImage **t = (VipsImage **) vips_object_local_array( object, 4 );
|
||||||
|
|
||||||
double *vector;
|
double *vector;
|
||||||
int n;
|
|
||||||
VipsArrayDouble *out_array;
|
VipsArrayDouble *out_array;
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_getpoint_parent_class )->build( object ) )
|
if( VIPS_OBJECT_CLASS( vips_getpoint_parent_class )->build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
t[1] = vips_image_new_memory();
|
/* Crop, decode and unpack to double.
|
||||||
|
*/
|
||||||
if( vips_crop( getpoint->in, &t[0],
|
if( vips_crop( getpoint->in, &t[0],
|
||||||
getpoint->x, getpoint->y, 1, 1, NULL ) ||
|
getpoint->x, getpoint->y, 1, 1, NULL ) ||
|
||||||
vips_image_write( t[0], t[1] ) )
|
vips_image_decode( t[0], &t[1] ) ||
|
||||||
|
vips_cast( t[1], &t[2], VIPS_FORMAT_DOUBLE, NULL ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(vector = vips__ink_to_vector( class->nickname,
|
/* To a mem buffer, then copy to out.
|
||||||
getpoint->in, VIPS_IMAGE_ADDR( t[1], 0, 0 ), &n )) )
|
*/
|
||||||
|
vips_image_set_int( t[2], "hide-progress", 1 );
|
||||||
|
if( !(t[3] = vips_image_new_memory()) ||
|
||||||
|
vips_image_write( t[2], t[3] ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
out_array = vips_array_double_new( vector, n );
|
if( !(vector = VIPS_ARRAY( getpoint->in, t[3]->Bands, double )) )
|
||||||
|
return( -1 );
|
||||||
|
memcpy( vector, t[3]->data, VIPS_IMAGE_SIZEOF_PEL( t[3] ) );
|
||||||
|
|
||||||
|
out_array = vips_array_double_new( vector, t[3]->Bands );
|
||||||
g_object_set( object,
|
g_object_set( object,
|
||||||
"out_array", out_array,
|
"out_array", out_array,
|
||||||
NULL );
|
NULL );
|
||||||
|
@ -343,70 +343,6 @@ vips__vector_to_ink( const char *domain,
|
|||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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, VIPS_IMAGE_SIZEOF_PEL( im ),
|
|
||||||
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( "%g ", result[i] );
|
|
||||||
printf( "\n" );
|
|
||||||
}
|
|
||||||
#endif /*VIPS_DEBUG*/
|
|
||||||
|
|
||||||
return( result );
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vips_insert_build( VipsObject *object )
|
vips_insert_build( VipsObject *object )
|
||||||
{
|
{
|
||||||
|
@ -5703,3 +5703,67 @@ vips_popenf( const char *fmt, const char *mode, ... )
|
|||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We used to use this for getpoint(), but since it was the only caller in
|
||||||
|
* vips8 it's now deprecated.
|
||||||
|
*/
|
||||||
|
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, VIPS_IMAGE_SIZEOF_PEL( im ),
|
||||||
|
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( "%g ", result[i] );
|
||||||
|
printf( "\n" );
|
||||||
|
}
|
||||||
|
#endif /*VIPS_DEBUG*/
|
||||||
|
|
||||||
|
return( result );
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -183,11 +183,6 @@ VipsPel *vips__vector_to_pels( const char *domain,
|
|||||||
double *real, double *imag, int n );
|
double *real, double *imag, int n );
|
||||||
VipsPel *vips__vector_to_ink( const char *domain,
|
VipsPel *vips__vector_to_ink( const char *domain,
|
||||||
VipsImage *im, double *real, double *imag, int n );
|
VipsImage *im, double *real, double *imag, int n );
|
||||||
double *vips__ink_to_vector( const char *domain,
|
|
||||||
VipsImage *im, VipsPel *ink, int *n );
|
|
||||||
|
|
||||||
VipsPel *im__vector_to_ink( const char *domain,
|
|
||||||
VipsImage *im, int n, double *vec );
|
|
||||||
|
|
||||||
int vips__draw_flood_direct( VipsImage *image, VipsImage *test,
|
int vips__draw_flood_direct( VipsImage *image, VipsImage *test,
|
||||||
int serial, int x, int y );
|
int serial, int x, int y );
|
||||||
|
@ -1224,6 +1224,12 @@ VipsWindow *vips_window_ref( VipsImage *im, int top, int height );
|
|||||||
FILE *vips_popenf( const char *fmt, const char *mode, ... )
|
FILE *vips_popenf( const char *fmt, const char *mode, ... )
|
||||||
__attribute__((format(printf, 1, 3)));
|
__attribute__((format(printf, 1, 3)));
|
||||||
|
|
||||||
|
double *vips__ink_to_vector( const char *domain,
|
||||||
|
VipsImage *im, VipsPel *ink, int *n );
|
||||||
|
|
||||||
|
VipsPel *im__vector_to_ink( const char *domain,
|
||||||
|
VipsImage *im, int n, double *vec );
|
||||||
|
|
||||||
/* This stuff is very, very old and should not be used by anyone now.
|
/* This stuff is very, very old and should not be used by anyone now.
|
||||||
*/
|
*/
|
||||||
#ifdef VIPS_ENABLE_ANCIENT
|
#ifdef VIPS_ENABLE_ANCIENT
|
||||||
|
Loading…
Reference in New Issue
Block a user