From b628642f4a2820319d17931c658dccd748f2d616 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 21 Sep 2009 15:50:29 +0000 Subject: [PATCH] fix im_errormsg() calls --- ChangeLog | 4 + TODO | 19 +- contrib/mitsub/mitsub.c | 14 +- contrib/vips2dj/vips2ah.c | 2 +- contrib/vips2dj/vips2dj.c | 7 +- libvips/arithmetic/arith_dispatch.c | 38 ++-- libvips/arithmetic/im_remainder.c | 8 +- libvips/boolean/bool_dispatch.c | 190 ++++++++++++-------- libvips/boolean/boolean.c | 220 ++++++++++++++++++----- libvips/colour/colour.c | 6 +- libvips/colour/im_LCh2Lab.c | 3 +- libvips/colour/im_LCh2UCS.c | 3 +- libvips/colour/im_Lab2LCh.c | 3 +- libvips/colour/im_Lab2LabQ.c | 6 +- libvips/colour/im_Lab2LabS.c | 6 +- libvips/colour/im_LabQ2Lab.c | 2 +- libvips/colour/im_LabQ2LabS.c | 3 +- libvips/colour/im_LabQ2disp.c | 3 +- libvips/colour/im_LabS2Lab.c | 6 +- libvips/colour/im_LabS2LabQ.c | 6 +- libvips/colour/im_UCS2LCh.c | 3 +- libvips/colour/im_XYZ2Yxy.c | 3 +- libvips/colour/im_Yxy2XYZ.c | 3 +- libvips/colour/im_dE00_fromLab.c | 2 +- libvips/colour/im_dECMC_fromLab.c | 2 +- libvips/colour/im_dE_fromLab.c | 3 +- libvips/colour/im_icc_transform.c | 18 +- libvips/colour/im_lab_morph.c | 16 +- libvips/conversion/im_bandjoin.c | 6 +- libvips/conversion/im_black.c | 2 +- libvips/conversion/im_c2amph.c | 3 +- libvips/conversion/im_c2imag.c | 3 +- libvips/conversion/im_c2real.c | 3 +- libvips/conversion/im_c2rect.c | 3 +- libvips/conversion/im_mask2vips.c | 2 +- libvips/conversion/im_recomb.c | 8 +- libvips/conversion/im_replicate.c | 2 +- libvips/conversion/im_ri2c.c | 4 +- libvips/conversion/im_slice.c | 10 +- libvips/conversion/im_thresh.c | 15 +- libvips/convolution/im_conv.c | 4 +- libvips/convolution/im_convsub.c | 40 +++-- libvips/convolution/im_fastcor.c | 5 +- libvips/convolution/im_gaussnoise.c | 2 +- libvips/convolution/im_logmasks.c | 2 +- libvips/convolution/im_rank.c | 7 +- libvips/convolution/im_rank_image.c | 22 +-- libvips/convolution/im_resize_linear.c | 6 +- libvips/convolution/rotmask.c | 10 +- libvips/deprecated/Makefile.am | 1 + libvips/deprecated/deprecated_dispatch.c | 143 +++++++++++++-- libvips/deprecated/rename.c | 141 +++++++++++++++ libvips/freq_filt/fmask4th.c | 53 +++--- libvips/freq_filt/fmaskcir.c | 35 ++-- libvips/freq_filt/im_fractsurf.c | 3 +- libvips/freq_filt/im_freq_mask.c | 5 +- libvips/histograms_lut/im_gammacorrect.c | 2 +- libvips/histograms_lut/im_histspec.c | 14 +- libvips/histograms_lut/im_identity.c | 6 +- libvips/histograms_lut/im_invertlut.c | 8 +- libvips/histograms_lut/im_stdif.c | 7 +- libvips/histograms_lut/tone.c | 2 +- libvips/include/vips/Makefile.am | 1 + libvips/include/vips/arithmetic.h | 2 +- libvips/include/vips/boolean.h | 58 ++++++ libvips/include/vips/deprecated.h | 27 +++ libvips/include/vips/proto.h | 48 +---- libvips/include/vips/vips.h | 1 + libvips/inplace/im_circle.c | 6 +- libvips/inplace/im_line.c | 15 +- libvips/inplace/line_draw.c | 5 +- libvips/inplace/plot_point.c | 2 +- libvips/iofuncs/error.c | 58 +----- libvips/iofuncs/im_debugim.c | 4 +- libvips/iofuncs/im_image.c | 2 +- libvips/iofuncs/im_init_world.c | 4 +- libvips/iofuncs/im_makerw.c | 4 +- libvips/iofuncs/im_piocheck.c | 19 +- libvips/iofuncs/im_printlines.c | 7 +- libvips/iofuncs/util.c | 2 +- libvips/matrix/im_matcat.c | 4 +- libvips/matrix/im_matmul.c | 4 +- libvips/matrix/im_mattrn.c | 2 +- libvips/morphology/im_cntlines.c | 8 +- libvips/morphology/im_profile.c | 5 +- libvips/mosaicing/im_avgdxdy.c | 2 +- libvips/mosaicing/im_chkpair.c | 4 +- libvips/mosaicing/im_clinear.c | 2 +- libvips/mosaicing/im_lrcalcon.c | 9 +- libvips/mosaicing/im_lrmosaic.c | 12 +- libvips/mosaicing/im_tbcalcon.c | 4 +- libvips/mosaicing/im_tbmosaic.c | 8 +- libvips/mosaicing/match.c | 8 +- libvips/other/cooc_funcs.c | 60 ++++--- libvips/other/glds_funcs.c | 43 +++-- libvips/other/im_benchmark.c | 13 +- libvips/other/im_dif_std.c | 15 +- libvips/other/im_eye.c | 2 +- libvips/other/im_grey.c | 2 +- libvips/other/im_make_xy.c | 2 +- libvips/other/im_meanstd.c | 4 +- libvips/other/im_simcontr.c | 7 +- libvips/other/im_sines.c | 14 +- libvips/other/im_spatres.c | 24 +-- libvips/other/im_zone.c | 5 +- libvips/relational/relational.c | 26 +-- libvips/resample/im_affine.c | 14 +- libvips/resample/resample_dispatch.c | 129 ------------- tools/mosaicing/find_mosaic.c | 24 ++- tools/mosaicing/mergeup.c | 38 ++-- 110 files changed, 1152 insertions(+), 785 deletions(-) create mode 100644 libvips/deprecated/rename.c create mode 100644 libvips/include/vips/boolean.h diff --git a/ChangeLog b/ChangeLog index 3f4dc8a5..561cb76f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,10 @@ open files) ... this lets them delete temps and stuff. Expect breakage :( - added vips_interpolate_get_window_offset() - boolean revised: smaller, more general, faster +- im_remainderconst_vec() renamed to im_remainder_vec() for consistency +- added im_shift*_vec() +- renamed im_eor_vec() as im_eorimage_vec() for consistency, also and, or +- renamed im_eorconst() as im_eorimage_const() for consistency, also and, or 25/3/09 started 7.18.0 - revised version numbers diff --git a/TODO b/TODO index e7d2ed89..cafc6c5f 100644 --- a/TODO +++ b/TODO @@ -1,16 +1,10 @@ -- move im_and_vec() to deprecated +- need in deprecated_dispatch.c -- shouldn't it be im_remainder_vec()? + im_remainderconst_vec - im_remainderconst_vec() is better? cf. +- move resample / im_affine, im_similarity, im_similarity_area to deprecated - im_andimage() - im_andimageconst() - im_andimage_vec() - -- booolean needs gtkdoc - -- test boolean +- we have tools/ and contrib/ argh @@ -25,11 +19,6 @@ - Joe's new def -- im_add(), im_subtract() etc. could all be in one file and share macros like - boolean.c - - quite hard, because of things like complex *, / and liboil - diff --git a/contrib/mitsub/mitsub.c b/contrib/mitsub/mitsub.c index 8e3cb2ed..436e006d 100644 --- a/contrib/mitsub/mitsub.c +++ b/contrib/mitsub/mitsub.c @@ -128,7 +128,7 @@ main( int argc, char *argv[] ) ysize = vips->Ysize; } else { - im_diagnostics( "mitsub: rotating ..." ); + im_diag( "mitsub", "%s", _( "rotating ..." ) ); xsize = vips->Ysize; ysize = vips->Xsize; } @@ -141,7 +141,7 @@ main( int argc, char *argv[] ) double factor = IM_MAX( x_factor, y_factor ); IMAGE *sh = im_open( "shrink", "t" ); - im_diagnostics( "mitsub: shrinking by %g ...", factor ); + im_diag( "mitsub", "%s", _( "shrinking by %g ..." ), factor ); if( !sh || im_shrink( vips, sh, factor, factor ) ) error_exit( "mitsub: shrink failed" ); @@ -199,7 +199,7 @@ main( int argc, char *argv[] ) n = 255; m = (int) xsize/fact + 1; } - im_diagnostics( "mitsub: enlarging by %g ...", (double) n/m ); + im_diag( "mitsub", _( "enlarging by %g ..." ), (double) n/m ); /* Horizontal enlarge. */ @@ -278,7 +278,7 @@ main( int argc, char *argv[] ) /* Centering. ('1' = centering available, '0'= no centering). */ if( center ) { - im_diagnostics( "mitsub: centering ..." ); + im_diag( "mitsub", "%s", _( "centering ..." ) ); putc( 0x1b, out ); putc( '&', out ); putc( 'C', out ); @@ -419,7 +419,7 @@ main( int argc, char *argv[] ) p = (PEL *) vips->data; switch( vips->Bands ) { case 4: - im_diagnostics( "mitsub: sending IM_TYPE_CMYK ..." ); + im_diag( "mitsub", "%s", _( "sending IM_TYPE_CMYK ..." ) ); for( y = 0; y < vips->Ysize; y++ ) for( x = 0; x < vips->Xsize; x++ ) { putc( p[2], out ); @@ -431,7 +431,7 @@ main( int argc, char *argv[] ) break; case 3: - im_diagnostics( "mitsub: sending IM_TYPE_RGB ..." ); + im_diag( "mitsub", "%s", _( "sending IM_TYPE_RGB ..." ) ); for( y = 0; y < vips->Ysize; y++ ) for( x = 0; x < vips->Xsize; x++ ) { putc( p[0], out ); @@ -442,7 +442,7 @@ main( int argc, char *argv[] ) break; case 1: - im_diagnostics( "mitsub: sending K ..." ); + im_diag( "mitsub", "%s", _( "sending K ..." ) ); for( y = 0; y < vips->Ysize; y++ ) for( x = 0; x < vips->Xsize; x++ ) putc( *p++, out ); diff --git a/contrib/vips2dj/vips2ah.c b/contrib/vips2dj/vips2ah.c index 782f7f4d..adf2aa6a 100644 --- a/contrib/vips2dj/vips2ah.c +++ b/contrib/vips2dj/vips2ah.c @@ -59,7 +59,7 @@ writeimage( REGION *ir, FILE *out ) int c1 = (C);\ \ if( putc( c1, out ) == EOF ) {\ - im_errormsg( "vips2hp2500cp: write error - disc full?" );\ + im_error( "vips2hp2500cp", "%s", _( "write error - disc full?" ) );\ return( -1 );\ }\ } diff --git a/contrib/vips2dj/vips2dj.c b/contrib/vips2dj/vips2dj.c index 0dbf312a..3e33ff24 100644 --- a/contrib/vips2dj/vips2dj.c +++ b/contrib/vips2dj/vips2dj.c @@ -86,7 +86,7 @@ find_printer( char *name ) if( strcmp( name, printer_data[i].name ) == 0 ) return( &printer_data[i] ); - im_errormsg( "vips2dj: unknown printer \"%s\"", name ); + im_error( "vips2dj", _( "unknown printer \"%s\"" ), name ); return( NULL ); } @@ -99,7 +99,8 @@ copy_bytes( FILE *in, FILE *out ) while( (ch = getc( in )) != EOF ) if( putc( ch, out ) == EOF ) { - im_errormsg( "vips2dj: write error -- disc full?" ); + im_error( "vips2dj", "%s", + _( "write error -- disc full?" ) ); return( -1 ); } @@ -123,7 +124,7 @@ transmit_file( char *mode, char *name, FILE *out ) im_snprintf( buf, PATH_MAX, "%s/share/vips/vips2dj/%s/%s", prefix, mode, name ); if( !(in = fopen( buf, "r" )) ) { - im_errormsg( "vips2dj: can't find \"%s\"", name ); + im_error( "vips2dj", _( "can't find \"%s\"" ), name ); return( -1 ); } if( copy_bytes( in, out ) ) { diff --git a/libvips/arithmetic/arith_dispatch.c b/libvips/arithmetic/arith_dispatch.c index 3c0bd11b..27be7d37 100644 --- a/libvips/arithmetic/arith_dispatch.c +++ b/libvips/arithmetic/arith_dispatch.c @@ -422,7 +422,7 @@ exp10tra_vec( im_object *argv ) */ static im_function exp10tra_desc = { "im_exp10tra", /* Name */ - N_( "10^pel of image" ), /* Description */ + N_( "10^pel of image" ), /* Description */ IM_FN_PIO | IM_FN_PTOP, /* Flags */ exp10tra_vec, /* Dispatch function */ IM_NUMBER( one_in_one_out ), /* Size of arg list */ @@ -571,7 +571,7 @@ static im_function lintra_desc = { N_( "calculate a*in + b = outfile" ), IM_FN_PIO | IM_FN_PTOP, /* Flags */ lintra_vec, /* Dispatch function */ - IM_NUMBER( lintra_args ), /* Size of arg list */ + IM_NUMBER( lintra_args ), /* Size of arg list */ lintra_args /* Arg list */ }; @@ -643,7 +643,7 @@ logtra_vec( im_object *argv ) */ static im_function logtra_desc = { "im_logtra", /* Name */ - N_( "ln of image" ), /* Description */ + N_( "ln of image" ), /* Description */ IM_FN_PIO | IM_FN_PTOP, /* Flags */ logtra_vec, /* Dispatch function */ IM_NUMBER( one_in_one_out ), /* Size of arg list */ @@ -915,7 +915,7 @@ static im_function maxpos_desc = { N_( "position of maximum value of image" ), 0, /* Flags */ maxpos_vec, /* Dispatch function */ - IM_NUMBER( maxpos_args ), /* Size of arg list */ + IM_NUMBER( maxpos_args ), /* Size of arg list */ maxpos_args /* Arg list */ }; @@ -940,7 +940,7 @@ maxpos_avg_vec( im_object *argv ) */ static im_function maxpos_avg_desc = { "im_maxpos_avg", - "position of maximum value of image, averaging in case of draw", + N_( "position of maximum value of image, averaging in case of draw" ), IM_FN_PIO, maxpos_avg_vec, IM_NUMBER( maxpos_avg_args ), @@ -984,7 +984,7 @@ maxpos_vec_vec( im_object *argv ) */ static im_function maxpos_vec_desc = { "im_maxpos_vec", - "position and value of n maxima of image", + N_( "position and value of n maxima of image" ), IM_FN_PIO, maxpos_vec_vec, IM_NUMBER( maxpos_vec_args ), @@ -1018,7 +1018,7 @@ minpos_vec_vec( im_object *argv ) */ static im_function minpos_vec_desc = { "im_minpos_vec", - "position and value of n minima of image", + N_( "position and value of n minima of image" ), IM_FN_PIO, minpos_vec_vec, IM_NUMBER( maxpos_vec_args ), @@ -1124,7 +1124,7 @@ static im_function minpos_desc = { N_( "position of minimum value of image" ), 0, /* Flags */ minpos_vec, /* Dispatch function */ - IM_NUMBER( maxpos_args ), /* Size of arg list */ + IM_NUMBER( maxpos_args ), /* Size of arg list */ maxpos_args /* Arg list */ }; @@ -1172,23 +1172,23 @@ static im_function remainderconst_desc = { N_( "remainder after integer division by a constant" ),/* Description */ IM_FN_PIO | IM_FN_PTOP, /* Flags */ remainderconst_vec, /* Dispatch function */ - IM_NUMBER( remainderconst_args ), /* Size of arg list */ + IM_NUMBER( remainderconst_args ),/* Size of arg list */ remainderconst_args /* Arg list */ }; /* Call im_remainderconst_vec via arg vector. */ static int -remainderconst_vec_vec( im_object *argv ) +remainder_vec_vec( im_object *argv ) { im_doublevec_object *dv = (im_doublevec_object *) argv[2]; - return( im_remainderconst_vec( argv[0], argv[1], dv->n, dv->vec ) ); + return( im_remainder_vec( argv[0], argv[1], dv->n, dv->vec ) ); } -/* Args for im_remainderconst_vec(). +/* Args for im_remainder_vec(). */ -static im_arg_desc remainderconst_vec_args[] = { +static im_arg_desc remainder_vec_args[] = { IM_INPUT_IMAGE( "in" ), IM_OUTPUT_IMAGE( "out" ), IM_INPUT_DOUBLEVEC( "x" ) @@ -1197,13 +1197,13 @@ static im_arg_desc remainderconst_vec_args[] = { /* Description of im_remainderconst_vec. */ static im_function remainderconst_vec_desc = { - "im_remainderconst_vec", /* Name */ + "im_remainder_vec", /* Name */ N_( "remainder after integer division by a vector of constants" ), /* Description */ IM_FN_PIO | IM_FN_PTOP, /* Flags */ - remainderconst_vec_vec, /* Dispatch function */ - IM_NUMBER( remainderconst_vec_args ), /* Size of arg list */ - remainderconst_vec_args /* Arg list */ + remainder_vec_vec, /* Dispatch function */ + IM_NUMBER( remainder_vec_args ),/* Size of arg list */ + remainder_vec_args /* Arg list */ }; /* Call im_multiply via arg vector. @@ -1239,7 +1239,7 @@ powtra_vec( im_object *argv ) */ static im_function powtra_desc = { "im_powtra", /* Name */ - N_( "pel^x ofbuildimage" ), + N_( "pel^x of image" ), IM_FN_PIO | IM_FN_PTOP, /* Flags */ powtra_vec, /* Dispatch function */ IM_NUMBER( powtra_args ), /* Size of arg list */ @@ -1294,7 +1294,7 @@ static im_function stats_desc = { N_( "many image statistics in one pass" ), IM_FN_PIO, /* Flags */ stats_vec, /* Dispatch function */ - IM_NUMBER( stats_args ), /* Size of arg list */ + IM_NUMBER( stats_args ), /* Size of arg list */ stats_args /* Arg list */ }; diff --git a/libvips/arithmetic/im_remainder.c b/libvips/arithmetic/im_remainder.c index 16c178cb..cf99ad8e 100644 --- a/libvips/arithmetic/im_remainder.c +++ b/libvips/arithmetic/im_remainder.c @@ -366,7 +366,7 @@ remainderconst_buffer( PEL *in, PEL *out, int width, PEL *vector, IMAGE *im ) } /** - * im_remainderconst_vec: + * im_remainder_vec: * @in: input #IMAGE * @out: output #IMAGE * @n: number of elements in array @@ -388,7 +388,7 @@ remainderconst_buffer( PEL *in, PEL *out, int width, PEL *vector, IMAGE *im ) * Returns: 0 on success, -1 on error */ int -im_remainderconst_vec( IMAGE *in, IMAGE *out, int n, double *c ) +im_remainder_vec( IMAGE *in, IMAGE *out, int n, double *c ) { if( im_check_noncomplex( "im_remainder", in ) ) return( -1 ); @@ -409,12 +409,12 @@ im_remainderconst_vec( IMAGE *in, IMAGE *out, int n, double *c ) * This operation calculates @in % @c (remainder after division by constant) * and writes the result to @out. The image must be one of the integer types. * - * See also: im_remainderconst_vec(), im_divide(). + * See also: im_remainder_vec(), im_divide(). * * Returns: 0 on success, -1 on error */ int im_remainderconst( IMAGE *in, IMAGE *out, double c ) { - return( im_remainderconst_vec( in, out, 1, &c ) ); + return( im_remainder_vec( in, out, 1, &c ) ); } diff --git a/libvips/boolean/bool_dispatch.c b/libvips/boolean/bool_dispatch.c index a97dae62..45ec1274 100644 --- a/libvips/boolean/bool_dispatch.c +++ b/libvips/boolean/bool_dispatch.c @@ -51,7 +51,7 @@ * * These operations perform boolean operations, such as bitwise-and, on * every pixel in an image or pair of images. - * All (except in a few cases noted below) will work with + * All will work with * images of any type or any mixture of types, of any size and of any number * of bands. * @@ -67,6 +67,8 @@ * The output type is the same as the input type for integer types. Float and * complex types are cast to signed int. * + * For binary operations, the images must match in size. + * * You might think im_andimage() would be called "im_and", but that causes * problems when we try and make a C++ binding and drop the "im_" prefix. */ @@ -95,185 +97,185 @@ static im_arg_desc vec_in_one_out[] = { IM_INPUT_DOUBLEVEC( "vec" ) }; -/* Call im_and via arg vector. +/* Call im_andimage via arg vector. */ static int -and_vec( im_object *argv ) +andimage_vec( im_object *argv ) { return( im_andimage( argv[0], argv[1], argv[2] ) ); } -/* Description of im_and. +/* Description of im_andimage. */ -static im_function and_desc = { +static im_function andimage_desc = { "im_andimage", /* Name */ "bitwise and of two images", /* Description */ - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - and_vec, /* Dispatch function */ + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + andimage_vec, /* Dispatch function */ IM_NUMBER( two_in_one_out ), /* Size of arg list */ two_in_one_out /* Arg list */ }; -/* Call im_andconst via arg vector. +/* Call im_andimageconst via arg vector. */ static int -andconst_vec( im_object *argv ) +andimageconst_vec( im_object *argv ) { int c = *((int *) argv[2]); - return( im_andconst( argv[0], argv[1], c ) ); + return( im_andimageconst( argv[0], argv[1], c ) ); } /* Description of im_andconst. */ -static im_function andconst_desc = { - "im_andimageconst", /* Name */ +static im_function andimageconst_desc = { + "im_andimageconst", /* Name */ "bitwise and of an image with a constant", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - andconst_vec, /* Dispatch function */ + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + andimageconst_vec, /* Dispatch function */ IM_NUMBER( const_in_one_out ), /* Size of arg list */ const_in_one_out /* Arg list */ }; -/* Call im_and_vec via arg vector. +/* Call im_andimage_vec via arg vector. */ static int -and_vec_vec( im_object *argv ) +andimage_vec_vec( im_object *argv ) { im_doublevec_object *rv = (im_doublevec_object *) argv[2]; - return( im_and_vec( argv[0], argv[1], rv->n, rv->vec ) ); + return( im_andimage_vec( argv[0], argv[1], rv->n, rv->vec ) ); } -/* Description of im_andconst. +/* Description of im_andimageconst. */ -static im_function and_vec_desc = { +static im_function andimage_vec_desc = { "im_andimage_vec", /* Name */ "bitwise and of an image with a vector constant", IM_FN_PTOP | IM_FN_PIO, /* Flags */ - and_vec_vec, /* Dispatch function */ + andimage_vec_vec, /* Dispatch function */ IM_NUMBER( vec_in_one_out ), /* Size of arg list */ vec_in_one_out /* Arg list */ }; -/* Call im_or via arg vector. +/* Call im_orimage via arg vector. */ static int -or_vec( im_object *argv ) +orimage_vec( im_object *argv ) { return( im_orimage( argv[0], argv[1], argv[2] ) ); } -/* Description of im_or. +/* Description of im_orimage. */ -static im_function or_desc = { +static im_function orimage_desc = { "im_orimage", /* Name */ "bitwise or of two images", /* Description */ - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - or_vec, /* Dispatch function */ + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + orimage_vec, /* Dispatch function */ IM_NUMBER( two_in_one_out ), /* Size of arg list */ two_in_one_out /* Arg list */ }; -/* Call im_orconst via arg vector. +/* Call im_orimageconst via arg vector. */ static int -orconst_vec( im_object *argv ) +orimageconst_vec( im_object *argv ) { int c = *((int *) argv[2]); - return( im_orconst( argv[0], argv[1], c ) ); + return( im_orimageconst( argv[0], argv[1], c ) ); } -/* Description of im_orconst. +/* Description of im_orimageconst. */ -static im_function orconst_desc = { - "im_orimageconst", /* Name */ +static im_function orimageconst_desc = { + "im_orimageconst", /* Name */ "bitwise or of an image with a constant", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - orconst_vec, /* Dispatch function */ + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + orimageconst_vec, /* Dispatch function */ IM_NUMBER( const_in_one_out ), /* Size of arg list */ const_in_one_out /* Arg list */ }; -/* Call im_or_vec via arg vector. +/* Call im_orimage_vec via arg vector. */ static int -or_vec_vec( im_object *argv ) +orimage_vec_vec( im_object *argv ) { im_doublevec_object *rv = (im_doublevec_object *) argv[2]; - return( im_or_vec( argv[0], argv[1], rv->n, rv->vec ) ); + return( im_orimage_vec( argv[0], argv[1], rv->n, rv->vec ) ); } -/* Description of im_orconst. +/* Description of im_orimage_vec. */ -static im_function or_vec_desc = { +static im_function orimage_vec_desc = { "im_orimage_vec", /* Name */ "bitwise or of an image with a vector constant", IM_FN_PTOP | IM_FN_PIO, /* Flags */ - or_vec_vec, /* Dispatch function */ + orimage_vec_vec, /* Dispatch function */ IM_NUMBER( vec_in_one_out ), /* Size of arg list */ vec_in_one_out /* Arg list */ }; -/* Call im_eor via arg vector. +/* Call im_eorimage via arg vector. */ static int -eor_vec( im_object *argv ) +eorimage_vec( im_object *argv ) { return( im_eorimage( argv[0], argv[1], argv[2] ) ); } -/* Description of im_eor. +/* Description of im_eorimage. */ -static im_function eor_desc = { +static im_function eorimage_desc = { "im_eorimage", /* Name */ "bitwise eor of two images", /* Description */ - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - eor_vec, /* Dispatch function */ + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + eorimage_vec, /* Dispatch function */ IM_NUMBER( two_in_one_out ), /* Size of arg list */ two_in_one_out /* Arg list */ }; -/* Call im_eorconst via arg vector. +/* Call im_eorimageconst via arg vector. */ static int -eorconst_vec( im_object *argv ) +eorimageconst_vec( im_object *argv ) { int c = *((int *) argv[2]); - return( im_eorconst( argv[0], argv[1], c ) ); + return( im_eorimageconst( argv[0], argv[1], c ) ); } -/* Description of im_eorconst. +/* Description of im_eorimageconst. */ -static im_function eorconst_desc = { - "im_eorimageconst", /* Name */ +static im_function eorimageconst_desc = { + "im_eorimageconst", /* Name */ "bitwise eor of an image with a constant", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - eorconst_vec, /* Dispatch function */ + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + eorimageconst_vec, /* Dispatch function */ IM_NUMBER( const_in_one_out ), /* Size of arg list */ const_in_one_out /* Arg list */ }; -/* Call im_eor_vec via arg vector. +/* Call im_eorimage_vec via arg vector. */ static int -eor_vec_vec( im_object *argv ) +eorimage_vec_vec( im_object *argv ) { im_doublevec_object *rv = (im_doublevec_object *) argv[2]; - return( im_eor_vec( argv[0], argv[1], rv->n, rv->vec ) ); + return( im_eorimage_vec( argv[0], argv[1], rv->n, rv->vec ) ); } -/* Description of im_eorconst. +/* Description of im_eorimage_vec. */ -static im_function eor_vec_desc = { +static im_function eorimage_vec_desc = { "im_eorimage_vec", /* Name */ "bitwise eor of an image with a vector constant", IM_FN_PTOP | IM_FN_PIO, /* Flags */ - eor_vec_vec, /* Dispatch function */ + eorimage_vec_vec, /* Dispatch function */ IM_NUMBER( vec_in_one_out ), /* Size of arg list */ vec_in_one_out /* Arg list */ }; @@ -292,13 +294,34 @@ shiftleft_vec( im_object *argv ) */ static im_function shiftleft_desc = { "im_shiftleft", /* Name */ - "shift integer image n bits to left", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ + "shift image n bits to left", + IM_FN_PTOP | IM_FN_PIO, /* Flags */ shiftleft_vec, /* Dispatch function */ IM_NUMBER( const_in_one_out ), /* Size of arg list */ const_in_one_out /* Arg list */ }; +/* Call im_shiftleft_vec via arg vector. + */ +static int +shiftleft_vec_vec( im_object *argv ) +{ + im_doublevec_object *rv = (im_doublevec_object *) argv[2]; + + return( im_shiftleft_vec( argv[0], argv[1], rv->n, rv->vec ) ); +} + +/* Description of im_shiftleft_vec. + */ +static im_function shiftleft_vec_desc = { + "im_shiftleft_vec", /* Name */ + "shift image array bits to left", + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + shiftleft_vec_vec, /* Dispatch function */ + IM_NUMBER( vec_in_one_out ), /* Size of arg list */ + vec_in_one_out /* Arg list */ +}; + /* Call im_shiftright via arg vector. */ static int @@ -314,25 +337,48 @@ shiftright_vec( im_object *argv ) static im_function shiftright_desc = { "im_shiftright", /* Name */ "shift integer image n bits to right", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ + IM_FN_PTOP | IM_FN_PIO, /* Flags */ shiftright_vec, /* Dispatch function */ IM_NUMBER( const_in_one_out ), /* Size of arg list */ const_in_one_out /* Arg list */ }; +/* Call im_shiftright_vec via arg vector. + */ +static int +shiftright_vec_vec( im_object *argv ) +{ + im_doublevec_object *rv = (im_doublevec_object *) argv[2]; + + return( im_shiftright_vec( argv[0], argv[1], rv->n, rv->vec ) ); +} + +/* Description of im_shiftright_vec. + */ +static im_function shiftright_vec_desc = { + "im_shiftright_vec", /* Name */ + "shift image array bits to right", + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + shiftright_vec_vec, /* Dispatch function */ + IM_NUMBER( vec_in_one_out ), /* Size of arg list */ + vec_in_one_out /* Arg list */ +}; + /* Package up all these functions. */ static im_function *bool_list[] = { - &and_desc, - &andconst_desc, - &and_vec_desc, - &or_desc, - &orconst_desc, - &or_vec_desc, - &eor_desc, - &eorconst_desc, - &eor_vec_desc, + &andimage_desc, + &andimageconst_desc, + &andimage_vec_desc, + &orimage_desc, + &orimageconst_desc, + &orimage_vec_desc, + &eorimage_desc, + &eorimageconst_desc, + &eorimage_vec_desc, + &shiftleft_vec_desc, &shiftleft_desc, + &shiftright_vec_desc, &shiftright_desc }; diff --git a/libvips/boolean/boolean.c b/libvips/boolean/boolean.c index b69e5870..06337b75 100644 --- a/libvips/boolean/boolean.c +++ b/libvips/boolean/boolean.c @@ -1,4 +1,4 @@ -/* boolean.c +/* boolean.c --- various bit operations * * Modified: * 15/12/94 JC @@ -301,6 +301,21 @@ CONST1_BUFFER( AND, & ) CONSTN_BUFFER( AND, & ) +/** + * im_andimage_vec: + * @in1: input #IMAGE 1 + * @in2: input #IMAGE 2 + * @out: output #IMAGE + * @n: array length + * @c: array of constants + * + * This operation calculates @in1 & @c (bitwise and of image pixels with array + * @c) and writes the result to @out. + * + * See also: im_andimage(), im_orimage_vec(). + * + * Returns: 0 on success, -1 on error + */ int im_andimage_vec( IMAGE *in, IMAGE *out, int n, double *c ) { @@ -311,10 +326,46 @@ im_andimage_vec( IMAGE *in, IMAGE *out, int n, double *c ) (im_wrapone_fn) ANDn_buffer ) ); } +/** + * im_andimageconst: + * @in1: input #IMAGE 1 + * @in2: input #IMAGE 2 + * @out: output #IMAGE + * @c: constant + * + * This operation calculates @in1 & @c (bitwise and of image pixels with + * constant + * @c) and writes the result to @out. + * + * See also: im_andimage(), im_orimage_vec(). + * + * Returns: 0 on success, -1 on error + */ +int +im_andimageconst( IMAGE *in, IMAGE *out, double c ) +{ + return( im_andimage_vec( in, out, 1, &c ) ); +} + CONST1_BUFFER( OR, | ) CONSTN_BUFFER( OR, | ) +/** + * im_orimage_vec: + * @in1: input #IMAGE 1 + * @in2: input #IMAGE 2 + * @out: output #IMAGE + * @n: array length + * @c: array of constants + * + * This operation calculates @in1 | @c (bitwise or of image pixels with array + * @c) and writes the result to @out. + * + * See also: im_andimage(), im_orimageconst(). + * + * Returns: 0 on success, -1 on error + */ int im_orimage_vec( IMAGE *in, IMAGE *out, int n, double *c ) { @@ -325,10 +376,47 @@ im_orimage_vec( IMAGE *in, IMAGE *out, int n, double *c ) (im_wrapone_fn) ORn_buffer ) ); } +/** + * im_orimageconst: + * @in1: input #IMAGE 1 + * @in2: input #IMAGE 2 + * @out: output #IMAGE + * @c: constant + * + * This operation calculates @in1 | @c (bitwise or of image pixels with + * constant + * @c) and writes the result to @out. + * + * See also: im_andimage(), im_orimage_vec(). + * + * Returns: 0 on success, -1 on error + */ +int +im_orimageconst( IMAGE *in, IMAGE *out, double c ) +{ + return( im_orimage_vec( in, out, 1, &c ) ); +} + CONST1_BUFFER( EOR, ^ ) CONSTN_BUFFER( EOR, ^ ) +/** + * im_eorimage_vec: + * @in1: input #IMAGE 1 + * @in2: input #IMAGE 2 + * @out: output #IMAGE + * @n: array length + * @c: array of constants + * + * This operation calculates @in1 ^ @c (bitwise exclusive-or of image pixels + * with array + * @c) and writes the result to @out. + * + * See also: im_andimage(), im_orimageconst(). + * + * Returns: 0 on success, -1 on error + */ int im_eorimage_vec( IMAGE *in, IMAGE *out, int n, double *c ) { @@ -339,10 +427,47 @@ im_eorimage_vec( IMAGE *in, IMAGE *out, int n, double *c ) (im_wrapone_fn) EORn_buffer ) ); } +/** + * im_eorimageconst: + * @in1: input #IMAGE 1 + * @in2: input #IMAGE 2 + * @out: output #IMAGE + * @c: constant + * + * This operation calculates @in1 ^ @c (bitwise exclusive-or of image pixels + * with + * constant + * @c) and writes the result to @out. + * + * See also: im_andimage(), im_orimage_vec(). + * + * Returns: 0 on success, -1 on error + */ +int +im_eorimageconst( IMAGE *in, IMAGE *out, double c ) +{ + return( im_eorimage_vec( in, out, 1, &c ) ); +} + CONST1_BUFFER( SHIFTL, << ) CONSTN_BUFFER( SHIFTL, << ) +/** + * im_shiftleft_vec: + * @in: input #IMAGE + * @out: output #IMAGE + * @n: array length + * @c: array of constants + * + * This operation calculates @in1 << @c (left-shift by @c bits + * with array + * @c) and writes the result to @out. + * + * See also: im_andimage(), im_orimageconst(). + * + * Returns: 0 on success, -1 on error + */ int im_shiftleft_vec( IMAGE *in, IMAGE *out, int n, double *c ) { @@ -353,10 +478,46 @@ im_shiftleft_vec( IMAGE *in, IMAGE *out, int n, double *c ) (im_wrapone_fn) SHIFTLn_buffer ) ); } +/** + * im_shiftleft: + * @in: input #IMAGE + * @out: output #IMAGE + * @c: constant + * + * This operation calculates @in1 << @c (left-shift by @c bits) + * and writes the result to @out. + * + * See also: im_andimage(), im_orimageconst(). + * + * Returns: 0 on success, -1 on error + */ +int +im_shiftleft( IMAGE *in, IMAGE *out, int n ) +{ + double c = n; + + return( im_shiftleft_vec( in, out, 1, &c ) ); +} + CONST1_BUFFER( SHIFTR, >> ) CONSTN_BUFFER( SHIFTR, >> ) +/** + * im_shiftright_vec: + * @in: input #IMAGE + * @out: output #IMAGE + * @n: array length + * @c: array of constants + * + * This operation calculates @in1 << @c (right-shift by @c bits + * with array + * @c) and writes the result to @out. + * + * See also: im_andimage(), im_orimageconst(). + * + * Returns: 0 on success, -1 on error + */ int im_shiftright_vec( IMAGE *in, IMAGE *out, int n, double *c ) { @@ -367,50 +528,19 @@ im_shiftright_vec( IMAGE *in, IMAGE *out, int n, double *c ) (im_wrapone_fn) SHIFTRn_buffer ) ); } -int -im_and_vec( IMAGE *in, IMAGE *out, int n, double *c ) -{ - return( im_andimage_vec( in, out, n, c ) ); -} - -int -im_or_vec( IMAGE *in, IMAGE *out, int n, double *c ) -{ - return( im_orimage_vec( in, out, n, c ) ); -} - -int -im_eor_vec( IMAGE *in, IMAGE *out, int n, double *c ) -{ - return( im_eorimage_vec( in, out, n, c ) ); -} - -int -im_andconst( IMAGE *in, IMAGE *out, double c ) -{ - return( im_andimage_vec( in, out, 1, &c ) ); -} - -int -im_orconst( IMAGE *in, IMAGE *out, double c ) -{ - return( im_orimage_vec( in, out, 1, &c ) ); -} - -int -im_eorconst( IMAGE *in, IMAGE *out, double c ) -{ - return( im_eorimage_vec( in, out, 1, &c ) ); -} - -int -im_shiftleft( IMAGE *in, IMAGE *out, int n ) -{ - double c = n; - - return( im_shiftleft_vec( in, out, 1, &c ) ); -} - +/** + * im_shiftright: + * @in: input #IMAGE + * @out: output #IMAGE + * @c: constant + * + * This operation calculates @in1 >> @c (right-shift by @c bits) + * and writes the result to @out. + * + * See also: im_andimage(), im_orimageconst(). + * + * Returns: 0 on success, -1 on error + */ int im_shiftright( IMAGE *in, IMAGE *out, int n ) { diff --git a/libvips/colour/colour.c b/libvips/colour/colour.c index 1675e787..64aac347 100644 --- a/libvips/colour/colour.c +++ b/libvips/colour/colour.c @@ -482,7 +482,7 @@ im_col_rgb2XYZ( struct im_col_display *d, struct im_col_tab_disp *table, int i; if( r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255 ) { - im_errormsg( "im_col_rgb2XYZ: out of range [0,255]" ); + im_error( "im_col_rgb2XYZ", "%s", _( "out of range [0,255]" ) ); return( -1 ); } @@ -508,7 +508,7 @@ im_col_rgb2XYZ( struct im_col_display *d, struct im_col_tab_disp *table, break; default: - im_errormsg( "im_col_rgb2XYZ: bad display type" ); + im_error( "im_col_rgb2XYZ", "%s", _( "bad display type" ) ); return( -1 ); } @@ -621,7 +621,7 @@ im_col_XYZ2rgb( struct im_col_display *d, struct im_col_tab_disp *table, break; default: - im_errormsg("XYZ2rgb: display unknown"); + im_error( "XYZ2rgb", "%s", _( "display unknown" ) ); return( -1 ); /*NOTREACHED*/ } diff --git a/libvips/colour/im_LCh2Lab.c b/libvips/colour/im_LCh2Lab.c index 4e7b1c2b..608ef5e8 100644 --- a/libvips/colour/im_LCh2Lab.c +++ b/libvips/colour/im_LCh2Lab.c @@ -88,7 +88,8 @@ im_LCh2Lab( IMAGE *in, IMAGE *out ) */ if( in->Bands != 3 || in->BandFmt != IM_BANDFMT_FLOAT || in->Coding != IM_CODING_NONE ) { - im_errormsg( "im_LCh2Lab: 3-band float uncoded input only" ); + im_error( "im_LCh2Lab", "%s", + _( "3-band float uncoded input only" ) ); return( -1 ); } diff --git a/libvips/colour/im_LCh2UCS.c b/libvips/colour/im_LCh2UCS.c index a826ff47..1c4de442 100644 --- a/libvips/colour/im_LCh2UCS.c +++ b/libvips/colour/im_LCh2UCS.c @@ -79,7 +79,8 @@ im_LCh2UCS( IMAGE *in, IMAGE *out ) */ if( in->Bands != 3 || in->BandFmt != IM_BANDFMT_FLOAT || in->Coding != IM_CODING_NONE ) { - im_errormsg( "im_LCh2UCS: 3-band uncoded float input only" ); + im_error( "im_LCh2UCS", "%s", + _( "3-band uncoded float input only" ) ); return( -1 ); } diff --git a/libvips/colour/im_Lab2LCh.c b/libvips/colour/im_Lab2LCh.c index 8cbdf471..25c7ec46 100644 --- a/libvips/colour/im_Lab2LCh.c +++ b/libvips/colour/im_Lab2LCh.c @@ -82,7 +82,8 @@ im_Lab2LCh( IMAGE *in, IMAGE *out ) */ if( in->Bands != 3 || in->BandFmt != IM_BANDFMT_FLOAT || in->Coding != IM_CODING_NONE ) { - im_errormsg( "im_Lab2LCh: 3-band uncoded float input only" ); + im_error( "im_Lab2LCh", "%s", + _( "3-band uncoded float input only" ) ); return( -1 ); } diff --git a/libvips/colour/im_Lab2LabQ.c b/libvips/colour/im_Lab2LabQ.c index 70dc4254..807d45f8 100644 --- a/libvips/colour/im_Lab2LabQ.c +++ b/libvips/colour/im_Lab2LabQ.c @@ -130,11 +130,13 @@ im_Lab2LabQ( IMAGE *labim, IMAGE *outim ) /* Check for uncoded Lab type */ if( labim->Coding != IM_CODING_NONE ) { - im_errormsg( "im_Lab2LabQ: uncoded input only" ); + im_error( "im_Lab2LabQ", "%s", + _( "uncoded input only" ) ); return( -1 ); } if( labim->BandFmt != IM_BANDFMT_FLOAT || labim->Bands != 3 ) { - im_errormsg( "im_Lab2LabQ: three-band float input only" ); + im_error( "im_Lab2LabQ", "%s", + _( "three-band float input only" ) ); return( -1 ); } diff --git a/libvips/colour/im_Lab2LabS.c b/libvips/colour/im_Lab2LabS.c index d83ba931..56158d04 100644 --- a/libvips/colour/im_Lab2LabS.c +++ b/libvips/colour/im_Lab2LabS.c @@ -66,11 +66,13 @@ im_Lab2LabS( IMAGE *labim, IMAGE *outim ) /* Check for uncoded Lab type */ if( labim->Coding != IM_CODING_NONE ) { - im_errormsg( "im_Lab2LabS: uncoded input only" ); + im_error( "im_Lab2LabS", "%s", + _( "uncoded input only" ) ); return( -1 ); } if( labim->BandFmt != IM_BANDFMT_FLOAT || labim->Bands != 3 ) { - im_errormsg( "im_Lab2LabS: three-band float input only" ); + im_error( "im_Lab2LabS", "%s", + _( "three-band float input only" ) ); return( -1 ); } diff --git a/libvips/colour/im_LabQ2Lab.c b/libvips/colour/im_LabQ2Lab.c index 327ec18d..b29e6c19 100644 --- a/libvips/colour/im_LabQ2Lab.c +++ b/libvips/colour/im_LabQ2Lab.c @@ -111,7 +111,7 @@ im_LabQ2Lab( IMAGE *labim, IMAGE *outim ) /* check for coded Lab type */ if( labim->Coding != IM_CODING_LABQ ) { - im_errormsg( "im_LabQ2Lab: not a packed Lab image" ); + im_error( "im_LabQ2Lab", "%s", _( "not a packed Lab image" ) ); return( -1 ); } diff --git a/libvips/colour/im_LabQ2LabS.c b/libvips/colour/im_LabQ2LabS.c index f2fe3a0d..8357107b 100644 --- a/libvips/colour/im_LabQ2LabS.c +++ b/libvips/colour/im_LabQ2LabS.c @@ -101,7 +101,8 @@ im_LabQ2LabS( IMAGE *labim, IMAGE *outim ) /* check for coded Lab type */ if( labim->Coding != IM_CODING_LABQ ) { - im_errormsg( "im_LabQ2LabS: not a packed Lab image" ); + im_error( "im_LabQ2LabS", "%s", + _( "not a packed Lab image" ) ); return( -1 ); } diff --git a/libvips/colour/im_LabQ2disp.c b/libvips/colour/im_LabQ2disp.c index 88fac6ec..85b84fe6 100644 --- a/libvips/colour/im_LabQ2disp.c +++ b/libvips/colour/im_LabQ2disp.c @@ -178,7 +178,8 @@ im_LabQ2disp_table( IMAGE *in, IMAGE *out, void *table ) CalibrateInfo *cal = (CalibrateInfo *) table; if ( in->Coding != IM_CODING_LABQ ) { - im_errormsg( "im_LabQ2Lab: not a packed Lab image" ); + im_error( "im_LabQ2Lab", "%s", + _( "not a packed Lab image" ) ); return( -1 ); } diff --git a/libvips/colour/im_LabS2Lab.c b/libvips/colour/im_LabS2Lab.c index 58c8b431..5aabf78d 100644 --- a/libvips/colour/im_LabS2Lab.c +++ b/libvips/colour/im_LabS2Lab.c @@ -72,11 +72,13 @@ im_LabS2Lab( IMAGE *in, IMAGE *out ) /* Check type. */ if( in->Coding != IM_CODING_NONE ) { - im_errormsg( "im_LabS2Lab: not an uncoded image" ); + im_error( "im_LabS2Lab", "%s", + _( "not an uncoded image" ) ); return( -1 ); } if( in->BandFmt != IM_BANDFMT_SHORT || in->Bands != 3 ) { - im_errormsg( "im_LabS2Lab: not a 3-band signed short image" ); + im_error( "im_LabS2Lab", "%s", + _( "not a 3-band signed short image" ) ); return( -1 ); } diff --git a/libvips/colour/im_LabS2LabQ.c b/libvips/colour/im_LabS2LabQ.c index 5e47764a..0c1dc014 100644 --- a/libvips/colour/im_LabS2LabQ.c +++ b/libvips/colour/im_LabS2LabQ.c @@ -125,11 +125,13 @@ im_LabS2LabQ( IMAGE *in, IMAGE *out ) /* Check type. */ if( in->Coding != IM_CODING_NONE ) { - im_errormsg( "im_LabS2LabQ: not an uncoded image" ); + im_error( "im_LabS2LabQ", "%s", + _( "not an uncoded image" ) ); return( -1 ); } if( in->BandFmt != IM_BANDFMT_SHORT || in->Bands != 3 ) { - im_errormsg( "im_LabS2LabQ: not a 3-band signed short image" ); + im_error( "im_LabS2LabQ", "%s", + _( "not a 3-band signed short image" ) ); return( -1 ); } diff --git a/libvips/colour/im_UCS2LCh.c b/libvips/colour/im_UCS2LCh.c index 84085e02..4bafa421 100644 --- a/libvips/colour/im_UCS2LCh.c +++ b/libvips/colour/im_UCS2LCh.c @@ -88,7 +88,8 @@ im_UCS2LCh( IMAGE *in, IMAGE *out ) */ if( in->Bands != 3 || in->BandFmt != IM_BANDFMT_FLOAT || in->Coding != IM_CODING_NONE ) { - im_errormsg( "im_UCS2LCh: 3-band float uncoded input only" ); + im_error( "im_UCS2LCh", "%s", + _( "3-band float uncoded input only" ) ); return( -1 ); } diff --git a/libvips/colour/im_XYZ2Yxy.c b/libvips/colour/im_XYZ2Yxy.c index 9c8b520d..e08d689a 100644 --- a/libvips/colour/im_XYZ2Yxy.c +++ b/libvips/colour/im_XYZ2Yxy.c @@ -84,7 +84,8 @@ im_XYZ2Yxy( IMAGE *in, IMAGE *out ) { if( in->Bands != 3 || in->BandFmt != IM_BANDFMT_FLOAT || in->Coding != IM_CODING_NONE ) { - im_errormsg( "im_XYZ2Yxy: 3-band uncoded float input only" ); + im_error( "im_XYZ2Yxy", "%s", + _( "3-band uncoded float input only" ) ); return( -1 ); } diff --git a/libvips/colour/im_Yxy2XYZ.c b/libvips/colour/im_Yxy2XYZ.c index 6dd1ea09..1b1fd053 100644 --- a/libvips/colour/im_Yxy2XYZ.c +++ b/libvips/colour/im_Yxy2XYZ.c @@ -85,7 +85,8 @@ im_Yxy2XYZ( IMAGE *in, IMAGE *out ) { if( in->Bands != 3 || in->BandFmt != IM_BANDFMT_FLOAT || in->Coding != IM_CODING_NONE ) { - im_errormsg( "im_Yxy2XYZ: 3-band uncoded float input only" ); + im_error( "im_Yxy2XYZ", "%s", + _( "3-band uncoded float input only" ) ); return( -1 ); } diff --git a/libvips/colour/im_dE00_fromLab.c b/libvips/colour/im_dE00_fromLab.c index a01b3fdb..3345b514 100644 --- a/libvips/colour/im_dE00_fromLab.c +++ b/libvips/colour/im_dE00_fromLab.c @@ -86,7 +86,7 @@ im_dE00_fromLab( IMAGE *im1, IMAGE *im2, IMAGE *out ) im1->Coding != IM_CODING_NONE || im2->Bands != 3 || im2->BandFmt != IM_BANDFMT_FLOAT || im2->Coding != IM_CODING_NONE ) { - im_errormsg( "im_dE00_fromLab: 3-band float only" ); + im_error( "im_dE00_fromLab", "%s", _( "3-band float only" ) ); return( -1 ); } diff --git a/libvips/colour/im_dECMC_fromLab.c b/libvips/colour/im_dECMC_fromLab.c index 70a6761b..b558ea11 100644 --- a/libvips/colour/im_dECMC_fromLab.c +++ b/libvips/colour/im_dECMC_fromLab.c @@ -86,7 +86,7 @@ im_dECMC_fromLab( IMAGE *im1, IMAGE *im2, IMAGE *out ) im1->Coding != IM_CODING_NONE || im2->Bands != 3 || im2->BandFmt != IM_BANDFMT_FLOAT || im2->Coding != IM_CODING_NONE ) { - im_errormsg( "im_dECMC_fromLab: 3-band float only" ); + im_error( "im_dECMC_fromLab", "%s", _( "3-band float only" ) ); return( -1 ); } diff --git a/libvips/colour/im_dE_fromLab.c b/libvips/colour/im_dE_fromLab.c index 27e07574..357d6257 100644 --- a/libvips/colour/im_dE_fromLab.c +++ b/libvips/colour/im_dE_fromLab.c @@ -92,7 +92,8 @@ im_dE_fromLab( IMAGE *im1, IMAGE *im2, IMAGE *out ) im1->Coding != IM_CODING_NONE || im2->Bands != 3 || im2->BandFmt != IM_BANDFMT_FLOAT || im2->Coding != IM_CODING_NONE ) { - im_errormsg( "im_dE_fromLab: inputs should be 3 band float"); + im_error( "im_dE_fromLab", "%s", + _( "inputs should be 3 band float") ); return( -1 ); } diff --git a/libvips/colour/im_icc_transform.c b/libvips/colour/im_icc_transform.c index 8aa2cb30..a09da2ae 100644 --- a/libvips/colour/im_icc_transform.c +++ b/libvips/colour/im_icc_transform.c @@ -391,17 +391,19 @@ im_icc_transform( IMAGE *in, IMAGE *out, if( !cmsIsIntentSupported( icc->in_profile, intent, LCMS_USED_AS_INPUT ) ) - im_warning( "im_icc_transform: intent %d (%s) not supported by " + im_warn( "im_icc_transform", + _( "intent %d (%s) not supported by " "profile \"%s\"; falling back to default intent " - "(usually PERCEPTUAL)", + "(usually PERCEPTUAL)" ), intent, decode_intent( intent ), input_profile_filename ); if( !cmsIsIntentSupported( icc->out_profile, intent, LCMS_USED_AS_OUTPUT ) ) - im_warning( "im_icc_transform: intent %d (%s) not supported by " + im_warn( "im_icc_transform", + _( "intent %d (%s) not supported by " "profile \"%s\"; falling back to default intent " - "(usually PERCEPTUAL)", + "(usually PERCEPTUAL)" ), intent, decode_intent( intent ), output_profile_filename ); @@ -524,7 +526,8 @@ icc_import( IMAGE *in, IMAGE *out, Icc *icc ) if( !cmsIsIntentSupported( icc->in_profile, icc->intent, LCMS_USED_AS_INPUT ) ) - im_warn( "im_icc_import", _( "intent %d (%s) not supported by " + im_warn( "im_icc_import", + _( "intent %d (%s) not supported by " "profile; falling back to default intent " "(usually PERCEPTUAL)" ), icc->intent, decode_intent( icc->intent ) ); @@ -697,9 +700,10 @@ im_icc_export_depth( IMAGE *in, IMAGE *out, int depth, if( !cmsIsIntentSupported( icc->out_profile, intent, LCMS_USED_AS_OUTPUT ) ) - im_warning( "im_icc_export: intent %d (%s) not supported by " + im_warn( "im_icc_export", + _( "intent %d (%s) not supported by " "profile \"%s\"; falling back to default intent " - "(usually PERCEPTUAL)", + "(usually PERCEPTUAL)" ), intent, decode_intent( intent ), output_profile_filename ); diff --git a/libvips/colour/im_lab_morph.c b/libvips/colour/im_lab_morph.c index e4ac277c..7ec28e6c 100644 --- a/libvips/colour/im_lab_morph.c +++ b/libvips/colour/im_lab_morph.c @@ -93,7 +93,8 @@ morph_init( Params *parm, parm->b_scale = b_scale; if( mask->xsize != 3 || mask->ysize < 1 || mask->ysize > 100 ) { - im_errormsg( "im_lab_morph: bad greyscale mask size" ); + im_error( "im_lab_morph", "%s", + _( "bad greyscale mask size" ) ); return( -1 ); } for( i = 0; i < mask->ysize; i++ ) { @@ -103,8 +104,8 @@ morph_init( Params *parm, if( L < 0 || L > 100 || a < -120 || a > 120 || b < -120 || b > 120 ) { - im_errormsg( "im_lab_morph: bad greyscale mask " - "value, row %d", i ); + im_error( "im_lab_morph", + _( "bad greyscale mask value, row %d" ), i ); return( -1 ); } } @@ -228,15 +229,18 @@ im_lab_morph( IMAGE *in, IMAGE *out, } if( in->Coding != IM_CODING_NONE ) { - im_errormsg( "im_lab_morph: must be uncoded or IM_CODING_LABQ" ); + im_error( "im_lab_morph", "%s", + _( "must be uncoded or IM_CODING_LABQ" ) ); return( -1 ); } if( in->BandFmt != IM_BANDFMT_FLOAT && in->BandFmt != IM_BANDFMT_DOUBLE ) { - im_errormsg( "im_lab_morph: must be uncoded float or double" ); + im_error( "im_lab_morph", "%s", + _( "must be uncoded float or double" ) ); return( -1 ); } if( in->Bands != 3 ) { - im_errormsg( "im_lab_morph: must be 3 bands" ); + im_error( "im_lab_morph", "%s", + _( "must be 3 bands" ) ); return( -1 ); } diff --git a/libvips/conversion/im_bandjoin.c b/libvips/conversion/im_bandjoin.c index 2edec590..69db9b85 100644 --- a/libvips/conversion/im_bandjoin.c +++ b/libvips/conversion/im_bandjoin.c @@ -124,15 +124,15 @@ im_bandjoin( IMAGE *in1, IMAGE *in2, IMAGE *out ) return( -1 ); if( in1->Xsize != in2->Xsize || in1->Ysize != in2->Ysize ) { - im_errormsg( "im_bandjoin: images not same size" ); + im_error( "im_bandjoin", "%s", _( "images not same size" ) ); return( -1 ); } if( in1->BandFmt != in2->BandFmt ) { - im_errormsg( "im_bandjoin: images not same type" ); + im_error( "im_bandjoin", "%s", _( "images not same type" ) ); return( -1 ); } if( in1->Coding != IM_CODING_NONE || in2->Coding != IM_CODING_NONE ) { - im_errormsg( "im_bandjoin: input coded" ); + im_error( "im_bandjoin", "%s", _( "input coded" ) ); return( -1 ); } diff --git a/libvips/conversion/im_black.c b/libvips/conversion/im_black.c index 87a783f0..e1cd92a7 100644 --- a/libvips/conversion/im_black.c +++ b/libvips/conversion/im_black.c @@ -84,7 +84,7 @@ im_black( IMAGE *out, int x, int y, int bands ) /* Check parameters. */ if( x < 0 || y < 0 || bands < 0 ) { - im_errormsg( "im_black: bad parameter" ); + im_error( "im_black", "%s", _( "bad parameter" ) ); return( -1 ); } diff --git a/libvips/conversion/im_c2amph.c b/libvips/conversion/im_c2amph.c index 112ce044..125e33c9 100644 --- a/libvips/conversion/im_c2amph.c +++ b/libvips/conversion/im_c2amph.c @@ -126,7 +126,8 @@ int im_c2amph( IMAGE *in, IMAGE *out ) { if( in->Coding != IM_CODING_NONE || !im_iscomplex( in ) ) { - im_errormsg( "im_c2amph: input should be uncoded complex" ); + im_error( "im_c2amph", "%s", + _( "input should be uncoded complex" ) ); return( -1 ); } if( im_cp_desc( out, in ) ) diff --git a/libvips/conversion/im_c2imag.c b/libvips/conversion/im_c2imag.c index 504d1853..933a878c 100644 --- a/libvips/conversion/im_c2imag.c +++ b/libvips/conversion/im_c2imag.c @@ -90,7 +90,8 @@ int im_c2imag( IMAGE *in, IMAGE *out ) { if( in->Coding != IM_CODING_NONE || !im_iscomplex( in ) ) { - im_errormsg( "im_c2imag: input should be uncoded complex" ); + im_error( "im_c2imag", "%s", + _( "input should be uncoded complex" ) ); return( -1 ); } if( im_cp_desc( out, in ) ) diff --git a/libvips/conversion/im_c2real.c b/libvips/conversion/im_c2real.c index 0a14a30b..a7cba6b3 100644 --- a/libvips/conversion/im_c2real.c +++ b/libvips/conversion/im_c2real.c @@ -95,7 +95,8 @@ int im_c2real( IMAGE *in, IMAGE *out ) { if( in->Coding != IM_CODING_NONE || !im_iscomplex( in ) ) { - im_errormsg( "im_c2real: input should be uncoded complex" ); + im_error( "im_c2real", "%s", + _( "input should be uncoded complex" ) ); return( -1 ); } if( im_cp_desc( out, in ) ) diff --git a/libvips/conversion/im_c2rect.c b/libvips/conversion/im_c2rect.c index a4c1a13f..30690c66 100644 --- a/libvips/conversion/im_c2rect.c +++ b/libvips/conversion/im_c2rect.c @@ -92,7 +92,8 @@ int im_c2rect( IMAGE *in, IMAGE *out ) { if( in->Coding != IM_CODING_NONE || !im_iscomplex( in ) ) { - im_errormsg( "im_c2rect: input should be uncoded complex" ); + im_error( "im_c2rect", "%s", + _( "input should be uncoded complex" ) ); return( -1 ); } if( im_cp_desc( out, in ) ) diff --git a/libvips/conversion/im_mask2vips.c b/libvips/conversion/im_mask2vips.c index 8f864821..85154ec6 100644 --- a/libvips/conversion/im_mask2vips.c +++ b/libvips/conversion/im_mask2vips.c @@ -60,7 +60,7 @@ im_mask2vips( DOUBLEMASK *in, IMAGE *out ) /* Check the mask. */ if( !in || !in->coeff ) { - im_errormsg( "im_mask2vips: bad input mask" ); + im_error( "im_mask2vips", "%s", _( "bad input mask" ) ); return( -1 ); } diff --git a/libvips/conversion/im_recomb.c b/libvips/conversion/im_recomb.c index 009e1772..8f05c6d0 100644 --- a/libvips/conversion/im_recomb.c +++ b/libvips/conversion/im_recomb.c @@ -111,7 +111,7 @@ recomb_buf( void *bin, void *bout, int width, IMAGE *in, DOUBLEMASK *mat ) case IM_BANDFMT_DOUBLE: LOOP( double, double ); break; default: - im_errormsg( "im_recomb: unsupported input type" ); + im_error( "im_recomb", "%s", _( "unsupported input type" ) ); return( -1 ); } @@ -130,11 +130,13 @@ im_recomb( IMAGE *in, IMAGE *out, DOUBLEMASK *mat ) if( im_piocheck( in, out ) ) return( -1 ); if( in->Coding != IM_CODING_NONE || im_iscomplex( in ) ) { - im_errormsg( "im_recomb: uncoded non-complex only" ); + im_error( "im_recomb", "%s", + _( "uncoded non-complex only" ) ); return( -1 ); } if( in->Bands != mat->xsize ) { - im_errormsg( "im_recomb: bands in must equal matrix width" ); + im_error( "im_recomb", "%s", + _( "bands in must equal matrix width" ) ); return( -1 ); } diff --git a/libvips/conversion/im_replicate.c b/libvips/conversion/im_replicate.c index a669c3bd..f374a5fe 100644 --- a/libvips/conversion/im_replicate.c +++ b/libvips/conversion/im_replicate.c @@ -134,7 +134,7 @@ int im_replicate( IMAGE *in, IMAGE *out, int across, int down ) { if( across <= 0 || down <= 0 ) { - im_errormsg( "im_replicate: bad parameters" ); + im_error( "im_replicate", "%s", _( "bad parameters" ) ); return( -1 ); } if( im_piocheck( in, out ) ) diff --git a/libvips/conversion/im_ri2c.c b/libvips/conversion/im_ri2c.c index 3d5d2dfd..3a4d15c8 100644 --- a/libvips/conversion/im_ri2c.c +++ b/libvips/conversion/im_ri2c.c @@ -115,11 +115,11 @@ im_ri2c( IMAGE *in1, IMAGE *in2, IMAGE *out ) * im_wrapmany does this for us. */ if( in1->Coding != IM_CODING_NONE || in2->Coding != IM_CODING_NONE ) { - im_errormsg( "im_ri2c: inputs should be uncoded" ); + im_error( "im_ri2c", "%s", _( "inputs should be uncoded" ) ); return( -1 ); } if( im_iscomplex( in1 ) || im_iscomplex( in2 ) ) { - im_errormsg( "im_ri2c: inputs already complex" ); + im_error( "im_ri2c", "%s", _( "inputs already complex" ) ); return( -1 ); } diff --git a/libvips/conversion/im_slice.c b/libvips/conversion/im_slice.c index 2e1077aa..369dbb09 100644 --- a/libvips/conversion/im_slice.c +++ b/libvips/conversion/im_slice.c @@ -88,26 +88,26 @@ double t1, t2; /* Check our args. */ if( im_iocheck( in, out ) ) { - im_errormsg("im_slice: im_iocheck failed"); + im_error( "im_slice", "%s", _( "im_iocheck failed") ); return( -1 ); } if( in->Coding != IM_CODING_NONE ) { - im_errormsg("im_slice: input should be uncoded"); + im_error( "im_slice", "%s", _( "input should be uncoded") ); return( -1 ); } /* Set up the output header. */ if( im_cp_desc( out, in ) ) { - im_errormsg("im_slice: im_cp_desc failed"); + im_error( "im_slice", "%s", _( "im_cp_desc failed") ); return( -1 ); } out->BandFmt = IM_BANDFMT_UCHAR; out->Bbits = IM_BBITS_BYTE; if( im_setupout( out ) ) { - im_errormsg("im_slice: im_setupout failed"); + im_error( "im_slice", "%s", _( "im_setupout failed") ); return( -1 ); } @@ -149,7 +149,7 @@ double t1, t2; im_for_all_types( im_slice_loop ); default: - im_errormsg("im_slice: Unknown input format"); + im_error( "im_slice", "%s", _( "Unknown input format") ); return( -1 ); } diff --git a/libvips/conversion/im_thresh.c b/libvips/conversion/im_thresh.c index 3662fece..699cd2af 100644 --- a/libvips/conversion/im_thresh.c +++ b/libvips/conversion/im_thresh.c @@ -80,20 +80,19 @@ double threshold; /* Check our args. */ if( im_iocheck( in, out ) ) - { im_errormsg("im_thresh: im_iocheck failed"); return( -1 ); } - if( in->Coding != IM_CODING_NONE ) - { im_errormsg("im_thresh: input should be uncoded");return(-1);} + return( -1 ); + if( in->Coding != IM_CODING_NONE ) { + im_error( "im_thresh", "%s", _( "input should be uncoded") ); + return(-1); + } /* Set up the output header. */ if( im_cp_desc( out, in ) ) - { im_errormsg("im_thresh: im_cp_desc failed"); return( -1 ); } + return( -1 ); out->BandFmt = IM_BANDFMT_UCHAR; out->Bbits = IM_BBITS_BYTE; if( im_setupout( out ) ) - { - im_errormsg("im_thresh: im_setupout failed"); return( -1 ); - } /* Make buffer for building o/p in. */ epl = in->Xsize * in->Bands; @@ -126,7 +125,7 @@ double threshold; im_for_all_types( im_thresh_loop ); default: - im_errormsg("im_thresh: Unknown input format"); + im_error( "im_thresh", "%s", _( "Unknown input format") ); return( -1 ); } diff --git a/libvips/convolution/im_conv.c b/libvips/convolution/im_conv.c index 479184d8..8768b564 100644 --- a/libvips/convolution/im_conv.c +++ b/libvips/convolution/im_conv.c @@ -504,7 +504,7 @@ im__create_int_luts( int *buffer, int buffersize, buf2 = (int*)calloc( (unsigned)buffersize, sizeof(int) ); if ( ( buf1 == NULL ) || ( buf2 == NULL ) ) { - im_errormsg("im_create_int_luts: calloc failed (1)"); + im_error( "im_create_int_luts", "%s", _( "calloc failed (1)") ); return( -1 ); } @@ -557,7 +557,7 @@ im__create_int_luts( int *buffer, int buffersize, orig_luts[i] = (int*)calloc((unsigned)256, sizeof(int)); if (orig_luts[i] == NULL) { - im_errormsg("im_create_int_luts: calloc failed (2)"); + im_error( "im_create_int_luts", "%s", _( "calloc failed (2)") ); return( -1 ); } for ( j=0; j<256; j++ ) diff --git a/libvips/convolution/im_convsub.c b/libvips/convolution/im_convsub.c index 738d240f..d829c9a8 100644 --- a/libvips/convolution/im_convsub.c +++ b/libvips/convolution/im_convsub.c @@ -89,22 +89,22 @@ int xskip, yskip; /* Check input, output and vars */ if ((xskip < 1)||(yskip < 1)) { - im_errormsg("im_convsub: xskip and yskip must be >= 1"); + im_error( "im_convsub", "%s", _( "xskip and yskip must be >= 1") ); return(-1); } if (im_iocheck(in, out) == -1) - { im_errormsg("im_convsub: Unable to im_iocheck"); return(-1); } + return( -1 ); if ( (in->Coding != IM_CODING_NONE)||(in->Bbits != IM_BBITS_BYTE) ||(in->BandFmt != IM_BANDFMT_UCHAR) ) { - im_errormsg("im_convsub:input should be unsigned char uncoded"); + im_error( "im_convsub", "%s", _( "nput should be unsigned char uncoded") ); return(-1); } /* Prepare output */ if (im_cp_desc(out, in) == -1) - { im_errormsg("im_convsub: im_cp_desc failed"); return(-1); } + return( -1 ); tempsize = in->Xsize/xskip; while ( 1 ) { @@ -127,16 +127,20 @@ int xskip, yskip; break; } out->Ysize = tempsize; - if ( ( out->Xsize < 2 )||( out->Ysize < 2 ) ) - {im_errormsg("im_convsub: too small output sizes");return(-1); } + if ( ( out->Xsize < 2 )||( out->Ysize < 2 ) ) { + im_error( "im_convsub", "%s", _( "too small output sizes") ); + return(-1); + } if( im_setupout(out) == -1) - {im_errormsg("im_convsub: im_setupout failed"); return(-1); } + return(-1); /* Malloc one line of output data */ os = out->Xsize * out->Bands; - if ( (line=(PEL*)calloc( (unsigned)os, sizeof(char))) == NULL) - { im_errormsg("im_convsub: unable to calloc(1)"); return(-1); } + if ( (line=(PEL*)calloc( (unsigned)os, sizeof(char))) == NULL) { + im_error( "im_convsub", "%s", _( "unable to calloc(1)") ); + return(-1); + } /* Malloc pointers and put them at correct location */ ms = m->xsize * m->ysize; @@ -152,7 +156,10 @@ int xskip, yskip; ((pnts = (PEL**)calloc((unsigned)count, sizeof(char *))) == NULL)|| ((cpnt1s=(PEL**)calloc((unsigned)count, sizeof(char *))) == NULL)|| ((cpnt2s=(PEL**)calloc((unsigned)count, sizeof(char *))) ==NULL ) ) - { im_errormsg("im_convsub: unable to calloc(2)"); return(-1); } + { + im_error( "im_convsub", "%s", _( "unable to calloc(2)") ); + return(-1); + } pnt = pnts; cpnt1 = cpnt1s; @@ -177,21 +184,23 @@ int xskip, yskip; } } - if ( i != count ) - { im_errormsg("im_convsub: impossible state"); return(-1); } + if ( i != count ) { + im_error( "im_convsub", "%s", _( "impossible state") ); + return(-1); } /* Malloc pointers; not all lut_orig are used necessarily */ lut_orig = (int**)calloc((unsigned)count, sizeof(int**) ); lut = (int**)calloc((unsigned)count, sizeof(int**) ); - if ( (lut == NULL) || (lut_orig == NULL) ) - { im_errormsg("im_conv: unable to calloc(1)"); return(-1); } + if ( (lut == NULL) || (lut_orig == NULL) ) { + im_error( "im_conv", "%s", _( "unable to calloc(1)") ); + return(-1); } /* Create luts; count is needed for freeing pointers. Not all lut_orig are used * if zero elms are detected. */ if ( im__create_int_luts(newm, count, lut_orig, lut, &lutcnt ) == -1 ) { - im_errormsg("im_convsub: im_create_int_luts failed"); + im_error( "im_convsub", "%s", _( "im_create_int_luts failed") ); return(-1); } @@ -237,7 +246,6 @@ int xskip, yskip; /* Output the calculated line */ if ( im_writeline(y, out, (PEL*)line) == -1 ) { - im_errormsg("im_convsub: im_writeline failed(2)"); free((char*)line); free((char*)newm); free((char*)pnts); free((char*)cpnt1s); free((char*)cpnt2s); diff --git a/libvips/convolution/im_fastcor.c b/libvips/convolution/im_fastcor.c index 459b8c72..f9466af7 100644 --- a/libvips/convolution/im_fastcor.c +++ b/libvips/convolution/im_fastcor.c @@ -148,7 +148,7 @@ im_fastcor_raw( IMAGE *in, IMAGE *ref, IMAGE *out ) /* Check sizes. */ if( in->Xsize < ref->Xsize || in->Ysize < ref->Ysize ) { - im_errormsg( "im_fastcor: ref not smaller than in" ); + im_error( "im_fastcor", "%s", _( "ref not smaller than in" ) ); return( -1 ); } @@ -158,7 +158,8 @@ im_fastcor_raw( IMAGE *in, IMAGE *ref, IMAGE *out ) in->BandFmt != IM_BANDFMT_UCHAR || ref->Coding != IM_CODING_NONE || ref->Bands != 1 || ref->BandFmt != IM_BANDFMT_UCHAR ) { - im_errormsg( "im_fastcor_raw: input not uncoded 1 band uchar" ); + im_error( "im_fastcor_raw", "%s", + _( "input not uncoded 1 band uchar" ) ); return( -1 ); } diff --git a/libvips/convolution/im_gaussnoise.c b/libvips/convolution/im_gaussnoise.c index e2c32617..bd6ed59b 100644 --- a/libvips/convolution/im_gaussnoise.c +++ b/libvips/convolution/im_gaussnoise.c @@ -121,7 +121,7 @@ im_gaussnoise( IMAGE *out, int x, int y, double mean, double sigma ) /* Check parameters. */ if( x < 0 || y < 0 ) { - im_errormsg( "im_gaussnoise: bad parameter" ); + im_error( "im_gaussnoise", "%s", _( "bad parameter" ) ); return( -1 ); } diff --git a/libvips/convolution/im_logmasks.c b/libvips/convolution/im_logmasks.c index 4aec46f6..339ead96 100644 --- a/libvips/convolution/im_logmasks.c +++ b/libvips/convolution/im_logmasks.c @@ -131,7 +131,7 @@ im_log_dmask( const char *filename, double sigma, double min_ampl ) last = val; } if( x == IM_MAXMASK ) { - im_errormsg( "im_log_dmask: mask too large" ); + im_error( "im_log_dmask", "%s", _( "mask too large" ) ); return( NULL ); } diff --git a/libvips/convolution/im_rank.c b/libvips/convolution/im_rank.c index 10cf503c..1fd0c2e8 100644 --- a/libvips/convolution/im_rank.c +++ b/libvips/convolution/im_rank.c @@ -354,12 +354,13 @@ im_rank_raw( IMAGE *in, IMAGE *out, int xsize, int ysize, int order ) /* Check parameters. */ if( !in || in->Coding != IM_CODING_NONE || im_iscomplex( in ) ) { - im_errormsg( "im_rank: input non-complex uncoded only" ); + im_error( "im_rank", "%s", + _( "input non-complex uncoded only" ) ); return( -1 ); } if( xsize > 1000 || ysize > 1000 || xsize <= 0 || ysize <= 0 || order < 0 || order > xsize * ysize - 1 ) { - im_errormsg( "im_rank: bad parameters" ); + im_error( "im_rank", "%s", _( "bad parameters" ) ); return( -1 ); } if( im_piocheck( in, out ) ) @@ -384,7 +385,7 @@ im_rank_raw( IMAGE *in, IMAGE *out, int xsize, int ysize, int order ) out->Xsize -= xsize - 1; out->Ysize -= ysize - 1; if( out->Xsize <= 0 || out->Ysize <= 0 ) { - im_errormsg( "im_rank: image too small for window" ); + im_error( "im_rank", "%s", _( "image too small for window" ) ); return( -1 ); } diff --git a/libvips/convolution/im_rank_image.c b/libvips/convolution/im_rank_image.c index 59127bf2..d0c32844 100644 --- a/libvips/convolution/im_rank_image.c +++ b/libvips/convolution/im_rank_image.c @@ -275,12 +275,12 @@ im_rank_image( IMAGE **in, IMAGE *out, int n, int index ) Rank *rank; if( n < 1 ) { - im_errormsg( "im_rank_image: zero input images!" ); + im_error( "im_rank_image", "%s", _( "zero input images!" ) ); return( -1 ); } if( index < 0 || index > n - 1 ) { - im_errormsg( "im_rank_image: " - "index should be in range 0 - %d", n - 1 ); + im_error( "im_rank_image", + _( "index should be in range 0 - %d" ), n - 1 ); return( -1 ); } if( im_poutcheck( out ) ) @@ -290,25 +290,25 @@ im_rank_image( IMAGE **in, IMAGE *out, int n, int index ) return( -1 ); if( in[i]->Coding != IM_CODING_NONE || im_iscomplex( in[i] ) ) { - im_errormsg( "im_rank_image: " - "uncoded non-complex only" ); + im_error( "im_rank_image", "%s", + _( "uncoded non-complex only" ) ); return( -1 ); } if( in[0]->BandFmt != in[i]->BandFmt ) { - im_errormsg( "im_rank_image: " - "input images differ in format" ); + im_error( "im_rank_image", "%s", + _( "input images differ in format" ) ); return( -1 ); } if( in[0]->Xsize != in[i]->Xsize || in[0]->Ysize != in[i]->Ysize ) { - im_errormsg( "im_rank_image: " - "input images differ in size" ); + im_error( "im_rank_image", "%s", + _( "input images differ in size" ) ); return( -1 ); } if( in[0]->Bands != in[i]->Bands ) { - im_errormsg( "im_rank_image: " - "input images differ in number of bands" ); + im_error( "im_rank_image", "%s", + _( "input images differ in number of bands" ) ); return( -1 ); } } diff --git a/libvips/convolution/im_resize_linear.c b/libvips/convolution/im_resize_linear.c index fe371fd5..af2b23a4 100644 --- a/libvips/convolution/im_resize_linear.c +++ b/libvips/convolution/im_resize_linear.c @@ -122,11 +122,11 @@ im_resize_linear( IMAGE *in, IMAGE *out, int X, int Y ) if( im_iocheck( in, out ) ) return( -1 ); if( im_iscomplex( in ) ) { - im_errormsg( "im_lowpass: non-complex input only" ); + im_error( "im_lowpass", "%s", _( "non-complex input only" ) ); return( -1 ); } if( in->Coding != IM_CODING_NONE ) { - im_errormsg("im_lowpass: input should be uncoded"); + im_error("im_lowpass: ", "%s", _( "put should be uncoded") ); return( -1 ); } if( im_cp_desc( out, in ) ) @@ -181,7 +181,7 @@ for (y=0; yxsize != m->ysize || (m->xsize % 2) == 0 ) { - im_errormsg( "im_rotate_*mask*: mask should " - "be square of even size" ); + im_error( "im_rotate_mask", "%s", + _( "mask should be square of even size" ) ); return( NULL ); } if( !(offsets = fn( m->xsize )) ) @@ -254,8 +254,8 @@ rotimask( offset_fn fn, INTMASK *m, const char *name ) int i; if( m->xsize != m->ysize || (m->xsize % 2) == 0 ) { - im_errormsg( "im_rotate_*mask*: mask should " - "be square of even size" ); + im_error( "im_rotate_mask", "%s", + _( "mask should be square of even size" ) ); return( NULL ); } if( !(offsets = fn( m->xsize )) ) diff --git a/libvips/deprecated/Makefile.am b/libvips/deprecated/Makefile.am index 8803298f..db260da4 100644 --- a/libvips/deprecated/Makefile.am +++ b/libvips/deprecated/Makefile.am @@ -7,6 +7,7 @@ libdeprecated_la_SOURCES = \ im_gaddim.c \ im_cmulnorm.c \ im_gfadd.c \ + rename.c \ im_litecor.c INCLUDES = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@ diff --git a/libvips/deprecated/deprecated_dispatch.c b/libvips/deprecated/deprecated_dispatch.c index d5276d78..bafbfdf9 100644 --- a/libvips/deprecated/deprecated_dispatch.c +++ b/libvips/deprecated/deprecated_dispatch.c @@ -41,18 +41,6 @@ #include #endif /*WITH_DMALLOC*/ -/** - * SECTION: deprecated - * @short_description: various deprecated operations which remain for - * compatibility - * - * @stability: Stable - * @include: vips/vips.h - * - * These operations are left-overs from earlier versions of VIPS which are - * kept for compatibility. - */ - /* Two images in, one out. */ static im_arg_desc two_in_one_out[] = { @@ -182,13 +170,142 @@ static im_function litecor_desc = { litecor_args /* Arg list */ }; +/* affine args + */ +static im_arg_desc affine_args[] = { + IM_INPUT_IMAGE( "in" ), + IM_OUTPUT_IMAGE( "out" ), + IM_INPUT_DOUBLE( "a" ), + IM_INPUT_DOUBLE( "b" ), + IM_INPUT_DOUBLE( "c" ), + IM_INPUT_DOUBLE( "d" ), + IM_INPUT_DOUBLE( "dx" ), + IM_INPUT_DOUBLE( "dy" ), + IM_INPUT_INT( "x" ), + IM_INPUT_INT( "y" ), + IM_INPUT_INT( "w" ), + IM_INPUT_INT( "h" ) +}; + +/* Call im_affine via arg vector. + */ +static int +affine_vec( im_object *argv ) +{ + double a = *((double *) argv[2]); + double b = *((double *) argv[3]); + double c = *((double *) argv[4]); + double d = *((double *) argv[5]); + double dx = *((double *) argv[6]); + double dy = *((double *) argv[7]); + int x = *((int *) argv[8]); + int y = *((int *) argv[9]); + int w = *((int *) argv[10]); + int h = *((int *) argv[11]); + + return( im_affine( argv[0], argv[1], a, b, c, d, dx, dy, x, y, w, h ) ); +} + +/* Description of im_affine. + */ +static im_function affine_desc = { + "im_affine", /* Name */ + "affine transform", + IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ + affine_vec, /* Dispatch function */ + IM_NUMBER( affine_args ), /* Size of arg list */ + affine_args /* Arg list */ +}; + +/* similarity args + */ +static im_arg_desc similarity_args[] = { + IM_INPUT_IMAGE( "in" ), + IM_OUTPUT_IMAGE( "out" ), + IM_INPUT_DOUBLE( "a" ), + IM_INPUT_DOUBLE( "b" ), + IM_INPUT_DOUBLE( "dx" ), + IM_INPUT_DOUBLE( "dy" ) +}; + +/* Call im_similarity via arg vector. + */ +static int +similarity_vec( im_object *argv ) +{ + double a = *((double *) argv[2]); + double b = *((double *) argv[3]); + double dx = *((double *) argv[4]); + double dy = *((double *) argv[5]); + + return( im_similarity( argv[0], argv[1], a, b, dx, dy ) ); +} + +/* Description of im_similarity. + */ +static im_function similarity_desc = { + "im_similarity", /* Name */ + "similarity transformation", + IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ + similarity_vec, /* Dispatch function */ + IM_NUMBER( similarity_args ), /* Size of arg list */ + similarity_args /* Arg list */ +}; + +/* similarity_area args + */ +static im_arg_desc similarity_area_args[] = { + IM_INPUT_IMAGE( "in" ), + IM_OUTPUT_IMAGE( "out" ), + IM_INPUT_DOUBLE( "a" ), + IM_INPUT_DOUBLE( "b" ), + IM_INPUT_DOUBLE( "dx" ), + IM_INPUT_DOUBLE( "dy" ), + IM_INPUT_INT( "x" ), + IM_INPUT_INT( "y" ), + IM_INPUT_INT( "w" ), + IM_INPUT_INT( "h" ) +}; + +/* Call im_similarity_area via arg vector. + */ +static int +similarity_area_vec( im_object *argv ) +{ + double a = *((double *) argv[2]); + double b = *((double *) argv[3]); + double dx = *((double *) argv[4]); + double dy = *((double *) argv[5]); + int x = *((int *) argv[6]); + int y = *((int *) argv[7]); + int w = *((int *) argv[8]); + int h = *((int *) argv[9]); + + return( im_similarity_area( argv[0], argv[1], a, b, dx, dy, + x, y, w, h ) ); +} + +/* Description of im_similarity_area. + */ +static im_function similarity_area_desc = { + "im_similarity_area", /* Name */ + "output area xywh of similarity transformation", + IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ + similarity_area_vec, /* Dispatch function */ + IM_NUMBER( similarity_area_args ), /* Size of arg list */ + similarity_area_args /* Arg list */ +}; + /* Package up all these functions. */ static im_function *deprecated_list[] = { &cmulnorm_desc, &fav4_desc, &gadd_desc, - &litecor_desc + &litecor_desc, + &affine_desc, + &similarity_area_desc, + &similarity_desc }; /* Package of functions. diff --git a/libvips/deprecated/rename.c b/libvips/deprecated/rename.c new file mode 100644 index 00000000..5c6a786d --- /dev/null +++ b/libvips/deprecated/rename.c @@ -0,0 +1,141 @@ +/* rename.c --- wrappers for various renamed functions + * + * 20/9/09 + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /*HAVE_CONFIG_H*/ +#include + +#include +#include + +#ifdef WITH_DMALLOC +#include +#endif /*WITH_DMALLOC*/ + +int +im_remainderconst_vec( IMAGE *in, IMAGE *out, int n, double *c ) +{ + return( im_remainder_vec( in, out, n, c ) ); +} + +int +im_and_vec( IMAGE *in, IMAGE *out, int n, double *c ) +{ + return( im_andimage_vec( in, out, n, c ) ); +} + +int +im_or_vec( IMAGE *in, IMAGE *out, int n, double *c ) +{ + return( im_orimage_vec( in, out, n, c ) ); +} + +int +im_eor_vec( IMAGE *in, IMAGE *out, int n, double *c ) +{ + return( im_eorimage_vec( in, out, n, c ) ); +} + +int +im_andconst( IMAGE *in, IMAGE *out, double c ) +{ + return( im_andimageconst( in, out, c ) ); +} + +int +im_orconst( IMAGE *in, IMAGE *out, double c ) +{ + return( im_orimageconst( in, out, c ) ); +} + +int +im_eorconst( IMAGE *in, IMAGE *out, double c ) +{ + return( im_eorimageconst( in, out, c ) ); +} + +void +im_errormsg( const char *fmt, ... ) +{ + va_list ap; + + va_start( ap, fmt ); + im_verror( "untranslated", fmt, ap ); + va_end( ap ); +} + +void +im_verrormsg( const char *fmt, va_list ap ) +{ + im_verror( "untranslated", fmt, ap ); +} + +void +im_errormsg_system( int err, const char *fmt, ... ) +{ + va_list ap; + + va_start( ap, fmt ); + im_verror_system( err, "untranslated", fmt, ap ); + va_end( ap ); +} + +void +im_diagnostics( const char *fmt, ... ) +{ + va_list ap; + + va_start( ap, fmt ); + im_vdiag( "untranslated", fmt, ap ); + va_end( ap ); +} + +void +im_warning( const char *fmt, ... ) +{ + va_list ap; + + va_start( ap, fmt ); + im_vwarn( "untranslated", fmt, ap ); + va_end( ap ); +} + +int +im_affine( IMAGE *in, IMAGE *out, + double a, double b, double c, double d, double dx, double dy, + int ox, int oy, int ow, int oh ) +{ + return( im_affinei( in, out, + vips_interpolate_bilinear_static(), + a, b, c, d, dx, dy, + ox, oy, ow, oh ) ); +} diff --git a/libvips/freq_filt/fmask4th.c b/libvips/freq_filt/fmask4th.c index 6d7960d4..c9e77767 100644 --- a/libvips/freq_filt/fmask4th.c +++ b/libvips/freq_filt/fmask4th.c @@ -122,7 +122,7 @@ ideal_hpf( IMAGE *out, int xs, int ys, double fc ) double *xd, *yd, fc2, distance2; if( xs != ys || fc < 0.0 ) { - im_errormsg( "ideal_hpf: bad args" ); + im_error( "ideal_hpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -131,7 +131,7 @@ ideal_hpf( IMAGE *out, int xs, int ys, double fc ) else if( fc <= 1.0 && fc > 0.0 ) fc2 = fc * fc; else { - im_errormsg( "ideal_hpf: bad args" ); + im_error( "ideal_hpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -165,7 +165,7 @@ ideal_lpf( IMAGE *out, int xs, int ys, double fc ) double *xd, *yd, fc2, distance2; if( xs != ys || fc <= 0.0 ) { - im_errormsg( "ideal_lpf: bad args" ); + im_error( "ideal_lpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -174,7 +174,7 @@ ideal_lpf( IMAGE *out, int xs, int ys, double fc ) else if( fc <= 1.0 && fc > 0.0 ) fc2 = fc * fc; else { - im_errormsg( "ideal_lpf: bad args" ); + im_error( "ideal_lpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -207,7 +207,7 @@ butterworth_hpf( IMAGE *out, int xs, int ys, double *xd, *yd, fc2, distance2, cnst; if( xs != ys || fc < 0.0 || order < 1.0 || ac <= 0.0 || ac >= 1.0 ) { - im_errormsg( "butterworth_hpf: bad args" ); + im_error( "butterworth_hpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -216,7 +216,7 @@ butterworth_hpf( IMAGE *out, int xs, int ys, else if( fc <= 1.0 && fc > 0.0 ) fc2 = fc * fc; else { - im_errormsg( "butterworth_hpf: bad args" ); + im_error( "butterworth_hpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -254,7 +254,7 @@ butterworth_lpf( IMAGE *out, int xs, int ys, double *xd, *yd, fc2, distance2, cnst; if( xs != ys || fc <= 0.0 || order < 1.0 || ac >= 1.0 || ac <= 0.0 ) { - im_errormsg( "butterworth_lpf: bad args" ); + im_error( "butterworth_lpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -263,7 +263,7 @@ butterworth_lpf( IMAGE *out, int xs, int ys, else if( fc <= 1.0 && fc > 0.0 ) fc2 = fc * fc; else { - im_errormsg( "butterworth_lpf: bad args" ); + im_error( "butterworth_lpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -294,7 +294,7 @@ gaussian_hpf( IMAGE *out, int xs, int ys, double fc, double ac ) double *xd, *yd, fc2, distance2, cnst; if( xs != ys || fc <= 0.0 || ac >= 1.0 || ac <= 0.0 ) { - im_errormsg( "gaussian_hpf: bad args" ); + im_error( "gaussian_hpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -303,7 +303,7 @@ gaussian_hpf( IMAGE *out, int xs, int ys, double fc, double ac ) else if( fc <= 1.0 && fc > 0.0 ) fc2 = fc * fc; else { - im_errormsg( "gaussian_hpf: bad args" ); + im_error( "gaussian_hpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -335,7 +335,7 @@ gaussian_lpf( IMAGE *out, int xs, int ys, double fc, double ac ) double *xd, *yd, fc2, distance2, cnst; if( xs != ys || fc < 0.0 || ac >= 1.0 || ac <= 0.0 ) { - im_errormsg( "gaussian_lpf: bad args" ); + im_error( "gaussian_lpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -344,7 +344,7 @@ gaussian_lpf( IMAGE *out, int xs, int ys, double fc, double ac ) else if( fc <= 1.0 && fc > 0.0 ) fc2 = fc * fc; else { - im_errormsg( "gaussian_lpf: bad args" ); + im_error( "gaussian_lpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -375,7 +375,7 @@ ideal_rpf( IMAGE *out, int xs, int ys, double fc, double width ) double *xd, *yd, df, distance2, radius1_2, radius2_2; if( xs != ys || fc <= 0 || width <= 0 ) { - im_errormsg( "ideal_rpf: bad args" ); + im_error( "ideal_rpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -389,7 +389,7 @@ ideal_rpf( IMAGE *out, int xs, int ys, double fc, double width ) radius2_2 = (fc + df) * (fc + df) * 4.0 / ((double)(xs * xs)); } else { - im_errormsg( "ideal_rpf: bad args" ); + im_error( "ideal_rpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -425,7 +425,7 @@ ideal_rrf( IMAGE *out, int xs, int ys, double fc, double width ) double *xd, *yd, df, distance2, radius1_2, radius2_2; if( xs != ys || fc < 0.0 || width <= 0.0 ) { - im_errormsg( "ideal_rrf: bad args" ); + im_error( "ideal_rrf", "%s", _( "bad args" ) ); return( NULL ); } @@ -439,7 +439,7 @@ ideal_rrf( IMAGE *out, int xs, int ys, double fc, double width ) radius2_2 = (fc + df) * (fc + df) * 4.0 / ((double)(xs * xs)); } else { - im_errormsg( "ideal_rrf: bad args" ); + im_error( "ideal_rrf", "%s", _( "bad args" ) ); return( NULL ); } @@ -475,7 +475,7 @@ butterworth_rpf( IMAGE *out, int xs, int ys, if( xs != ys || fc <= 0.0 || width <= 0.0 || order < 1.0 || ac >= 1.0 || ac <= 0.0 ) { - im_errormsg( "butterworth_rpf: bad args" ); + im_error( "butterworth_rpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -489,7 +489,7 @@ butterworth_rpf( IMAGE *out, int xs, int ys, ndf = width /(double)ys; } else { - im_errormsg( "butterworth_rpf: bad args" ); + im_error( "butterworth_rpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -529,7 +529,7 @@ butterworth_rrf( IMAGE *out, int xs, int ys, if( xs != ys || fc <= 0.0 || width <= 0.0 || order < 1.0 || ac >= 1.0 || ac <= 0.0 ) { - im_errormsg( "butterworth_rrf: bad args" ); + im_error( "butterworth_rrf", "%s", _( "bad args" ) ); return( NULL ); } @@ -543,7 +543,7 @@ butterworth_rrf( IMAGE *out, int xs, int ys, ndf = width /(double)ys; } else { - im_errormsg( "butterworth_rrf: bad args" ); + im_error( "butterworth_rrf", "%s", _( "bad args" ) ); return( NULL ); } @@ -580,7 +580,7 @@ gaussian_rpf( IMAGE *out, int xs, int ys, double fc, double width, double ac ) double *xd, *yd, d, df, ndf, ndf2, nfc, cnst; if( xs != ys || fc < 0.0 || width <= 0.0 || ac <= 0.0 || ac > 1.0 ) { - im_errormsg( "gaussian_rpf: bad args" ); + im_error( "gaussian_rpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -594,7 +594,7 @@ gaussian_rpf( IMAGE *out, int xs, int ys, double fc, double width, double ac ) ndf = width /(double)ys; } else { - im_errormsg( "gaussian_rpf: bad args" ); + im_error( "gaussian_rpf", "%s", _( "bad args" ) ); return( NULL ); } @@ -631,7 +631,7 @@ gaussian_rrf( IMAGE *out, int xs, int ys, double fc, double width, double ac ) double *xd, *yd, d, df, ndf, ndf2, nfc, cnst; if( xs != ys || fc < 0.0 || width <= 0.0 || ac <= 0.0 || ac > 1.0 ) { - im_errormsg( "gaussian_rrf: bad args" ); + im_error( "gaussian_rrf", "%s", _( "bad args" ) ); return( NULL ); } @@ -645,7 +645,7 @@ gaussian_rrf( IMAGE *out, int xs, int ys, double fc, double width, double ac ) ndf = width / (double)ys; } else { - im_errormsg( "gaussian_rrf: bad args" ); + im_error( "gaussian_rrf", "%s", _( "bad args" ) ); return( NULL ); } @@ -699,7 +699,7 @@ fractal_flt( IMAGE *out, int xs, int ys, double frdim ) double *xd, *yd, distance2, cnst; if( xs != ys || frdim <= 2.0 || frdim >= 3.0 ) { - im_errormsg( "fractal_flt: bad args" ); + im_error( "fractal_flt", "%s", _( "bad args" ) ); return( NULL ); } @@ -792,7 +792,8 @@ im__create_quarter( IMAGE *out, int xs, int ys, MaskType flag, va_list ap ) return( fractal_flt( out, xs, ys, p0 ) ); default: - im_errormsg( "create_quarter: unimplemented mask" ); + im_error( "create_quarter", "%s", + _( "unimplemented mask" ) ); return( NULL ); } diff --git a/libvips/freq_filt/fmaskcir.c b/libvips/freq_filt/fmaskcir.c index 98b7fc27..09b9fc48 100644 --- a/libvips/freq_filt/fmaskcir.c +++ b/libvips/freq_filt/fmaskcir.c @@ -160,7 +160,7 @@ ideal_bpf( IMAGE *out, double fcx, double fcy, double r ) int y2plus, y2minus; if( xs != ys ) { - im_errormsg( "ideal_bpf: bad sizes" ); + im_error( "ideal_bpf", "%s", _( "bad sizes" ) ); return( -1 ); } if( fabs(fcx) <= 1.0 && fabs(fcy) < 1.0 && r > 0.0 && r < 1.0 ) { @@ -174,7 +174,7 @@ ideal_bpf( IMAGE *out, double fcx, double fcy, double r ) r2 = r*r; } else { - im_errormsg( "ideal_bpf: bad args" ); + im_error( "ideal_bpf", "%s", _( "bad args" ) ); return( -1 ); } @@ -230,7 +230,7 @@ ideal_brf( IMAGE *out, double fcx, double fcy, double r ) int y2plus, y2minus; if( xs != ys ) { - im_errormsg( "ideal_brf: bad args" ); + im_error( "ideal_brf", "%s", _( "bad args" ) ); return( -1 ); } if( fabs(fcx) <= 1.0 && fabs(fcy) <= 1.0 && r > 0.0 && r < 1.0 ) { @@ -244,7 +244,7 @@ ideal_brf( IMAGE *out, double fcx, double fcy, double r ) r2 = r*r; } else { - im_errormsg( "ideal_brf: bad args" ); + im_error( "ideal_brf", "%s", _( "bad args" ) ); return( -1 ); } @@ -305,7 +305,7 @@ butterworth_bpf( IMAGE *out, int y2plus, y2minus; if( xs != ys || order < 1.0 ) { - im_errormsg( "butterworth_bpf: bad sizes" ); + im_error( "butterworth_bpf", "%s", _( "bad sizes" ) ); return( -1 ); } if( fabs(fcx) <= 1.0 && fabs(fcy) <= 1.0 && r > 0.0 && r < 1.0 ) { @@ -319,11 +319,11 @@ butterworth_bpf( IMAGE *out, nr2 = r*r; } else { - im_errormsg( "butterworth_bpf: bad args" ); + im_error( "butterworth_bpf", "%s", _( "bad args" ) ); return( -1 ); } if( ac >= 1.0 || ac < 0.0) { - im_errormsg( "butterworth_bpf: bad args" ); + im_error( "butterworth_bpf", "%s", _( "bad args" ) ); return( -1 ); } @@ -396,7 +396,7 @@ butterworth_brf( IMAGE *out, int y2plus, y2minus; if( xs != ys || order < 1.0 ) { - im_errormsg( "butterworth_brf: bad sizes" ); + im_error( "butterworth_brf", "%s", _( "bad sizes" ) ); return( -1 ); } if( fabs(fcx) <= 1.0 && fabs(fcy) <= 1.0 && r > 0.0 && r < 1.0 ) { @@ -410,11 +410,11 @@ butterworth_brf( IMAGE *out, nr2 = r*r; } else { - im_errormsg( "butterworth_brf: bad args" ); + im_error( "butterworth_brf", "%s", _( "bad args" ) ); return( -1 ); } if( ac >= 1.0 || ac < 0.0) { - im_errormsg( "butterworth_brf: bad args" ); + im_error( "butterworth_brf", "%s", _( "bad args" ) ); return( -1 ); } @@ -478,7 +478,7 @@ gaussian_bpf( IMAGE *out, double fcx, double fcy, double r, double ac ) int y2plus, y2minus; if( xs != ys ) { - im_errormsg( "gauss_bpf: bad sizes" ); + im_error( "gauss_bpf", "%s", _( "bad sizes" ) ); return( -1 ); } if( fabs(fcx) <= 1.0 && fabs(fcy) <= 1.0 && r > 0.0 && r < 1.0 ) { @@ -492,11 +492,11 @@ gaussian_bpf( IMAGE *out, double fcx, double fcy, double r, double ac ) nr2 = r*r; } else { - im_errormsg( "gauss_bpf: bad args (f)" ); + im_error( "gauss_bpf", "%s", _( "bad args (f)" ) ); return( -1 ); } if( ac >= 1.0 || ac < 0.0 ) { - im_errormsg( "gauss_bpf: bad args (ac)" ); + im_error( "gauss_bpf", "%s", _( "bad args (ac)" ) ); return( -1 ); } @@ -558,7 +558,7 @@ gaussian_brf( IMAGE *out, double fcx, double fcy, double r, double ac ) int y2plus, y2minus; if( xs != ys ) { - im_errormsg( "gauss_brf: bad sizes" ); + im_error( "gauss_brf", "%s", _( "bad sizes" ) ); return( -1 ); } if( fabs(fcx) <= 1.0 && fabs(fcy) <= 1.0 && r > 0.0 && r < 1.0 ) { @@ -572,11 +572,11 @@ gaussian_brf( IMAGE *out, double fcx, double fcy, double r, double ac ) nr2 = r * r; } else { - im_errormsg( "gauss_brf: bad args" ); + im_error( "gauss_brf", "%s", _( "bad args" ) ); return( -1 ); } if( ac >= 1.0 || ac < 0.0 ) { - im_errormsg( "gauss_brf: bad args" ); + im_error( "gauss_brf", "%s", _( "bad args" ) ); return( -1 ); } @@ -656,7 +656,8 @@ im__fmaskcir( IMAGE *out, MaskType flag, va_list ap ) return( gaussian_brf( out, p0, p1, p2, p3 ) ); default: - im_errormsg( "im__fmaskcir: unimplemented mask" ); + im_error( "im__fmaskcir", "%s", + _( "unimplemented mask" ) ); return( -1 ); } diff --git a/libvips/freq_filt/im_fractsurf.c b/libvips/freq_filt/im_fractsurf.c index fa85bd1d..3fe31a4d 100644 --- a/libvips/freq_filt/im_fractsurf.c +++ b/libvips/freq_filt/im_fractsurf.c @@ -69,7 +69,8 @@ im_fractsurf( IMAGE *out, int size, double frd ) if( !noise ) return( -1 ); if( frd <= 2.0 || frd >= 3.0 ) { - im_errormsg( "im_fractsurf: dimension shuld be in (2,3)" ); + im_error( "im_fractsurf", "%s", + _( "dimension shuld be in (2,3)" ) ); return( -1 ); } diff --git a/libvips/freq_filt/im_freq_mask.c b/libvips/freq_filt/im_freq_mask.c index fe734bb1..fb788fff 100644 --- a/libvips/freq_filt/im_freq_mask.c +++ b/libvips/freq_filt/im_freq_mask.c @@ -143,7 +143,8 @@ build_freq_mask( IMAGE *out, int xs, int ys, MaskType flag, va_list ap ) /* Check sizes and create one quarter of the final mask */ if( !im_ispoweroftwo( xs ) || !im_ispoweroftwo( ys ) ) { - im_errormsg( "im_freq_mask: mask sizes power of 2 only" ); + im_error( "im_freq_mask", "%s", + _( "mask sizes power of 2 only" ) ); return( -1 ); } @@ -190,7 +191,7 @@ build_freq_mask( IMAGE *out, int xs, int ys, MaskType flag, va_list ap ) break; default: - im_errormsg( "im_freq_mask: unimplemented mask type" ); + im_error( "im_freq_mask", "%s", _( "unimplemented mask type" ) ); return( -1 ); } diff --git a/libvips/histograms_lut/im_gammacorrect.c b/libvips/histograms_lut/im_gammacorrect.c index 14e4ad7a..0466f023 100644 --- a/libvips/histograms_lut/im_gammacorrect.c +++ b/libvips/histograms_lut/im_gammacorrect.c @@ -68,7 +68,7 @@ im_gammacorrect( IMAGE *in, IMAGE *out, double exponent ) if( im_piocheck( in, out ) ) return( -1 ); if( in->BandFmt != IM_BANDFMT_UCHAR ) { - im_errormsg( "im_gammacorrect: uchar images only" ); + im_error( "im_gammacorrect", "%s", _( "uchar images only" ) ); return( -1 ); } diff --git a/libvips/histograms_lut/im_histspec.c b/libvips/histograms_lut/im_histspec.c index 55dce220..a15960c8 100644 --- a/libvips/histograms_lut/im_histspec.c +++ b/libvips/histograms_lut/im_histspec.c @@ -89,17 +89,17 @@ match( IMAGE *in, IMAGE *ref, IMAGE *out ) if( im_iocheck( in, out ) || im_iocheck( ref, out ) ) return( -1 ); if( in->Coding != IM_CODING_NONE || ref->Coding != IM_CODING_NONE ) { - im_errormsg( "im_histspec: not uncoded" ); + im_error( "im_histspec", "%s", _( "not uncoded" ) ); return( -1 ); } if( in->BandFmt != IM_BANDFMT_UINT || ref->BandFmt != IM_BANDFMT_UINT ) { - im_errormsg( "im_histspec: bad band format" ); + im_error( "im_histspec", "%s", _( "bad band format" ) ); return( -1 ); } if( in->Bands != ref->Bands ) { - im_errormsg( "im_histspec: input histograms differ in " - "number of bands" ); + im_error( "im_histspec", "%s", + _( "input histograms differ in number of bands" ) ); return( -1 ); } @@ -110,7 +110,7 @@ match( IMAGE *in, IMAGE *ref, IMAGE *out ) else if( inpx <= 65536 && refpx <= 65536 ) px = 65536; else { - im_errormsg( "im_histspec: luts too large" ); + im_error( "im_histspec", "%s", _( "luts too large" ) ); return( -1 ); } max = px * bands; @@ -187,8 +187,8 @@ im_histspec( IMAGE *in, IMAGE *ref, IMAGE *out ) if( !t1 || !t2 || !t2 || !t4 || !t5 ) return( -1 ); if( !im_isuint( in ) || !im_isuint( ref ) ) { - im_errormsg( "im_histspec: input luts are not some unsigned " - "integer type" ); + im_error( "im_histspec", "%s", + _( "input luts are not some unsigned integer type" ) ); return( -1 ); } diff --git a/libvips/histograms_lut/im_identity.c b/libvips/histograms_lut/im_identity.c index 030781df..fba173a4 100644 --- a/libvips/histograms_lut/im_identity.c +++ b/libvips/histograms_lut/im_identity.c @@ -83,7 +83,7 @@ im_identity( IMAGE *lut, int bands ) if( im_outcheck( lut ) ) return( -1 ); if( bands < 0 ) { - im_errormsg( "im_identity: bad bands" ); + im_error( "im_identity", "%s", _( "bad bands" ) ); return( -1 ); } @@ -126,11 +126,11 @@ im_identity_ushort( IMAGE *lut, int bands, int sz ) if( im_outcheck( lut ) ) return( -1 ); if( sz > 65536 || sz < 0 ) { - im_errormsg( "im_identity_ushort: bad size" ); + im_error( "im_identity_ushort", "%s", _( "bad size" ) ); return( -1 ); } if( bands < 0 ) { - im_errormsg( "im_identity_ushort: bad bands" ); + im_error( "im_identity_ushort", "%s", _( "bad bands" ) ); return( -1 ); } diff --git a/libvips/histograms_lut/im_invertlut.c b/libvips/histograms_lut/im_invertlut.c index 26d6ffb6..954a903d 100644 --- a/libvips/histograms_lut/im_invertlut.c +++ b/libvips/histograms_lut/im_invertlut.c @@ -142,8 +142,8 @@ build_state( State *state, DOUBLEMASK *input, IMAGE *output, int lut_size ) for( x = 0; x < input->xsize; x++ ) if( state->data[y][x] > 1.0 || state->data[y][x] < 0.0 ) { - im_errormsg( "im_invertlut: element out of " - "range [0,1]" ); + im_error( "im_invertlut", "%s", + _( "element out of range [0,1]" ) ); return( -1 ); } @@ -242,11 +242,11 @@ im_invertlut( DOUBLEMASK *input, IMAGE *output, int lut_size ) State state; if( !input || input->xsize < 2 || input->ysize < 1 ) { - im_errormsg( "im_invertlut: bad input matrix" ); + im_error( "im_invertlut", "%s", _( "bad input matrix" ) ); return( -1 ); } if( lut_size < 1 || lut_size > 65536 ) { - im_errormsg( "im_invertlut: bad lut_size" ); + im_error( "im_invertlut", "%s", _( "bad lut_size" ) ); return( -1 ); } diff --git a/libvips/histograms_lut/im_stdif.c b/libvips/histograms_lut/im_stdif.c index f15e41f9..c3821e66 100644 --- a/libvips/histograms_lut/im_stdif.c +++ b/libvips/histograms_lut/im_stdif.c @@ -197,18 +197,19 @@ im_stdif_raw( IMAGE *in, IMAGE *out, if( m0 < 0 || m0 > 255 || a < 0 || a > 1.0 || b < 0 || b > 2 || s0 < 0 || s0 > 255 ) { - im_errormsg( "im_stdif: parameters out of range" ); + im_error( "im_stdif", "%s", _( "parameters out of range" ) ); return( -1 ); } if( im_piocheck( in, out ) ) return( -1 ); if( in->Bbits != IM_BBITS_BYTE || in->BandFmt != IM_BANDFMT_UCHAR || in->Bands != 1 || in->Coding != IM_CODING_NONE ) { - im_errormsg( "im_stdif: one band uchar uncoded only" ); + im_error( "im_stdif", "%s", + _( "one band uchar uncoded only" ) ); return( -1 ); } if( xwin > in->Xsize || ywin > in->Ysize ) { - im_errormsg( "im_stdif: window too large" ); + im_error( "im_stdif", "%s", _( "window too large" ) ); return( -1 ); } if( im_cp_desc( out, in ) ) diff --git a/libvips/histograms_lut/tone.c b/libvips/histograms_lut/tone.c index 0466a5dc..b445324a 100644 --- a/libvips/histograms_lut/tone.c +++ b/libvips/histograms_lut/tone.c @@ -533,7 +533,7 @@ im_tone_analyse( } Lw = i / 10.24; - im_diagnostics( "im_tone_analyse: set Lb = %g, Lw = %g", Lb, Lw ); + im_diag( "im_tone_analyse", "set Lb = %g, Lw = %g", Lb, Lw ); return( im_tone_build( lut, Lb, Lw, Ps, Pm, Ph, S, M, H ) ); } diff --git a/libvips/include/vips/Makefile.am b/libvips/include/vips/Makefile.am index 65f53301..35da35d1 100644 --- a/libvips/include/vips/Makefile.am +++ b/libvips/include/vips/Makefile.am @@ -1,6 +1,7 @@ pkginclude_HEADERS = \ arithmetic.h \ colour.h \ + boolean.h \ debug.h \ dispatch.h \ format.h \ diff --git a/libvips/include/vips/arithmetic.h b/libvips/include/vips/arithmetic.h index 0119a73f..fbfbdc06 100644 --- a/libvips/include/vips/arithmetic.h +++ b/libvips/include/vips/arithmetic.h @@ -72,8 +72,8 @@ int im_expntra_vec( IMAGE *in, IMAGE *out, int n, double *e ); int im_logtra( IMAGE *in, IMAGE *out ); int im_log10tra( IMAGE *in, IMAGE *out ); int im_remainder( IMAGE *in1, IMAGE *in2, IMAGE *out ); +int im_remainder_vec( IMAGE *in, IMAGE *out, int n, double *c ); int im_remainderconst( IMAGE *in, IMAGE *out, double c ); -int im_remainderconst_vec( IMAGE *in, IMAGE *out, int n, double *c ); int im_floor( IMAGE *in, IMAGE *out ); int im_rint( IMAGE *in, IMAGE *out ); int im_ceil( IMAGE *in, IMAGE *out ); diff --git a/libvips/include/vips/boolean.h b/libvips/include/vips/boolean.h new file mode 100644 index 00000000..66838c33 --- /dev/null +++ b/libvips/include/vips/boolean.h @@ -0,0 +1,58 @@ +/* boolean.h + * + * 20/9/09 + * - from proto.h + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifndef IM_BOOLEAN_H +#define IM_BOOLEAN_H + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus*/ + +int im_andimage( IMAGE *, IMAGE *, IMAGE * ); +int im_andimage_vec( IMAGE *, IMAGE *, int, double * ); +int im_andimageconst( IMAGE *, IMAGE *, double ); +int im_orimage( IMAGE *, IMAGE *, IMAGE * ); +int im_orimage_vec( IMAGE *, IMAGE *, int, double * ); +int im_orimageconst( IMAGE *, IMAGE *, double ); +int im_eorimage( IMAGE *, IMAGE *, IMAGE * ); +int im_eorimage_vec( IMAGE *, IMAGE *, int, double * ); +int im_eorimageconst( IMAGE *, IMAGE *, double ); +int im_shiftleft_vec( IMAGE *in, IMAGE *out, int n, double *c ); +int im_shiftleft( IMAGE *, IMAGE *, int ); +int im_shiftright_vec( IMAGE *in, IMAGE *out, int n, double *c ); +int im_shiftright( IMAGE *, IMAGE *, int ); + +#ifdef __cplusplus +} +#endif /*__cplusplus*/ + +#endif /*IM_BOOLEAN_H*/ diff --git a/libvips/include/vips/deprecated.h b/libvips/include/vips/deprecated.h index 1e43c71c..dbcd6528 100644 --- a/libvips/include/vips/deprecated.h +++ b/libvips/include/vips/deprecated.h @@ -286,6 +286,33 @@ int im_fav4( IMAGE **, IMAGE * ); int im_gadd( double, IMAGE *, double, IMAGE *, double, IMAGE *); int im_litecor( IMAGE *, IMAGE *, IMAGE *, int, double ); +/* Renamed operations. + */ + +/* arithmetic + */ +int im_remainderconst_vec( IMAGE *in, IMAGE *out, int n, double *c ); + +/* boolean + */ +int im_andconst( IMAGE *, IMAGE *, double ); +int im_and_vec( IMAGE *, IMAGE *, int, double * ); +int im_orconst( IMAGE *, IMAGE *, double ); +int im_or_vec( IMAGE *, IMAGE *, int, double * ); +int im_eorconst( IMAGE *, IMAGE *, double ); +int im_eor_vec( IMAGE *, IMAGE *, int, double * ); + +/* mosaicing + */ +int im_affine( IMAGE *in, IMAGE *out, + double a, double b, double c, double d, double dx, double dy, + int ox, int oy, int ow, int oh ); +int im_similarity( IMAGE *in, IMAGE *out, + double a, double b, double dx, double dy ); +int im_similarity_area( IMAGE *in, IMAGE *out, + double a, double b, double dx, double dy, + int ox, int oy, int ow, int oh ); + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/include/vips/proto.h b/libvips/include/vips/proto.h index 96447f01..b4349854 100644 --- a/libvips/include/vips/proto.h +++ b/libvips/include/vips/proto.h @@ -73,7 +73,6 @@ GOptionGroup *im_get_option_group( void ); */ void im_progress_set( int progress ); -const char *im_error_buffer( void ); int im_debugim( IMAGE * ); int im_printlines( IMAGE * ); @@ -163,14 +162,19 @@ int im_add_invalidate_callback( IMAGE *, im_callback_fn, void *, void * ); void error_exit( const char *, ... ) __attribute__((noreturn, format(printf, 1, 2))); +const char *im_error_buffer( void ); void im_error_clear( void ); void im_verror( const char *domain, const char *fmt, va_list ap ); void im_error( const char *domain, const char *fmt, ... ) __attribute__((format(printf, 2, 3))); +void im_verror_system( int err, const char *domain, + const char *fmt, va_list ap ); void im_error_system( int err, const char *domain, const char *fmt, ... ) __attribute__((format(printf, 3, 4))); +void im_vdiag( const char *domain, const char *fmt, va_list ap ); void im_warn( const char *domain, const char *fmt, ... ) __attribute__((format(printf, 2, 3))); +void im_vwarn( const char *domain, const char *fmt, va_list ap ); void im_diag( const char *domain, const char *fmt, ... ) __attribute__((format(printf, 2, 3))); @@ -302,20 +306,6 @@ int im_fwfft( IMAGE *, IMAGE * ); int im_invfft( IMAGE *, IMAGE * ); int im_invfftr( IMAGE *, IMAGE * ); -/* boolean - */ -int im_andimage( IMAGE *, IMAGE *, IMAGE * ); -int im_andconst( IMAGE *, IMAGE *, double ); -int im_and_vec( IMAGE *, IMAGE *, int, double * ); -int im_orimage( IMAGE *, IMAGE *, IMAGE * ); -int im_orconst( IMAGE *, IMAGE *, double ); -int im_or_vec( IMAGE *, IMAGE *, int, double * ); -int im_eorimage( IMAGE *, IMAGE *, IMAGE * ); -int im_eorconst( IMAGE *, IMAGE *, double ); -int im_eor_vec( IMAGE *, IMAGE *, int, double * ); -int im_shiftleft( IMAGE *, IMAGE *, int ); -int im_shiftright( IMAGE *, IMAGE *, int ); - /* cimg */ int im_greyc_mask( IMAGE *in, IMAGE *out, IMAGE *mask, @@ -611,17 +601,6 @@ int im_correl( IMAGE *ref, IMAGE *sec, int im_remosaic( IMAGE *in, IMAGE *out, const char *old_str, const char *new_str ); -/* Old stuff, for compat. - */ -int im_affine( IMAGE *in, IMAGE *out, - double a, double b, double c, double d, double dx, double dy, - int ox, int oy, int ow, int oh ); -int im_similarity( IMAGE *in, IMAGE *out, - double a, double b, double dx, double dy ); -int im_similarity_area( IMAGE *in, IMAGE *out, - double a, double b, double dx, double dy, - int ox, int oy, int ow, int oh ); - int im_align_bands( IMAGE *in, IMAGE *out ); int im_maxpos_subpel( IMAGE *in, double *x, double *y ); @@ -700,23 +679,6 @@ int im_video_v4l1( IMAGE *im, const char *device, int ngrabs ); int im_video_test( IMAGE *im, int brightness, int error ); -/* Backwards compatibility macros. - */ -#define im_clear_error_string() im_error_clear() -#define im_errorstring() im_error_buffer() - -/* Deprecated API. - */ -void im_errormsg( const char *fmt, ... ) - __attribute__((format(printf, 1, 2))); -void im_verrormsg( const char *fmt, va_list ap ); -void im_errormsg_system( int err, const char *fmt, ... ) - __attribute__((format(printf, 2, 3))); -void im_diagnostics( const char *fmt, ... ) - __attribute__((format(printf, 1, 2))); -void im_warning( const char *fmt, ... ) - __attribute__((format(printf, 1, 2))); - #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/include/vips/vips.h b/libvips/include/vips/vips.h index c6379558..c834e202 100644 --- a/libvips/include/vips/vips.h +++ b/libvips/include/vips/vips.h @@ -137,6 +137,7 @@ typedef struct im__DOUBLEMASK { #include #include +#include #ifdef IM_ENABLE_DEPRECATED #include diff --git a/libvips/inplace/im_circle.c b/libvips/inplace/im_circle.c index 5dc92536..eab4f5ce 100644 --- a/libvips/inplace/im_circle.c +++ b/libvips/inplace/im_circle.c @@ -75,19 +75,19 @@ im_circle( IMAGE *im, int cx, int cy, int radius, int intensity) if ( (im->data == NULL)||(im->BandFmt != IM_BANDFMT_UCHAR)||(im->Bands != 1) ||(im->Bbits != IM_BBITS_BYTE) ) { - im_errormsg("im_circle: unable to write input image"); + im_error("im_circle: ", "%s", _( "able to write input image") ); return(-1); } if ((intensity > 255)||(intensity <= 0)) { - im_errormsg("im_circle: intensity between 0 and 255"); + im_error( "im_circle", "%s", _( "intensity between 0 and 255") ); return(-1); } /* Check if circle fits into image */ if ( ((radius+cy)> im->Ysize - 1) || ((cy-radius)< 0 ) || ((radius+cx)> im->Xsize - 1) || ((cx-radius) < 0 ) ) { - im_errormsg("im_circle: The circle doesnot fit in image"); + im_error( "im_circle", "%s", _( "The circle doesnot fit in image") ); return(-1); } /* Draw the circle */ diff --git a/libvips/inplace/im_line.c b/libvips/inplace/im_line.c index 925846ca..b043176b 100644 --- a/libvips/inplace/im_line.c +++ b/libvips/inplace/im_line.c @@ -69,13 +69,16 @@ double signx, signy; return( -1 ); /* check coordinates */ if ( (x1 > image->Xsize)||(x1<0)||(y1 > image->Ysize)||(y1<0) - ||(x2 > image->Xsize)||(x2<0)||(y2 > image->Ysize)||(y2<0) ) - { im_errormsg("im_line: invalid line cooordinates"); return(-1); } -if ((pelval > 255)||(pelval < 0)) - {im_errormsg("im_line: line intensity between 0 and 255"); return(-1); } + ||(x2 > image->Xsize)||(x2<0)||(y2 > image->Ysize)||(y2<0) ) { + im_error( "im_line", "%s", _( "invalid line cooordinates") ); + return(-1); } +if ((pelval > 255)||(pelval < 0)) { + im_error( "im_line", "%s", _( "line intensity between 0 and 255") ); + return(-1); } -if (image->Bands != 1) - { im_errormsg("im_line: image should have one band only");return(-1); } +if (image->Bands != 1) { + im_error( "im_line", "%s", _( "image should have one band only") ); + return(-1); } dx = (double)(x2 - x1); dy = (double)(y2 - y1); diff --git a/libvips/inplace/line_draw.c b/libvips/inplace/line_draw.c index a3f4fc38..14148897 100644 --- a/libvips/inplace/line_draw.c +++ b/libvips/inplace/line_draw.c @@ -107,7 +107,8 @@ im_fastline( IMAGE *im, int x1, int y1, int x2, int y2, PEL *pel ) y1 > im->Ysize || y1 < 0 || x2 > im->Xsize || x2 < 0 || y2 > im->Ysize || y2 < 0 ) { - im_errormsg( "im_fastline: invalid line cooordinates" ); + im_error( "im_fastline", "%s", + _( "invalid line cooordinates" ) ); return( -1 ); } @@ -426,7 +427,7 @@ im_lineset( IMAGE *in, IMAGE *out, IMAGE *mask, IMAGE *ink, return( -1 ); } - /* Copy the image thenm fastline to it ... this will render to a "t" + /* Copy the image then fastline to it ... this will render to a "t" * usually. */ if( im_incheck( mask ) || diff --git a/libvips/inplace/plot_point.c b/libvips/inplace/plot_point.c index 379f3157..452d4694 100644 --- a/libvips/inplace/plot_point.c +++ b/libvips/inplace/plot_point.c @@ -75,7 +75,7 @@ im_readpoint( IMAGE *im, int x, int y, PEL *pel ) /* Check coordinates in range. */ if( x > im->Xsize || x < 0 || y > im->Ysize || y < 0 ) { - im_errormsg( "im_readpoint: invalid cooordinates" ); + im_error( "im_readpoint", "%s", _( "invalid cooordinates" ) ); return( 1 ); } diff --git a/libvips/iofuncs/error.c b/libvips/iofuncs/error.c index 53a8e76d..ac472daa 100644 --- a/libvips/iofuncs/error.c +++ b/libvips/iofuncs/error.c @@ -1,10 +1,5 @@ -/* @(#) error handling - * @(#) - * @(#) Usage: - * @(#) void im_errormsg(variable_list) - * @(#) (variable_list) is (format, arg1, arg2, ...) - * @(#) format, arg1, arg2, etc are the same as in fprintf - * @(#) +/* error.c --- error message handling + * * Copyright: N. Dessipris * Written on: 18/03/1991 * Updated on: 9/7/92 KM @@ -202,52 +197,3 @@ im_warn( const char *domain, const char *fmt, ... ) im_vwarn( domain, fmt, ap ); va_end( ap ); } - -/* Compatibility with pre-7.10 ... can't portably do these as macros sadly. - */ - -void -im_errormsg( const char *fmt, ... ) -{ - va_list ap; - - va_start( ap, fmt ); - im_verror( "untranslated", fmt, ap ); - va_end( ap ); -} - -void -im_verrormsg( const char *fmt, va_list ap ) -{ - im_verror( "untranslated", fmt, ap ); -} - -void -im_errormsg_system( int err, const char *fmt, ... ) -{ - va_list ap; - - va_start( ap, fmt ); - im_verror_system( err, "untranslated", fmt, ap ); - va_end( ap ); -} - -void -im_diagnostics( const char *fmt, ... ) -{ - va_list ap; - - va_start( ap, fmt ); - im_vdiag( "untranslated", fmt, ap ); - va_end( ap ); -} - -void -im_warning( const char *fmt, ... ) -{ - va_list ap; - - va_start( ap, fmt ); - im_vwarn( "untranslated", fmt, ap ); - va_end( ap ); -} diff --git a/libvips/iofuncs/im_debugim.c b/libvips/iofuncs/im_debugim.c index 59d1c6b3..c8d27547 100644 --- a/libvips/iofuncs/im_debugim.c +++ b/libvips/iofuncs/im_debugim.c @@ -68,7 +68,7 @@ im_debugim( IMAGE *in ) if( im_incheck( in ) ) return( -1 ); if( in->Coding != IM_CODING_NONE ) { - im_errormsg( "im_debugim: input must be uncoded" ); + im_error( "im_debugim", "%s", _( "input must be uncoded" ) ); return( -1 ); } @@ -130,7 +130,7 @@ im_debugim( IMAGE *in ) case IM_BANDFMT_DPCOMPLEX: loopcmplx(double); break; default: - im_errormsg("im_debugim: unknown input format"); + im_error( "im_debugim", "%s", _( "unknown input format") ); return( -1 ); } diff --git a/libvips/iofuncs/im_image.c b/libvips/iofuncs/im_image.c index d44adf3d..f695f6d9 100644 --- a/libvips/iofuncs/im_image.c +++ b/libvips/iofuncs/im_image.c @@ -60,7 +60,7 @@ im_image( void *buffer, int width, int height, int bands, int format ) if( width <= 0 || height <= 0 || bands <= 0 || format < 0 || format > IM_BANDFMT_DPCOMPLEX ) { - im_errormsg( "im_image: bad parameters" ); + im_error( "im_image", "%s", _( "bad parameters" ) ); return( NULL ); } diff --git a/libvips/iofuncs/im_init_world.c b/libvips/iofuncs/im_init_world.c index 5410cd2b..c7953e83 100644 --- a/libvips/iofuncs/im_init_world.c +++ b/libvips/iofuncs/im_init_world.c @@ -143,7 +143,7 @@ im_init_world( const char *argv0 ) */ if( im_load_plugins( "%s/vips-%d.%d", libdir, IM_MAJOR_VERSION, IM_MINOR_VERSION ) ) { - im_warn( "im_init_world", "%s", im_errorstring() ); + im_warn( "im_init_world", "%s", im_error_buffer() ); im_error_clear(); } @@ -151,7 +151,7 @@ im_init_world( const char *argv0 ) * :-( kept for back compat convenience. */ if( im_load_plugins( "%s", libdir ) ) { - im_warn( "im_init_world", "%s", im_errorstring() ); + im_warn( "im_init_world", "%s", im_error_buffer() ); im_error_clear(); } diff --git a/libvips/iofuncs/im_makerw.c b/libvips/iofuncs/im_makerw.c index 49342e70..f4bb86e7 100644 --- a/libvips/iofuncs/im_makerw.c +++ b/libvips/iofuncs/im_makerw.c @@ -62,7 +62,7 @@ im_makerw( IMAGE *im ) /* This will rewind im_openout() files, and generate im_partial() files. */ if( im_incheck( im ) ) { - im_errormsg( "im_makerw: unable to rewind file" ); + im_error( "im_makerw", "%s", _( "unable to rewind file" ) ); return( -1 ); } @@ -78,7 +78,7 @@ im_makerw( IMAGE *im ) break; default: - im_errormsg( "im_makerw: bad file type" ); + im_error( "im_makerw", "%s", _( "bad file type" ) ); return( -1 ); } diff --git a/libvips/iofuncs/im_piocheck.c b/libvips/iofuncs/im_piocheck.c index 5e4b63ea..412fe74f 100644 --- a/libvips/iofuncs/im_piocheck.c +++ b/libvips/iofuncs/im_piocheck.c @@ -89,7 +89,7 @@ im_pincheck( IMAGE *im ) /* Should have been written to. */ if( !im->data ) { - im_errormsg( "im_pincheck: no image data" ); + im_error( "im_pincheck", "%s", _( "no image data" ) ); return( -1 ); } @@ -105,7 +105,7 @@ im_pincheck( IMAGE *im ) /* Should have had generate functions attached. */ if( !im->generate ) { - im_errormsg( "im_pincheck: no image data" ); + im_error( "im_pincheck", "%s", _( "no image data" ) ); return( -1 ); } @@ -123,7 +123,8 @@ im_pincheck( IMAGE *im ) printf( "im_pincheck: auto-rewind of %s\n", im->filename ); #endif/*DEBUG_IO*/ if( im__close( im ) || im_openin( im ) ) { - im_errormsg( "im_pincheck: auto-rewind for %s failed", + im_error( "im_pincheck", + _( "auto-rewind for %s failed" ), im->filename ); return( -1 ); } @@ -131,7 +132,7 @@ im_pincheck( IMAGE *im ) break; default: - im_errormsg( "im_pincheck: image not readable" ); + im_error( "im_pincheck", "%s", _( "image not readable" ) ); return( -1 ); } @@ -144,7 +145,7 @@ int im_poutcheck( IMAGE *im ) { if( !im ) { - im_errormsg( "im_poutcheck: null image descriptor" ); + im_error( "im_poutcheck", "%s", _( "null image descriptor" ) ); return( -1 ); } @@ -157,7 +158,8 @@ im_poutcheck( IMAGE *im ) /* Check that it has not been im_setupout(). */ if( im->data ) { - im_errormsg( "im_poutcheck: image already written" ); + im_error( "im_poutcheck", "%s", + _( "image already written" ) ); return( -1 ); } @@ -167,7 +169,8 @@ im_poutcheck( IMAGE *im ) /* Make sure nothing is attached. */ if( im->generate ) { - im_errormsg( "im_poutcheck: image already written" ); + im_error( "im_poutcheck", "%s", + _( "image already written" ) ); return( -1 ); } @@ -180,7 +183,7 @@ im_poutcheck( IMAGE *im ) break; default: - im_errormsg( "im_poutcheck: image not writeable" ); + im_error( "im_poutcheck", "%s", _( "image not writeable" ) ); return( -1 ); } diff --git a/libvips/iofuncs/im_printlines.c b/libvips/iofuncs/im_printlines.c index 4f2c5caf..aade7540 100644 --- a/libvips/iofuncs/im_printlines.c +++ b/libvips/iofuncs/im_printlines.c @@ -78,11 +78,11 @@ im_printlines( IMAGE *in ) if( im_incheck( in ) ) return( -1 ); if( in->Coding != IM_CODING_NONE ) { - im_errormsg( "im_printlines: input must be uncoded" ); + im_error( "im_printlines", "%s", _( "input must be uncoded" ) ); return( -1 ); } if( !in->data ) { - im_errormsg( "im_debugim: unsuitable image type" ); + im_error( "im_debugim", "%s", _( "unsuitable image type" ) ); return( -1 ); } @@ -140,7 +140,8 @@ im_printlines( IMAGE *in ) switch( in->BandFmt ) { im_for_all_types(); default: { - im_errormsg( "im_printlines: unknown input format" ); + im_error( "im_printlines", "%s", + _( "unknown input format" ) ); return( -1 ); } } diff --git a/libvips/iofuncs/util.c b/libvips/iofuncs/util.c index fad79985..28c3c80a 100644 --- a/libvips/iofuncs/util.c +++ b/libvips/iofuncs/util.c @@ -740,7 +740,7 @@ im_local( IMAGE *im, void *obj; if( !im ) { - im_errormsg( "im_local: NULL image descriptor" ); + im_error( "im_local", "%s", _( "NULL image descriptor" ) ); return( NULL ); } diff --git a/libvips/matrix/im_matcat.c b/libvips/matrix/im_matcat.c index 78e837dd..ea335824 100644 --- a/libvips/matrix/im_matcat.c +++ b/libvips/matrix/im_matcat.c @@ -62,7 +62,7 @@ im_matcat( DOUBLEMASK *in1, DOUBLEMASK *in2, const char *name ) /* matrices must be same width */ if( in1->xsize != in2->xsize ) { - im_errormsg( "im_matcat: matrices must be same width" ); + im_error( "im_matcat", "%s", _( "matrices must be same width" ) ); return( NULL ); } @@ -72,7 +72,7 @@ im_matcat( DOUBLEMASK *in1, DOUBLEMASK *in2, const char *name ) /* Allocate output matrix. */ if( !(mat = im_create_dmask( name, newxsize, newysize )) ) { - im_errormsg( "im_matcat: unable to allocate output matrix" ); + im_error( "im_matcat", "%s", _( "unable to allocate output matrix" ) ); return( NULL ); } diff --git a/libvips/matrix/im_matmul.c b/libvips/matrix/im_matmul.c index 98c9eb59..4de9195f 100644 --- a/libvips/matrix/im_matmul.c +++ b/libvips/matrix/im_matmul.c @@ -65,14 +65,14 @@ im_matmul( DOUBLEMASK *in1, DOUBLEMASK *in2, const char *name ) /* Check matrix sizes. */ if( in1->xsize != in2->ysize ) { - im_errormsg( "im_matmul: bad sizes" ); + im_error( "im_matmul", "%s", _( "bad sizes" ) ); return( NULL ); } /* Allocate output matrix. */ if( !(mat = im_create_dmask( name, in2->xsize, in1->ysize )) ) { - im_errormsg( "im_matmul: unable to allocate output mask" ); + im_error( "im_matmul", "%s", _( "unable to allocate output mask" ) ); return( NULL ); } diff --git a/libvips/matrix/im_mattrn.c b/libvips/matrix/im_mattrn.c index fd6549c2..82fbd862 100644 --- a/libvips/matrix/im_mattrn.c +++ b/libvips/matrix/im_mattrn.c @@ -63,7 +63,7 @@ im_mattrn( DOUBLEMASK *in, const char *name ) /* Allocate output matrix. */ if( !(mat = im_create_dmask( name, in->ysize, in->xsize )) ) { - im_errormsg( "im_mattrn: unable to allocate output matrix" ); + im_error( "im_mattrn", "%s", _( "unable to allocate output matrix" ) ); return( NULL ); } diff --git a/libvips/morphology/im_cntlines.c b/libvips/morphology/im_cntlines.c index f02b3355..143f923c 100644 --- a/libvips/morphology/im_cntlines.c +++ b/libvips/morphology/im_cntlines.c @@ -74,12 +74,14 @@ im_cntlines( IMAGE *im, double *nolines, int flag ) return( -1 ); if( im->Coding != IM_CODING_NONE || im->BandFmt != IM_BANDFMT_UCHAR || im->Bands != 1 ) { - im_errormsg( "im_cntlines: 1-band uchar uncoded only" ); + im_error( "im_cntlines", "%s", + _( "1-band uchar uncoded only" ) ); return( -1 ); } if( flag != 0 && flag != 1 ) { - im_errormsg( "im_cntlines: flag should be 0 (horizontal) " - "or 1 (vertical)" ); + im_error( "im_cntlines", "%s", + _( "flag should be 0 (horizontal) )" + "or 1 (vertical)" ) ); return( -1 ); } diff --git a/libvips/morphology/im_profile.c b/libvips/morphology/im_profile.c index 6d7dd700..0aa61898 100644 --- a/libvips/morphology/im_profile.c +++ b/libvips/morphology/im_profile.c @@ -67,11 +67,12 @@ im_profile( IMAGE *in, IMAGE *out, int dir ) return( -1 ); if( in->Coding != IM_CODING_NONE || in->BandFmt != IM_BANDFMT_UCHAR || in->Bands != 1 ) { - im_errormsg( "im_profile: 1-band uchar uncoded only" ); + im_error( "im_profile", "%s", + _( "1-band uchar uncoded only" ) ); return( -1 ); } if( dir != 0 && dir != 1 ) { - im_errormsg( "im_profile: dir not 0 or 1" ); + im_error( "im_profile", "%s", _( "dir not 0 or 1" ) ); return( -1 ); } diff --git a/libvips/mosaicing/im_avgdxdy.c b/libvips/mosaicing/im_avgdxdy.c index e152d553..838f5c31 100644 --- a/libvips/mosaicing/im_avgdxdy.c +++ b/libvips/mosaicing/im_avgdxdy.c @@ -65,7 +65,7 @@ im__avgdxdy( TIE_POINTS *points, int *dx, int *dy ) int i; if( points->nopoints == 0 ) { - im_errormsg( "im_avgdxdy: no points to average" ); + im_error( "im_avgdxdy", "%s", _( "no points to average" ) ); return( -1 ); } diff --git a/libvips/mosaicing/im_chkpair.c b/libvips/mosaicing/im_chkpair.c index 13547a87..2630ce44 100644 --- a/libvips/mosaicing/im_chkpair.c +++ b/libvips/mosaicing/im_chkpair.c @@ -205,11 +205,11 @@ im__chkpair( IMAGE *ref, IMAGE *sec, TIE_POINTS *points ) return( -1 ); if( ref->Bands != sec->Bands || ref->BandFmt != sec->BandFmt || ref->Coding != sec->Coding ) { - im_errormsg( "im_chkpair: inputs incompatible"); + im_error( "im_chkpair", "%s", _( "inputs incompatible" ) ); return( -1 ); } if( ref->Bands != 1 || ref->BandFmt != IM_BANDFMT_UCHAR ) { - im_errormsg( "im_chkpair: help!" ); + im_error( "im_chkpair", "%s", _( "help!" ) ); return( -1 ); } diff --git a/libvips/mosaicing/im_clinear.c b/libvips/mosaicing/im_clinear.c index 0f180da7..3fa3ac79 100644 --- a/libvips/mosaicing/im_clinear.c +++ b/libvips/mosaicing/im_clinear.c @@ -142,7 +142,7 @@ im__clinear( TIE_POINTS *points ) if( im_invmat( mat, 4 ) ) { im_free_dmat( mat, 0, 3, 0, 3 ); im_free_dvector( g, 0, 3 ); - im_errormsg( "im_clinear: im_invmat failed" ); + im_error( "im_clinear", "%s", _( "im_invmat failed" ) ); return( -1 ); } diff --git a/libvips/mosaicing/im_lrcalcon.c b/libvips/mosaicing/im_lrcalcon.c index 368e0aeb..298da344 100644 --- a/libvips/mosaicing/im_lrcalcon.c +++ b/libvips/mosaicing/im_lrcalcon.c @@ -203,8 +203,8 @@ im__find_best_contrast( IMAGE *im, int x, y, i; if( nacross <= 0 || ndown <= 0 ) { - im_errormsg( "im__lrcalcon: mosaicing overlap too small for " - "your search size" ); + im_error( "im__lrcalcon", "%s", + _( "overlap too small for your search size" ) ); return( -1 ); } @@ -242,7 +242,8 @@ im__find_best_contrast( IMAGE *im, /* Found enough tie-points? */ if( elms < nbest ) { - im_errormsg( "im_mosaic: found %d tie-points, need at least %d", + im_error( "im_mosaic", + _( "found %d tie-points, need at least %d" ), elms, nbest ); im_free( pc ); return( -1 ); @@ -287,7 +288,7 @@ im__lrcalcon( IMAGE *ref, TIE_POINTS *points ) if( im_incheck( ref ) ) return( -1 ); if( ref->Bands != 1 || ref->BandFmt != IM_BANDFMT_UCHAR ) { - im_errormsg( "im__lrcalcon: not 1-band uchar image" ); + im_error( "im__lrcalcon", "%s", _( "not 1-band uchar image" ) ); return( -1 ); } diff --git a/libvips/mosaicing/im_lrmosaic.c b/libvips/mosaicing/im_lrmosaic.c index 59cdde03..e6292549 100644 --- a/libvips/mosaicing/im_lrmosaic.c +++ b/libvips/mosaicing/im_lrmosaic.c @@ -122,7 +122,7 @@ im__find_lroverlap( IMAGE *ref_in, IMAGE *sec_in, IMAGE *out, if( ref_in->Bands != sec_in->Bands || ref_in->BandFmt != sec_in->BandFmt || ref_in->Coding != sec_in->Coding ) { - im_errormsg( "im_lrmosaic: input images incompatible" ); + im_error( "im_lrmosaic", "%s", _( "input images incompatible" ) ); return( -1 ); } @@ -130,7 +130,7 @@ im__find_lroverlap( IMAGE *ref_in, IMAGE *sec_in, IMAGE *out, */ if( halfcorrelation < 0 || halfarea < 0 || halfarea < halfcorrelation ) { - im_errormsg( "im_lrmosaic: bad area parameters" ); + im_error( "im_lrmosaic", "%s", _( "bad area parameters" ) ); return( -1 ); } @@ -150,7 +150,7 @@ im__find_lroverlap( IMAGE *ref_in, IMAGE *sec_in, IMAGE *out, im_rect_intersectrect( &left, &right, &overlap ); if( overlap.width < 2*halfarea + 1 || overlap.height < 2*halfarea + 1 ) { - im_errormsg( "im_lrmosaic: overlap too small for search" ); + im_error( "im_lrmosaic", "%s", _( "overlap too small for search" ) ); return( -1 ); } @@ -213,7 +213,7 @@ im__find_lroverlap( IMAGE *ref_in, IMAGE *sec_in, IMAGE *out, return( -1 ); } else { - im_errormsg( "im_lrmosaic: unknown Coding type" ); + im_error( "im_lrmosaic", "%s", _( "unknown Coding type" ) ); return( -1 ); } @@ -327,7 +327,7 @@ im__balance( IMAGE *ref, IMAGE *sec, IMAGE *out, /* Test balancetype. */ if( balancetype < 0 || balancetype > 3 ) { - im_errormsg( "im_mosaic: bad balancetype parameter" ); + im_error( "im_mosaic", "%s", _( "bad balancetype parameter" ) ); return( -1 ); } @@ -344,7 +344,7 @@ im__balance( IMAGE *ref, IMAGE *sec, IMAGE *out, */ if( ref->Coding != IM_CODING_NONE || ref->BandFmt != IM_BANDFMT_UCHAR ) { - im_errormsg( "im_mosaic: uncoded uchar only for balancing" ); + im_error( "im_mosaic", "%s", _( "uncoded uchar only for balancing" ) ); return( -1 ); } diff --git a/libvips/mosaicing/im_tbcalcon.c b/libvips/mosaicing/im_tbcalcon.c index b444fa43..33d56f83 100644 --- a/libvips/mosaicing/im_tbcalcon.c +++ b/libvips/mosaicing/im_tbcalcon.c @@ -103,7 +103,7 @@ im__tbcalcon( IMAGE *ref, TIE_POINTS *points ) if( im_incheck( ref ) ) return( -1 ); if( ref->Bands != 1 || ref->BandFmt != IM_BANDFMT_UCHAR ) { - im_errormsg( "im__tbcalcon: help!" ); + im_error( "im__tbcalcon", "%s", _( "help!" ) ); return( -1 ); } @@ -117,7 +117,7 @@ im__tbcalcon( IMAGE *ref, TIE_POINTS *points ) area.width--; area.height--; if( area.width < 0 || area.height < 0 ) { - im_errormsg( "im__tbcalcon: overlap too small" ); + im_error( "im__tbcalcon", "%s", _( "overlap too small" ) ); return( -1 ); } diff --git a/libvips/mosaicing/im_tbmosaic.c b/libvips/mosaicing/im_tbmosaic.c index 75a423d6..d36bd842 100644 --- a/libvips/mosaicing/im_tbmosaic.c +++ b/libvips/mosaicing/im_tbmosaic.c @@ -99,7 +99,7 @@ im__find_tboverlap( IMAGE *ref_in, IMAGE *sec_in, IMAGE *out, if( ref_in->Bands != sec_in->Bands || ref_in->BandFmt != sec_in->BandFmt || ref_in->Coding != sec_in->Coding ) { - im_errormsg( "im_tbmosaic: input images incompatible" ); + im_error( "im_tbmosaic", "%s", _( "input images incompatible" ) ); return( -1 ); } @@ -107,7 +107,7 @@ im__find_tboverlap( IMAGE *ref_in, IMAGE *sec_in, IMAGE *out, */ if( halfcorrelation < 0 || halfarea < 0 || halfarea < halfcorrelation ) { - im_errormsg( "im_tbmosaic: bad area parameters" ); + im_error( "im_tbmosaic", "%s", _( "bad area parameters" ) ); return( -1 ); } @@ -127,7 +127,7 @@ im__find_tboverlap( IMAGE *ref_in, IMAGE *sec_in, IMAGE *out, im_rect_intersectrect( &top, &bottom, &overlap ); if( overlap.width < 2*halfarea + 1 || overlap.height < 2*halfarea + 1 ) { - im_errormsg( "im_tbmosaic: overlap too small for search" ); + im_error( "im_tbmosaic", "%s", _( "overlap too small for search" ) ); return( -1 ); } @@ -190,7 +190,7 @@ im__find_tboverlap( IMAGE *ref_in, IMAGE *sec_in, IMAGE *out, return( -1 ); } else { - im_errormsg( "im_tbmosaic: unknown Coding type" ); + im_error( "im_tbmosaic", "%s", _( "unknown Coding type" ) ); return( -1 ); } diff --git a/libvips/mosaicing/match.c b/libvips/mosaicing/match.c index 24b38788..32bb3e7a 100644 --- a/libvips/mosaicing/match.c +++ b/libvips/mosaicing/match.c @@ -53,10 +53,8 @@ im__coeff( int xr1, int yr1, int xs1, int ys1, { DOUBLEMASK *in, *out; - if( !(in = im_create_dmask( "in", 4, 4 )) ) { - im_errormsg( "im__coeff: unable to allocate matrix" ); + if( !(in = im_create_dmask( "in", 4, 4 )) ) return( -1 ); - } in->coeff[0] = (double)xs1; in->coeff[1] = (double)-ys1; @@ -77,7 +75,6 @@ im__coeff( int xr1, int yr1, int xs1, int ys1, if( !(out = im_matinv( in, "out" )) ) { im_free_dmask( in ); - im_errormsg( "im__coeff: unable to invert matrix" ); return( -1 ); } @@ -119,7 +116,8 @@ im_match_linear( IMAGE *ref, IMAGE *sec, IMAGE *out, /* Transform image! */ - if( im_similarity_area( sec, out, a, b, dx, dy, x, y, w, h ) ) + if( im_affinei( sec, out, vips_interpolate_bilinear_static(), + a, -b, b, a, dx, dy, x, y, w, h ) ) return( -1 ); return( 0 ); diff --git a/libvips/other/cooc_funcs.c b/libvips/other/cooc_funcs.c index 5f3d9f41..aaba04a9 100644 --- a/libvips/other/cooc_funcs.c +++ b/libvips/other/cooc_funcs.c @@ -95,28 +95,29 @@ int dx, dy; /* displacements */ int norm; if (im_iocheck(im, m) == -1) - { im_errormsg("im_cooc_sym: im_iocheck failed"); return(-1);} - if ((im->Bands != 1)||(im->Bbits != IM_BBITS_BYTE)||(im->BandFmt != IM_BANDFMT_UCHAR)) - { - im_errormsg("im_cooc_sym: Unable to accept input"); + return( -1 ); + if ((im->Bands != 1)||(im->Bbits != IM_BBITS_BYTE)||(im->BandFmt != IM_BANDFMT_UCHAR)) { + im_error( "im_cooc_sym", "%s", _( "Unable to accept input") ); return(-1); } - if ( (xpos + xsize + dx > im->Xsize)|| (ypos + ysize + dy > im->Ysize) ) - { im_errormsg("im_cooc_sym: wrong args"); return(-1); } + if ( (xpos + xsize + dx > im->Xsize)|| (ypos + ysize + dy > im->Ysize) ) { + im_error( "im_cooc_sym", "%s", _( "wrong args") ); + return(-1); } if (im_cp_desc(m, im) == -1) - { im_errormsg("im_cooc_sym: im_cp_desc failed"); return(-1);} + return( -1 ); m->Xsize = 256; m->Ysize = 256; m->Bbits = IM_BBITS_DOUBLE; m->BandFmt = IM_BANDFMT_DOUBLE; m->Type = IM_TYPE_B_W; if (im_setupout(m) == -1) - {im_errormsg("im_cooc_sym: im_setupout failed"); return(-1);} + return( -1 ); /* malloc space to keep the read values */ buf = (int *)calloc( (unsigned)m->Xsize*m->Ysize, sizeof(int) ); line = (double *)calloc( (unsigned)m->Xsize * m->Bands, sizeof(double)); - if ( (buf == NULL) || (line == NULL) ) - { im_errormsg("im_cooc_sym: calloc failed"); return(-1); } + if ( (buf == NULL) || (line == NULL) ) { + im_error( "im_cooc_sym", "%s", _( "calloc failed") ); + return(-1); } input = (PEL*)im->data; input += ( ypos * im->Xsize + xpos ); offset = dy * im->Xsize + dx; @@ -147,7 +148,7 @@ int dx, dy; /* displacements */ *cpline++ = (double)(*cpnt++)/(double)norm; if (im_writeline( y, m, (PEL *) line ) == -1) { - im_errormsg("im_cooc_sym: unable to im_writeline"); + im_error( "im_cooc_sym", "%s", _( "unable to im_writeline") ); return(-1); } } @@ -172,27 +173,29 @@ int dx, dy; /* displacements */ int norm; if (im_iocheck(im, m) == -1) - { im_errormsg("im_cooc_ord: im_iocheck failed"); return(-1);} + return( -1 ); if ((im->Bands != 1)||(im->Bbits != IM_BBITS_BYTE)||(im->BandFmt != IM_BANDFMT_UCHAR)) { - im_errormsg("im_cooc_ord: Unable to accept input"); + im_error( "im_cooc_ord", "%s", _( "Unable to accept input") ); return(-1); } - if ( (xpos + xsize + dx > im->Xsize)|| (ypos + ysize + dy > im->Ysize) ) - { im_errormsg("im_cooc_ord: wrong args"); return(-1); } + if ( (xpos + xsize + dx > im->Xsize)|| (ypos + ysize + dy > im->Ysize) ) { + im_error( "im_cooc_ord", "%s", _( "wrong args") ); + return(-1); } if (im_cp_desc(m, im) == -1) - { im_errormsg("im_cooc_ord: im_cp_desc failed"); return(-1);} + return( -1 ); m->Xsize = 256; m->Ysize = 256; m->Bbits = IM_BBITS_DOUBLE; m->BandFmt = IM_BANDFMT_DOUBLE; if (im_setupout(m) == -1) - {im_errormsg("im_cooc_ord: im_setupout failed"); return(-1);} + return( -1 ); /* malloc space to keep the read values */ buf = (int *)calloc( (unsigned)m->Xsize*m->Ysize, sizeof(int) ); line = (double *)calloc( (unsigned)m->Xsize * m->Bands, sizeof(double)); - if ( (buf == NULL) || (line == NULL) ) - { im_errormsg("im_cooc_ord: calloc failed"); return(-1); } + if ( (buf == NULL) || (line == NULL) ) { + im_error( "im_cooc_ord", "%s", _( "calloc failed") ); + return(-1); } input = (PEL*)im->data; input += ( ypos * im->Xsize + xpos ); offset = dy * im->Xsize + dx; @@ -221,7 +224,7 @@ int dx, dy; /* displacements */ *cpline++ = (double)(*cpnt++)/(double)norm; if (im_writeline( y, m, (PEL *) line ) == -1) { - im_errormsg("im_cooc_ord: unable to im_writeline"); + im_error( "im_cooc_ord", "%s", _( "unable to im_writeline") ); return(-1); } } @@ -240,8 +243,9 @@ im_cooc_matrix( IMAGE *im, IMAGE *m, return( im_cooc_ord(im, m, xp, yp, xs, ys, dx, dy) ); else if (flag == 1) /* symmetrical cooc */ return( im_cooc_sym(im, m, xp, yp, xs, ys, dx, dy) ); - else - { im_errormsg("im_cooc_matrix: wrong flag!"); return(-1); } + else { + im_error( "im_cooc_matrix", "%s", _( "wrong flag!") ); + return(-1); } } /* Calculate contrast, asmoment, entropy and correlation @@ -258,7 +262,7 @@ im_cooc_asm( IMAGE *m, double *asmoment ) if (m->Xsize != 256 || m->Ysize != 256 || m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) { - im_errormsg("im_cooc_asm: unable to accept input"); + im_error( "im_cooc_asm", "%s", _( "unable to accept input") ); return(-1); } tmpasm = 0.0; @@ -284,7 +288,7 @@ im_cooc_contrast( IMAGE *m, double *contrast ) if (m->Xsize != 256 || m->Ysize != 256 || m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) { - im_errormsg("im_cooc_contrast: unable to accept input"); + im_error( "im_cooc_contrast", "%s", _( "unable to accept input") ); return(-1); } tmpcon = 0.0; @@ -357,14 +361,14 @@ im_cooc_correlation( IMAGE *m, double *correlation ) if (m->Xsize != 256 || m->Ysize != 256 || m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) { - im_errormsg("im_cooc_correlation: unable to accept input"); + im_error( "im_cooc_correlation", "%s", _( "unable to accept input") ); return(-1); } row = (double*)calloc( (unsigned)m->Ysize, sizeof(double)); col = (double*)calloc( (unsigned)m->Xsize, sizeof(double)); if ( row == NULL || col == NULL ) { - im_errormsg("im_cooc_correlation: unable to calloc"); + im_error( "im_cooc_correlation", "%s", _( "unable to calloc") ); return(-1); } pbuf = (double*)m->data; @@ -417,7 +421,7 @@ mrow, stdrow, mcol, stdcol); #endif if ( (stdcol==0.0)||(stdrow==0) ) { - im_errormsg("im_cooc_correlation: zero std"); + im_error( "im_cooc_correlation", "%s", _( "zero std") ); return(-1); } tmpcor = (tmpcor-(mcol*mrow))/(stdcol*stdrow); @@ -441,7 +445,7 @@ im_cooc_entropy( IMAGE *m, double *entropy ) if (m->Xsize != 256 || m->Ysize != 256 || m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) { - im_errormsg("im_cooc_entropy: unable to accept input"); + im_error( "im_cooc_entropy", "%s", _( "unable to accept input") ); return(-1); } pbufstart = (double*)m->data; diff --git a/libvips/other/glds_funcs.c b/libvips/other/glds_funcs.c index 51b82efd..96d450d4 100644 --- a/libvips/other/glds_funcs.c +++ b/libvips/other/glds_funcs.c @@ -91,27 +91,30 @@ im_glds_matrix( IMAGE *im, IMAGE *m, int norm; if (im_iocheck(im, m) == -1) - { im_errormsg("im_glds_matrix: im_iocheck failed"); return(-1);} + return( -1 ); - if ((im->Bands != 1)||(im->Bbits != IM_BBITS_BYTE)||(im->BandFmt != IM_BANDFMT_UCHAR)) - { im_errormsg("im_glds_matrix: Wrong input"); return(-1); } + if ((im->Bands != 1)||(im->Bbits != IM_BBITS_BYTE)||(im->BandFmt != IM_BANDFMT_UCHAR)) { + im_error( "im_glds_matrix", "%s", _( "Wrong input") ); + return(-1); } - if ( (xpos + xsize + dx > im->Xsize)|| (ypos + ysize + dy > im->Ysize) ) - { im_errormsg("im_glds_matrix: wrong args"); return(-1); } + if ( (xpos + xsize + dx > im->Xsize)|| (ypos + ysize + dy > im->Ysize) ) { + im_error( "im_glds_matrix", "%s", _( "wrong args") ); + return(-1); } if (im_cp_desc(m, im) == -1) - { im_errormsg("im_glds_matrix: im_cp_desc failed"); return(-1);} + return( -1 ); m->Xsize = 256; m->Ysize = 1; m->Bbits = IM_BBITS_DOUBLE; m->BandFmt = IM_BANDFMT_DOUBLE; m->Type = IM_TYPE_B_W; if (im_setupout(m) == -1) - { im_errormsg("im_glds_matrix: im_setupout failed");return(-1);} + return( -1 ); b = (int *)calloc( (unsigned)m->Xsize, sizeof(int) ); l = (double *)calloc( (unsigned)m->Xsize, sizeof(double)); - if ( (b == NULL) || (l == NULL) ) - { im_errormsg("im_glds_matrix: calloc failed"); return(-1); } + if ( (b == NULL) || (l == NULL) ) { + im_error( "im_glds_matrix", "%s", _( "calloc failed") ); + return(-1); } in = (PEL*)im->data; in += ( ypos * im->Xsize + xpos ); @@ -135,7 +138,7 @@ im_glds_matrix( IMAGE *im, IMAGE *m, for (x=0; xXsize; x++) *pl++ = ((double)(*pb++))/(double)norm; if (im_writeline( 0, m, (PEL *) l ) == -1) - {im_errormsg("im_glds_matrix: im_writeline failed");return(-1);} + return( -1 ); free((char*)b); free((char*)l); return(0); @@ -153,8 +156,9 @@ im_glds_asm( IMAGE *m, double *asmoment ) return( -1 ); if (m->Xsize != 256 || m->Ysize != 1 || - m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) - {im_errormsg("im_glds_asm: unable to accept input");return(-1);} + m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) { + im_error( "im_glds_asm", "%s", _( "unable to accept input") ); + return(-1);} tmpasm = 0.0; in = (double*)m->data; for(i=0; iXsize; i++) @@ -178,8 +182,9 @@ im_glds_contrast( IMAGE *m, double *contrast ) return( -1 ); if (m->Xsize != 256 || m->Ysize != 1 || - m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) - { im_errormsg("im_glds_contrast: wrong input"); return(-1); } + m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) { + im_error( "im_glds_contrast", "%s", _( "wrong input") ); + return(-1); } tmpcon = 0.0; in = (double*)m->data; for(i=0; iXsize; i++) @@ -204,8 +209,9 @@ im_glds_entropy( IMAGE *m, double *entropy ) return( -1 ); if (m->Xsize != 256 || m->Ysize != 1 || - m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) - { im_errormsg("im_glds_entropy: wrong input"); return(-1); } + m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) { + im_error( "im_glds_entropy", "%s", _( "wrong input") ); + return(-1); } tmpent = 0.0; in = (double*)m->data; for(i=0; iXsize; i++) @@ -233,8 +239,9 @@ im_glds_mean( IMAGE *m, double *mean ) return( -1 ); if (m->Xsize != 256 || m->Ysize != 1 || - m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) - { im_errormsg("im_glds_mean: wrong input"); return(-1); } + m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) { + im_error( "im_glds_mean", "%s", _( "wrong input") ); + return(-1); } tmpmean = 0.0; in = (double*)m->data; for(i=0; iXsize; i++) diff --git a/libvips/other/im_benchmark.c b/libvips/other/im_benchmark.c index bd337013..0022fdf5 100644 --- a/libvips/other/im_benchmark.c +++ b/libvips/other/im_benchmark.c @@ -208,9 +208,10 @@ benchmark( IMAGE *in, IMAGE *out ) /* Shrink by 10%, bilinear interp. */ - im_affine( t[1], t[2], - 0.9, 0, 0, 0.9, 0, 0, - 0, 0, t[1]->Xsize * 0.9, t[1]->Ysize * 0.9 ) || + im_affinei_all( t[1], t[2], + vips_interpolate_bilinear_static(), + 0.9, 0, 0, 0.9, + 0, 0 ) || /* Find L ~= 100 areas (white surround). */ @@ -264,11 +265,11 @@ im_benchmarkn( IMAGE *in, IMAGE *out, int n ) * so if we chain many of them together the image gets * too small. */ - im_affine( t[0], t[1], + im_affinei_all( t[0], t[1], + vips_interpolate_bilinear_static(), (double) in->Xsize / t[0]->Xsize, 0, 0, (double) in->Ysize / t[0]->Ysize, - 0, 0, - 0, 0, in->Xsize, in->Ysize ) || + 0, 0 ) || im_benchmarkn( t[1], out, n - 1 ) ); } diff --git a/libvips/other/im_dif_std.c b/libvips/other/im_dif_std.c index 60b1e57c..98080f65 100644 --- a/libvips/other/im_dif_std.c +++ b/libvips/other/im_dif_std.c @@ -66,15 +66,18 @@ double *pmean, *pstd; if( im_incheck( im ) ) return( -1 ); - if ((im->Bands != 1)||(im->Bbits != IM_BBITS_BYTE)||(im->BandFmt != IM_BANDFMT_UCHAR)) - {im_errormsg("im_dif_std: Unable to accept input"); return(-1);} - if ( (xpos + xsize + dx > im->Xsize)|| (ypos + ysize + dy > im->Ysize) ) - { im_errormsg("im_dif_std: wrong args"); return(-1); } + if ((im->Bands != 1)||(im->Bbits != IM_BBITS_BYTE)||(im->BandFmt != IM_BANDFMT_UCHAR)) { + im_error( "im_dif_std", "%s", _( "Unable to accept input") ); + return(-1);} + if ( (xpos + xsize + dx > im->Xsize)|| (ypos + ysize + dy > im->Ysize) ) { + im_error( "im_dif_std", "%s", _( "wrong args") ); + return(-1); } bufsize = xsize * ysize; buf = (int *)calloc( (unsigned)bufsize, sizeof(int) ); - if ( buf == NULL ) - { im_errormsg("im_dif_std: calloc failed"); return(-1); } + if ( buf == NULL ) { + im_error( "im_dif_std", "%s", _( "calloc failed") ); + return(-1); } input = (PEL*)im->data; input += ( ypos * im->Xsize + xpos ); ofst = dy * im->Xsize + dx; diff --git a/libvips/other/im_eye.c b/libvips/other/im_eye.c index 20fb3801..177ca3d2 100644 --- a/libvips/other/im_eye.c +++ b/libvips/other/im_eye.c @@ -75,7 +75,7 @@ im_feye( IMAGE *image, const int xsize, const int ysize, const double factor ) if( im_outcheck( image ) ) return( -1 ); if( factor > 1.0 || factor <= 0.0 ) { - im_errormsg( "im_feye: factor should be in [1,0)" ); + im_error( "im_feye", "%s", _( "factor should be in [1,0)" ) ); return( -1 ); } diff --git a/libvips/other/im_grey.c b/libvips/other/im_grey.c index 388b1c2a..cc9a58b6 100644 --- a/libvips/other/im_grey.c +++ b/libvips/other/im_grey.c @@ -100,7 +100,7 @@ im_fgrey( IMAGE *out, const int xsize, const int ysize ) /* Check args. */ if( xsize <=0 || ysize <= 0 ) { - im_errormsg( "im_fgrey: bad size" ); + im_error( "im_fgrey", "%s", _( "bad size" ) ); return( -1 ); } if( im_poutcheck( out ) ) diff --git a/libvips/other/im_make_xy.c b/libvips/other/im_make_xy.c index 705ed5a2..ad8500a6 100644 --- a/libvips/other/im_make_xy.c +++ b/libvips/other/im_make_xy.c @@ -91,7 +91,7 @@ im_make_xy( IMAGE *out, const int xsize, const int ysize ) /* Check args. */ if( xsize <=0 || ysize <= 0 ) { - im_errormsg( "im_make_xy: bad size" ); + im_error( "im_make_xy", "%s", _( "bad size" ) ); return( -1 ); } if( im_poutcheck( out ) ) diff --git a/libvips/other/im_meanstd.c b/libvips/other/im_meanstd.c index 2edbfeff..df14994b 100644 --- a/libvips/other/im_meanstd.c +++ b/libvips/other/im_meanstd.c @@ -76,7 +76,7 @@ im__mean_std_double_buffer( double *buffer, int size, double variance; /* = (sumf2 - correction)/n */ if (size <= 0) { - im_errormsg("im_mean_std_double_buffer: wrong args"); + im_error( "im_mean_std_double_buffer", "%s", _( "wrong args") ); return(-1); } mean = 0.0; std = 0.0; @@ -112,7 +112,7 @@ im__mean_std_int_buffer( int *buffer, int size, double variance; /* = (sumf2 - correction)/n */ if (size <= 0) { - im_errormsg("im_mean_std_int_buffer: wrong args"); + im_error( "im_mean_std_int_buffer", "%s", _( "wrong args") ); return(-1); } diff --git a/libvips/other/im_simcontr.c b/libvips/other/im_simcontr.c index a7ad3c21..eb174650 100644 --- a/libvips/other/im_simcontr.c +++ b/libvips/other/im_simcontr.c @@ -75,12 +75,13 @@ im_simcontr( IMAGE *image, int xs, int ys ) /* Set up image checking whether the output is a buffer or a file */ if (im_setupout( image ) == -1 ) - { im_errormsg("im_simcontr: im_setupout failed"); return(-1); } + return( -1 ); /* Create data */ line1 = (unsigned char *)calloc((unsigned)xs, sizeof(char)); line2 = (unsigned char *)calloc((unsigned)xs, sizeof(char)); - if ( (line1 == NULL) || (line2 == NULL) ) - { im_errormsg("im_simcontr: calloc failed"); return(-1); } + if ( (line1 == NULL) || (line2 == NULL) ) { + im_error( "im_simcontr", "%s", _( "calloc failed") ); + return(-1); } cpline = line1; for (x=0; xXsize; - if ( (line=(float *)calloc((unsigned)size, sizeof(float))) == NULL ) - { im_errormsg("im_sines: calloc failed"); return(-1); } + if ( (line=(float *)calloc((unsigned)size, sizeof(float))) == NULL ) { + im_error( "im_sines", "%s", _( "calloc failed") ); + return(-1); } /* make angle in rad */ if (horfreq == 0) @@ -111,7 +113,6 @@ im_sines( IMAGE *image, int xsize, int ysize, double horfreq, double verfreq ) (float)(cos(cons*(x*costheta-ysintheta))); if ( im_writeline( y, image, (PEL *)line ) == -1 ) { - im_errormsg("im_sines: im_writeline failed"); free ( (char *)line ); return( -1 ); } @@ -127,7 +128,6 @@ im_sines( IMAGE *image, int xsize, int ysize, double horfreq, double verfreq ) *cpline++ = (float)ysintheta; if ( im_writeline( y, image, (PEL *)line ) == -1 ) { - im_errormsg("im_sines: im_writeline failed"); free ( (char *)line ); return( -1 ); } diff --git a/libvips/other/im_spatres.c b/libvips/other/im_spatres.c index f8535f15..c4381d62 100644 --- a/libvips/other/im_spatres.c +++ b/libvips/other/im_spatres.c @@ -68,34 +68,37 @@ im_spatres( IMAGE *in, IMAGE *out, int step ) int os; /* Check args */ - if ( step < 1 ) - {im_errormsg("im_spatres: Invalid step %d\n", step);return(-1);} + if ( step < 1 ) { + im_error( "im_spatres", _( "Invalid step %d" ), step ); + return(-1);} if ( (in->Xsize/step == 0)||(in->Ysize/step == 0) ) - {im_errormsg("im_spatres: Invalid step %d\n", step);return(-1);} + {im_error("im_spatres", _( "Invalid step %d" ), step);return(-1);} if (im_iocheck(in, out) == -1) - { im_errormsg("im_spatres: im_iocheck failed"); return(-1); } + return( -1 ); - if((in->Coding != IM_CODING_NONE)||(in->Bbits != 8)||(in->BandFmt !=IM_BANDFMT_UCHAR)) - { im_errormsg("im_spatres: wrong input"); return(-1); } + if((in->Coding != IM_CODING_NONE)||(in->Bbits != 8)||(in->BandFmt !=IM_BANDFMT_UCHAR)) { + im_error( "im_spatres", "%s", _( "wrong input") ); + return(-1); } /* Prepare output */ if (im_cp_desc(out, in) == -1) - { im_errormsg("im_spatres: im_cp_desc failed"); return(-1); } + return( -1 ); out->Xsize = in->Xsize - in->Xsize%step; out->Ysize = in->Ysize - in->Ysize%step; if( im_setupout(out) == -1) - { im_errormsg("im_spatres: im_setupout failed"); return(-1); } + return( -1 ); /* Malloc buffer for one 'line' of input data */ os = in->Xsize * in->Bands; line = (unsigned char *)calloc((unsigned)os, sizeof(char)); /* Malloc space for values */ values = (unsigned char *)calloc((unsigned)out->Bands, sizeof(char)); - if ( line == NULL || values == NULL ) - { im_errormsg("im_spatres: calloc failed"); return(-1); } + if ( line == NULL || values == NULL ) { + im_error( "im_spatres", "%s", _( "calloc failed") ); + return(-1); } step2 = step * step; rounding = step2/2; @@ -135,7 +138,6 @@ im_spatres( IMAGE *in, IMAGE *out, int step ) for (j = 0; j < step; j++) if ( im_writeline ( y+j, out, (PEL *)line ) == -1 ) { - im_errormsg("im_spatres: im_writeline failed"); free ( (char *)line ); free ( (char *)values ); return( -1 ); } diff --git a/libvips/other/im_zone.c b/libvips/other/im_zone.c index 59477461..19e74b55 100644 --- a/libvips/other/im_zone.c +++ b/libvips/other/im_zone.c @@ -79,7 +79,8 @@ im_fzone( IMAGE *image, int size ) if( im_outcheck( image ) ) return( -1 ); if( size <= 0 || (size % 2) != 0 ) { - im_errormsg( "im_zone: size must be even and positive" ); + im_error( "im_zone", "%s", + _( "size must be even and positive" ) ); return( -1 ); } @@ -99,7 +100,7 @@ im_fzone( IMAGE *image, int size ) */ for( y = 0, j = -size2; j < size2; j++, y++ ) { for( x = 0, i = -size2; i < size2; i++, x++ ) - buf[x] = cos( (IM_PI/size) * (i*i + j*j) ); + buf[x] = cos( (IM_PI / size) * (i * i + j * j) ); if( im_writeline( y, image, (PEL *) buf ) ) return( -1 ); } diff --git a/libvips/relational/relational.c b/libvips/relational/relational.c index ec9c7542..7341e8ca 100644 --- a/libvips/relational/relational.c +++ b/libvips/relational/relational.c @@ -134,7 +134,7 @@ relational_process( char *name, IMAGE **in, IMAGE *out, */ for( n = 0; in[n]; n++ ) { if( in[n]->Coding != IM_CODING_NONE ) { - im_errormsg( "%s: uncoded images only", name ); + im_error( name, "%s", _( "uncoded images only" ) ); return( -1 ); } } @@ -144,8 +144,8 @@ relational_process( char *name, IMAGE **in, IMAGE *out, */ for( i = 1; i < n; i++ ) if( in[0]->Bands != in[i]->Bands ) { - im_errormsg( "%s: images differ in numbers of bands", - name ); + im_error( name, "%s", + _( "images differ in numbers of bands" ) ); return( -1 ); } @@ -365,11 +365,11 @@ im_equal_vec( IMAGE *in, IMAGE *out, int n, double *c ) double *p; if( n != in->Bands ) { - im_errormsg( "im_equal_vec: vec size does not match bands" ); + im_error( "im_equal_vec", "%s", _( "vec size does not match bands" ) ); return( -1 ); } if( im_iscomplex( in ) ) { - im_errormsg( "im_equal_vec: not implemented for complex" ); + im_error( "im_equal_vec", "%s", _( "not implemented for complex" ) ); return( -1 ); } @@ -433,11 +433,11 @@ im_notequal_vec( IMAGE *in, IMAGE *out, int n, double *c ) double *p; if( n != in->Bands ) { - im_errormsg( "im_notequal_vec: vec size does not match bands" ); + im_error( "im_notequal_vec", "%s", _( "vec size does not match bands" ) ); return( -1 ); } if( im_iscomplex( in ) ) { - im_errormsg( "im_notequal_vec: not implemented for complex" ); + im_error( "im_notequal_vec", "%s", _( "not implemented for complex" ) ); return( -1 ); } @@ -542,11 +542,11 @@ im_less_vec( IMAGE *in, IMAGE *out, int n, double *c ) double *p; if( n != in->Bands ) { - im_errormsg( "im_less_vec: vec size does not match bands" ); + im_error( "im_less_vec", "%s", _( "vec size does not match bands" ) ); return( -1 ); } if( im_iscomplex( in ) ) { - im_errormsg( "im_less_vec: not implemented for complex" ); + im_error( "im_less_vec", "%s", _( "not implemented for complex" ) ); return( -1 ); } @@ -651,11 +651,11 @@ im_lesseq_vec( IMAGE *in, IMAGE *out, int n, double *c ) double *p; if( n != in->Bands ) { - im_errormsg( "im_lesseq_vec: vec size does not match bands" ); + im_error( "im_lesseq_vec", "%s", _( "vec size does not match bands" ) ); return( -1 ); } if( im_iscomplex( in ) ) { - im_errormsg( "im_lesseq_vec: not implemented for complex" ); + im_error( "im_lesseq_vec", "%s", _( "not implemented for complex" ) ); return( -1 ); } @@ -692,7 +692,7 @@ im_more_vec( IMAGE *in, IMAGE *out, int n, double *c ) */ if( !(t = im_open_local( out, "im_more_vec-1", "p" )) || im_lesseq_vec( in, t, n, c ) || - im_eorconst( t, out, 255 ) ) + im_eorimageconst( t, out, 255 ) ) return( -1 ); return( 0 ); @@ -722,7 +722,7 @@ im_moreeq_vec( IMAGE *in, IMAGE *out, int n, double *c ) */ if( !(t = im_open_local( out, "im_moreeq_vec-1", "p" )) || im_less_vec( in, t, n, c ) || - im_eorconst( t, out, 255 ) ) + im_eorimageconst( t, out, 255 ) ) return( -1 ); return( 0 ); diff --git a/libvips/resample/im_affine.c b/libvips/resample/im_affine.c index 05192b53..c307032a 100644 --- a/libvips/resample/im_affine.c +++ b/libvips/resample/im_affine.c @@ -500,23 +500,11 @@ im_affinei_all( IMAGE *in, IMAGE *out, VipsInterpolate *interpolate, return( im__affinei( in, out, interpolate, &trn ) ); } -/* Provide the old im__affine()/im_affine() as bilinear affinei. +/* Still needed by some parts of mosaic. */ - int im__affine( IMAGE *in, IMAGE *out, Transformation *trn ) { return( im__affinei( in, out, vips_interpolate_bilinear_static(), trn ) ); } - -int -im_affine( IMAGE *in, IMAGE *out, - double a, double b, double c, double d, double dx, double dy, - int ox, int oy, int ow, int oh ) -{ - return( im_affinei( in, out, - vips_interpolate_bilinear_static(), - a, b, c, d, dx, dy, - ox, oy, ow, oh ) ); -} diff --git a/libvips/resample/resample_dispatch.c b/libvips/resample/resample_dispatch.c index 05b1a3b0..925d5a77 100644 --- a/libvips/resample/resample_dispatch.c +++ b/libvips/resample/resample_dispatch.c @@ -44,53 +44,6 @@ #include #endif /*WITH_DMALLOC*/ -/* affine args - */ -static im_arg_desc affine_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_DOUBLE( "a" ), - IM_INPUT_DOUBLE( "b" ), - IM_INPUT_DOUBLE( "c" ), - IM_INPUT_DOUBLE( "d" ), - IM_INPUT_DOUBLE( "dx" ), - IM_INPUT_DOUBLE( "dy" ), - IM_INPUT_INT( "x" ), - IM_INPUT_INT( "y" ), - IM_INPUT_INT( "w" ), - IM_INPUT_INT( "h" ) -}; - -/* Call im_affine via arg vector. - */ -static int -affine_vec( im_object *argv ) -{ - double a = *((double *) argv[2]); - double b = *((double *) argv[3]); - double c = *((double *) argv[4]); - double d = *((double *) argv[5]); - double dx = *((double *) argv[6]); - double dy = *((double *) argv[7]); - int x = *((int *) argv[8]); - int y = *((int *) argv[9]); - int w = *((int *) argv[10]); - int h = *((int *) argv[11]); - - return( im_affine( argv[0], argv[1], a, b, c, d, dx, dy, x, y, w, h ) ); -} - -/* Description of im_affine. - */ -static im_function affine_desc = { - "im_affine", /* Name */ - "affine transform", - IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ - affine_vec, /* Dispatch function */ - IM_NUMBER( affine_args ), /* Size of arg list */ - affine_args /* Arg list */ -}; - /* affinei args */ static im_arg_desc affinei_args[] = { @@ -183,93 +136,11 @@ static im_function affinei_all_desc = { affinei_all_args /* Arg list */ }; -/* similarity args - */ -static im_arg_desc similarity_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_DOUBLE( "a" ), - IM_INPUT_DOUBLE( "b" ), - IM_INPUT_DOUBLE( "dx" ), - IM_INPUT_DOUBLE( "dy" ) -}; - -/* Call im_similarity via arg vector. - */ -static int -similarity_vec( im_object *argv ) -{ - double a = *((double *) argv[2]); - double b = *((double *) argv[3]); - double dx = *((double *) argv[4]); - double dy = *((double *) argv[5]); - - return( im_similarity( argv[0], argv[1], a, b, dx, dy ) ); -} - -/* Description of im_similarity. - */ -static im_function similarity_desc = { - "im_similarity", /* Name */ - "similarity transformation", - IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ - similarity_vec, /* Dispatch function */ - IM_NUMBER( similarity_args ), /* Size of arg list */ - similarity_args /* Arg list */ -}; - -/* similarity_area args - */ -static im_arg_desc similarity_area_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_DOUBLE( "a" ), - IM_INPUT_DOUBLE( "b" ), - IM_INPUT_DOUBLE( "dx" ), - IM_INPUT_DOUBLE( "dy" ), - IM_INPUT_INT( "x" ), - IM_INPUT_INT( "y" ), - IM_INPUT_INT( "w" ), - IM_INPUT_INT( "h" ) -}; - -/* Call im_similarity_area via arg vector. - */ -static int -similarity_area_vec( im_object *argv ) -{ - double a = *((double *) argv[2]); - double b = *((double *) argv[3]); - double dx = *((double *) argv[4]); - double dy = *((double *) argv[5]); - int x = *((int *) argv[6]); - int y = *((int *) argv[7]); - int w = *((int *) argv[8]); - int h = *((int *) argv[9]); - - return( im_similarity_area( argv[0], argv[1], a, b, dx, dy, - x, y, w, h ) ); -} - -/* Description of im_similarity_area. - */ -static im_function similarity_area_desc = { - "im_similarity_area", /* Name */ - "output area xywh of similarity transformation", - IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ - similarity_area_vec, /* Dispatch function */ - IM_NUMBER( similarity_area_args ), /* Size of arg list */ - similarity_area_args /* Arg list */ -}; - /* Package up all these functions. */ static im_function *resample_list[] = { - &affine_desc, &affinei_desc, &affinei_all_desc, - &similarity_area_desc, - &similarity_desc }; /* Package of functions. diff --git a/tools/mosaicing/find_mosaic.c b/tools/mosaicing/find_mosaic.c index 46b62ec4..70370fe0 100644 --- a/tools/mosaicing/find_mosaic.c +++ b/tools/mosaicing/find_mosaic.c @@ -107,7 +107,8 @@ char *name; /* Chop off '.v'. */ if( !(p = strrchr( out, '.' )) ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( NULL ); } @@ -116,7 +117,8 @@ char *name; /* Chop off nxn. */ if( !(p = strrchr( out, '.' )) ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( NULL ); } @@ -137,7 +139,8 @@ char *name; /* Chop off '.v'. */ if( !(p = strrchr( out, '.' )) ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( -1 ); } @@ -146,7 +149,8 @@ char *name; /* Find '.nxm'. */ if( !(p = strrchr( out, '.' )) ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( -1 ); } @@ -154,7 +158,8 @@ char *name; /* Read out x posn. */ if( sscanf( p, ".%dx%*d", &n ) != 1 ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( -1 ); } @@ -174,7 +179,8 @@ char *name; /* Chop off '.v'. */ if( !(p = strrchr( out, '.' )) ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( -1 ); } @@ -183,7 +189,8 @@ char *name; /* Find '.nxm'. */ if( !(p = strrchr( out, '.' )) ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( -1 ); } @@ -191,7 +198,8 @@ char *name; /* Read out y posn. */ if( sscanf( p, ".%*dx%d", &m ) != 1 ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( -1 ); } diff --git a/tools/mosaicing/mergeup.c b/tools/mosaicing/mergeup.c index 287529da..3436cf58 100644 --- a/tools/mosaicing/mergeup.c +++ b/tools/mosaicing/mergeup.c @@ -233,7 +233,8 @@ char *name; /* Chop off '.v'. */ if( !(p = strrchr( out, '.' )) ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( NULL ); } @@ -242,7 +243,8 @@ char *name; /* Chop off nxn. */ if( !(p = strrchr( out, '.' )) ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( NULL ); } @@ -263,7 +265,8 @@ char *name; /* Chop off '.v'. */ if( !(p = strrchr( out, '.' )) ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( -1 ); } @@ -272,7 +275,8 @@ char *name; /* Find '.nxm'. */ if( !(p = strrchr( out, '.' )) ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( -1 ); } @@ -280,7 +284,8 @@ char *name; /* Read out x posn. */ if( sscanf( p, ".%dx%*d", &n ) != 1 ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( -1 ); } @@ -300,7 +305,8 @@ char *name; /* Chop off '.v'. */ if( !(p = strrchr( out, '.' )) ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( -1 ); } @@ -309,7 +315,8 @@ char *name; /* Find '.nxm'. */ if( !(p = strrchr( out, '.' )) ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( -1 ); } @@ -317,7 +324,8 @@ char *name; /* Read out y posn. */ if( sscanf( p, ".%*dx%d", &m ) != 1 ) { - im_errormsg( "Bad file name format '%s'", name ); + im_error( "find_mosaic", + _( "bad file name format '%s'" ), name ); free( out ); return( -1 ); } @@ -337,10 +345,8 @@ static int join_leftright(IMAGE *left, IMAGE *right, IMAGE *out, int dx, int dy ) { - if (im_lrmerge(left, right, out, dx, dy, 20) == -1){ - im_errormsg("mergeup: unable to run im_lrmerge"); + if (im_lrmerge(left, right, out, dx, dy, 20) == -1) return( -1 ); - } return( 0 ); } @@ -350,10 +356,8 @@ return( 0 ); static int join_updown( IMAGE *top, IMAGE *bottom, IMAGE *out, int dx, int dy ) { - if (im_tbmerge(top, bottom, out, dx, dy, 20) == -1){ - im_errormsg("mergeup: unable to run im_tbmerge"); + if (im_tbmerge(top, bottom, out, dx, dy, 20) == -1) return( -1 ); - } return( 0 ); } @@ -373,7 +377,7 @@ merge_up( int width, int height, IMAGE **inp, IMAGE *outp, int xoff, int yoff, p_img = (IMAGE **) malloc(1 + 3 * width * height * sizeof(IMAGE *)); if( p_img == NULL ){ - im_errormsg("mergeup: allocation failure in mergeup"); + im_error( "mergeup", "%s", _( "allocation failure in mergeup") ); return( -1 ); } partial_no = 0; @@ -383,7 +387,7 @@ merge_up( int width, int height, IMAGE **inp, IMAGE *outp, int xoff, int yoff, first_row = 0; if( (width == 0 ) && (height == 0 ) ){ - im_errormsg("mergeup: Need more than one image"); + im_error( "mergeup", "%s", _( "Need more than one image") ); return( -1 ); } @@ -395,7 +399,6 @@ merge_up( int width, int height, IMAGE **inp, IMAGE *outp, int xoff, int yoff, if( j != 0 ){ im_snprintf( name, 29, "partial_img.%d.v",partial_no ); if( !( p_img[partial_no] = im_open( name, "p" )) ){ - im_errormsg("mergeup: unable to open partial image"); free(p_img); return( -1 ); } @@ -421,7 +424,6 @@ merge_up( int width, int height, IMAGE **inp, IMAGE *outp, int xoff, int yoff, if( i < height ){ im_snprintf( name, 29, "partial_img.%d.v", partial_no ); if( !( p_img[partial_no] = im_open( name, "p" )) ){ - im_errormsg("mergeup: unable to open partial image"); free(p_img); return( -1 ); }