allow much larger reduce factors

sometimes you want to use lanczos etc. for everything
This commit is contained in:
John Cupitt 2017-10-09 11:48:11 +01:00
parent 61fc94946a
commit de82c9e919
6 changed files with 24 additions and 20 deletions

View File

@ -601,7 +601,7 @@ vips_colourspace_class_init( VipsColourspaceClass *class )
G_STRUCT_OFFSET( VipsColourspace, space ),
VIPS_TYPE_INTERPRETATION, VIPS_INTERPRETATION_sRGB );
VIPS_ARG_ENUM( class, "source-space", 6,
VIPS_ARG_ENUM( class, "source_space", 6,
_( "Source space" ),
_( "Source color space" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -938,7 +938,7 @@ vips_convi_build( VipsObject *object )
!intize_to_fixed_point( M, convi->fixed ) &&
!vips_convi_compile( convi, in ) ) {
generate = vips_convi_gen_vector;
g_info( "using vector path" );
g_info( "convi: using vector path" );
}
else
vips_convi_compile_free( convi );
@ -947,7 +947,7 @@ vips_convi_build( VipsObject *object )
/* Make the data for the C path.
*/
if( generate == vips_convi_gen ) {
g_info( "using C path" );
g_info( "convi: using C path" );
/* Make an int version of our mask.
*/

View File

@ -67,7 +67,7 @@ GType vips_resample_get_type( void );
/* The max size of the vector we use.
*/
#define MAX_POINT (50)
#define MAX_POINT (2000)
int vips_reduce_get_points( VipsKernel kernel, double shrink );
void vips_reduce_make_mask( double *c,

View File

@ -454,7 +454,7 @@ vips_reduceh_build( VipsObject *object )
*/
reduceh->n_point =
vips_reduce_get_points( reduceh->kernel, reduceh->hshrink );
g_info( "%d point mask", reduceh->n_point );
g_info( "reduceh: %d point mask", reduceh->n_point );
if( reduceh->n_point > MAX_POINT ) {
vips_error( object_class->nickname,
"%s", _( "reduce factor too large" ) );

View File

@ -781,7 +781,7 @@ vips_reducev_raw( VipsReducev *reducev, VipsImage *in, VipsImage **out )
if( in->BandFmt == VIPS_FORMAT_UCHAR &&
vips_vector_isenabled() &&
!vips_reducev_compile( reducev ) ) {
g_info( "using vector path" );
g_info( "reducev: using vector path" );
generate = vips_reducev_vector_gen;
}
@ -848,12 +848,12 @@ vips_reducev_build( VipsObject *object )
reducev->n_point =
vips_reduce_get_points( reducev->kernel, reducev->vshrink );
g_info( "reducev: %d point mask", reducev->n_point );
if( reducev->n_point > MAX_POINT ) {
vips_error( object_class->nickname,
"%s", _( "reduce factor too large" ) );
return( -1 );
}
g_info( "%d point mask", reducev->n_point );
/* Unpack for processing.
*/

View File

@ -115,22 +115,26 @@ G_DEFINE_TYPE( VipsResize, vips_resize, VIPS_TYPE_RESAMPLE );
static int
vips_resize_int_shrink( VipsResize *resize, double scale )
{
int shrink;
if( scale > 1.0 )
return( 1 );
shrink = 1;
else
switch( resize->kernel ) {
case VIPS_KERNEL_NEAREST:
shrink = 1;
switch( resize->kernel ) {
case VIPS_KERNEL_NEAREST:
return( 1 );
case VIPS_KERNEL_LINEAR:
case VIPS_KERNEL_CUBIC:
default:
shrink = VIPS_FLOOR( 1.0 / scale );
case VIPS_KERNEL_LINEAR:
case VIPS_KERNEL_CUBIC:
default:
return( VIPS_FLOOR( 1.0 / scale ) );
case VIPS_KERNEL_LANCZOS2:
case VIPS_KERNEL_LANCZOS3:
shrink = VIPS_MAX( 1, VIPS_FLOOR( 1.0 / (scale * 2) ) );
}
case VIPS_KERNEL_LANCZOS2:
case VIPS_KERNEL_LANCZOS3:
return( VIPS_MAX( 1, VIPS_FLOOR( 1.0 / (scale * 2) ) ) );
}
return( shrink );
}
/* Suggest a VipsInterpolate which corresponds to a VipsKernel. We use
@ -392,7 +396,7 @@ vips_resize_init( VipsResize *resize )
* a #VipsInterpolate selected depending on @kernel. It will use
* #VipsInterpolateBicubic for #VIPS_KERNEL_CUBIC and above.
*
* vips_resize() normally maintains the image apect ratio. If you set
* vips_resize() normally maintains the image aspect ratio. If you set
* @vscale, that factor is used for the vertical scale and @scale for the
* horizontal.
*