From ea4562a24af7492d5b4f610bd2f8a3248d966abc Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 2 Nov 2009 22:01:09 +0000 Subject: [PATCH] stuff --- doc/reference/libvips-docs.sgml.in | 7 +- libvips/conversion/conver_dispatch.c | 274 +--------------------- libvips/conversion/im_vips2mask.c | 2 +- libvips/deprecated/deprecated_dispatch.c | 278 +++++++++++++++++++++++ libvips/freq_filt/im_fwfft.c | 12 +- libvips/freq_filt/im_invfft.c | 6 +- libvips/freq_filt/im_invfftr.c | 6 +- libvips/histograms_lut/im_histspec.c | 23 +- libvips/histograms_lut/tone.c | 6 +- libvips/include/vips/Makefile.am | 1 + libvips/include/vips/colour.h | 2 - libvips/include/vips/conversion.h | 118 ++++++++++ libvips/include/vips/deprecated.h | 17 ++ libvips/include/vips/format.h | 21 ++ libvips/include/vips/proto.h | 95 -------- libvips/include/vips/vips.h | 5 +- libvips/mosaicing/global_balance.c | 8 +- tools/other/squares.c | 1 + 18 files changed, 476 insertions(+), 406 deletions(-) create mode 100644 libvips/include/vips/conversion.h diff --git a/doc/reference/libvips-docs.sgml.in b/doc/reference/libvips-docs.sgml.in index 85d79b5d..110d67fa 100644 --- a/doc/reference/libvips-docs.sgml.in +++ b/doc/reference/libvips-docs.sgml.in @@ -39,7 +39,12 @@ - API by section (no gtkdoc comments yet) + VIPS operation API by section (no gtkdoc comments yet) + + + + + Other API (no gtkdoc comments yet) diff --git a/libvips/conversion/conver_dispatch.c b/libvips/conversion/conver_dispatch.c index 3ba23505..dbda8acf 100644 --- a/libvips/conversion/conver_dispatch.c +++ b/libvips/conversion/conver_dispatch.c @@ -34,41 +34,12 @@ #endif /*HAVE_CONFIG_H*/ #include -#include - #include #ifdef WITH_DMALLOC #include #endif /*WITH_DMALLOC*/ -static int -print_vec( im_object *argv ) -{ - const char *message = argv[0]; - char **out = (char **) &argv[1]; - - if( im_print( message ) ) - return( -1 ); - *out = im_strdup( NULL, "printed" ); - - return( 0 ); -} - -static im_arg_desc print_arg_types[] = { - IM_INPUT_STRING( "message" ), - IM_OUTPUT_STRING( "result" ) -}; - -static im_function print_desc = { - "im_print", /* Name */ - "print string to stdout", /* Description */ - 0, /* Flags */ - print_vec, /* Dispatch function */ - IM_NUMBER( print_arg_types ), /* Size of arg list */ - print_arg_types /* Arg list */ -}; - static int system_vec( im_object *argv ) { @@ -525,177 +496,6 @@ static im_function c2amph_desc = { one_in_one_out /* Arg list */ }; -/* Call im_clip2dcm via arg vector. - */ -static int -clip2dcm_vec( im_object *argv ) -{ - return( im_clip2dcm( argv[0], argv[1] ) ); -} - -/* Description of im_clip2dcm. - */ -static im_function clip2dcm_desc = { - "im_clip2dcm", /* Name */ - "convert to double complex", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2dcm_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2cm via arg vector. - */ -static int -clip2cm_vec( im_object *argv ) -{ - return( im_clip2cm( argv[0], argv[1] ) ); -} - -/* Description of im_clip2cm. - */ -static im_function clip2cm_desc = { - "im_clip2cm", /* Name */ - "convert to complex", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2cm_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2us via arg vector. - */ -static int -clip2us_vec( im_object *argv ) -{ - return( im_clip2us( argv[0], argv[1] ) ); -} - -/* Description of im_clip2us. - */ -static im_function clip2us_desc = { - "im_clip2us", /* Name */ - "convert to unsigned 16-bit integer", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2us_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2ui via arg vector. - */ -static int -clip2ui_vec( im_object *argv ) -{ - return( im_clip2ui( argv[0], argv[1] ) ); -} - -/* Description of im_clip2ui. - */ -static im_function clip2ui_desc = { - "im_clip2ui", /* Name */ - "convert to unsigned 32-bit integer", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2ui_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2s via arg vector. - */ -static int -clip2s_vec( im_object *argv ) -{ - return( im_clip2s( argv[0], argv[1] ) ); -} - -/* Description of im_clip2s. - */ -static im_function clip2s_desc = { - "im_clip2s", /* Name */ - "convert to signed 16-bit integer", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2s_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2i via arg vector. - */ -static int -clip2i_vec( im_object *argv ) -{ - return( im_clip2i( argv[0], argv[1] ) ); -} - -/* Description of im_clip2i. - */ -static im_function clip2i_desc = { - "im_clip2i", /* Name */ - "convert to signed 32-bit integer", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2i_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2d via arg vector. - */ -static int -clip2d_vec( im_object *argv ) -{ - return( im_clip2d( argv[0], argv[1] ) ); -} - -/* Description of im_clip2d. - */ -static im_function clip2d_desc = { - "im_clip2d", /* Name */ - "convert to double-precision float", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2d_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2f via arg vector. - */ -static int -clip2f_vec( im_object *argv ) -{ - return( im_clip2f( argv[0], argv[1] ) ); -} - -/* Description of im_clip2f. - */ -static im_function clip2f_desc = { - "im_clip2f", /* Name */ - "convert to single-precision float", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2f_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_clip2c via arg vector. - */ -static int -clip2c_vec( im_object *argv ) -{ - return( im_clip2c( argv[0], argv[1] ) ); -} - -/* Description of im_clip2c. - */ -static im_function clip2c_desc = { - "im_clip2c", /* Name */ - "convert to signed 8-bit integer", - IM_FN_PTOP | IM_FN_PIO, /* Flags */ - clip2c_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - /* Call im_clip via arg vector. */ static int @@ -1313,66 +1113,6 @@ static im_function scaleps_desc = { one_in_one_out /* Arg list */ }; -/* Args to im_slice. - */ -static im_arg_desc slice_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_DOUBLE( "thresh1" ), - IM_INPUT_DOUBLE( "thresh2" ) -}; - -/* Call im_slice via arg vector. - */ -static int -slice_vec( im_object *argv ) -{ - double t1 = *((double *) argv[2]); - double t2 = *((double *) argv[3]); - - return( im_slice( argv[0], argv[1], t1, t2 ) ); -} - -/* Description of im_slice. - */ -static im_function slice_desc = { - "im_slice", /* Name */ - "slice an image using two thresholds", - 0, /* Flags */ - slice_vec, /* Dispatch function */ - IM_NUMBER( slice_args ), /* Size of arg list */ - slice_args /* Arg list */ -}; - -/* Args to im_thresh. - */ -static im_arg_desc thresh_args[] = { - IM_INPUT_IMAGE( "input" ), - IM_OUTPUT_IMAGE( "output" ), - IM_INPUT_DOUBLE( "threshold" ) -}; - -/* Call im_thresh via arg vector. - */ -static int -thresh_vec( im_object *argv ) -{ - double t1 = *((double *) argv[2]); - - return( im_thresh( argv[0], argv[1], t1 ) ); -} - -/* Description of im_thresh. - */ -static im_function thresh_desc = { - "im_thresh", /* Name */ - "slice an image at a threshold", - 0, /* Flags */ - thresh_vec, /* Dispatch function */ - IM_NUMBER( thresh_args ), /* Size of arg list */ - thresh_args /* Arg list */ -}; - /* Args to im_grid. */ static im_arg_desc grid_args[] = { @@ -1593,17 +1333,8 @@ static im_function *conv_list[] = { &c2ps_desc, &c2real_desc, &c2rect_desc, - &clip2c_desc, - &clip2cm_desc, - &clip2d_desc, - &clip2dcm_desc, - &clip2f_desc, - &clip2fmt_desc, - &clip2i_desc, - &clip2s_desc, - &clip2ui_desc, - &clip2us_desc, &clip_desc, + &clip2fmt_desc, ©_desc, ©_file_desc, ©_morph_desc, @@ -1626,7 +1357,6 @@ static im_function *conv_list[] = { &mask2vips_desc, &msb_desc, &msb_band_desc, - &print_desc, &recomb_desc, &replicate_desc, &ri2c_desc, @@ -1636,12 +1366,10 @@ static im_function *conv_list[] = { &scale_desc, &scaleps_desc, &rightshift_size_desc, - &slice_desc, &subsample_desc, &system_desc, &tbjoin_desc, &text_desc, - &thresh_desc, &vips2mask_desc, &wrap_desc, &zoom_desc diff --git a/libvips/conversion/im_vips2mask.c b/libvips/conversion/im_vips2mask.c index 7d92b6ac..06dc86ce 100644 --- a/libvips/conversion/im_vips2mask.c +++ b/libvips/conversion/im_vips2mask.c @@ -68,7 +68,7 @@ im_vips2mask( IMAGE *in, const char *outname ) if( !(t = im_open( "im_vips2mask", "p" )) ) return( NULL ); - if( im_clip2d( in, t ) || + if( im_clip2fmt( in, t, IM_BANDFMT_DOUBLE ) || !(out = im_vips2mask( t, outname )) ) { im_close( t ); return( NULL ); diff --git a/libvips/deprecated/deprecated_dispatch.c b/libvips/deprecated/deprecated_dispatch.c index 1cf2ebcc..31b3460e 100644 --- a/libvips/deprecated/deprecated_dispatch.c +++ b/libvips/deprecated/deprecated_dispatch.c @@ -41,6 +41,13 @@ #include #endif /*WITH_DMALLOC*/ +/* One image in, one out. + */ +static im_arg_desc one_in_one_out[] = { + IM_INPUT_IMAGE( "in" ), + IM_OUTPUT_IMAGE( "out" ) +}; + /* Two images in, one out. */ static im_arg_desc two_in_one_out[] = { @@ -354,6 +361,265 @@ static im_function icc_export_desc = { icc_export_args /* Arg list */ }; +static int +print_vec( im_object *argv ) +{ + const char *message = argv[0]; + char **out = (char **) &argv[1]; + + if( im_print( message ) ) + return( -1 ); + *out = im_strdup( NULL, "printed" ); + + return( 0 ); +} + +static im_arg_desc print_arg_types[] = { + IM_INPUT_STRING( "message" ), + IM_OUTPUT_STRING( "result" ) +}; + +static im_function print_desc = { + "im_print", /* Name */ + "print string to stdout", /* Description */ + 0, /* Flags */ + print_vec, /* Dispatch function */ + IM_NUMBER( print_arg_types ), /* Size of arg list */ + print_arg_types /* Arg list */ +}; + +/* Call im_clip2dcm via arg vector. + */ +static int +clip2dcm_vec( im_object *argv ) +{ + return( im_clip2dcm( argv[0], argv[1] ) ); +} + +/* Description of im_clip2dcm. + */ +static im_function clip2dcm_desc = { + "im_clip2dcm", /* Name */ + "convert to double complex", + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + clip2dcm_vec, /* Dispatch function */ + IM_NUMBER( one_in_one_out ), /* Size of arg list */ + one_in_one_out /* Arg list */ +}; + +/* Call im_clip2cm via arg vector. + */ +static int +clip2cm_vec( im_object *argv ) +{ + return( im_clip2cm( argv[0], argv[1] ) ); +} + +/* Description of im_clip2cm. + */ +static im_function clip2cm_desc = { + "im_clip2cm", /* Name */ + "convert to complex", + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + clip2cm_vec, /* Dispatch function */ + IM_NUMBER( one_in_one_out ), /* Size of arg list */ + one_in_one_out /* Arg list */ +}; + +/* Call im_clip2us via arg vector. + */ +static int +clip2us_vec( im_object *argv ) +{ + return( im_clip2us( argv[0], argv[1] ) ); +} + +/* Description of im_clip2us. + */ +static im_function clip2us_desc = { + "im_clip2us", /* Name */ + "convert to unsigned 16-bit integer", + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + clip2us_vec, /* Dispatch function */ + IM_NUMBER( one_in_one_out ), /* Size of arg list */ + one_in_one_out /* Arg list */ +}; + +/* Call im_clip2ui via arg vector. + */ +static int +clip2ui_vec( im_object *argv ) +{ + return( im_clip2ui( argv[0], argv[1] ) ); +} + +/* Description of im_clip2ui. + */ +static im_function clip2ui_desc = { + "im_clip2ui", /* Name */ + "convert to unsigned 32-bit integer", + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + clip2ui_vec, /* Dispatch function */ + IM_NUMBER( one_in_one_out ), /* Size of arg list */ + one_in_one_out /* Arg list */ +}; + +/* Call im_clip2s via arg vector. + */ +static int +clip2s_vec( im_object *argv ) +{ + return( im_clip2s( argv[0], argv[1] ) ); +} + +/* Description of im_clip2s. + */ +static im_function clip2s_desc = { + "im_clip2s", /* Name */ + "convert to signed 16-bit integer", + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + clip2s_vec, /* Dispatch function */ + IM_NUMBER( one_in_one_out ), /* Size of arg list */ + one_in_one_out /* Arg list */ +}; + +/* Call im_clip2i via arg vector. + */ +static int +clip2i_vec( im_object *argv ) +{ + return( im_clip2i( argv[0], argv[1] ) ); +} + +/* Description of im_clip2i. + */ +static im_function clip2i_desc = { + "im_clip2i", /* Name */ + "convert to signed 32-bit integer", + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + clip2i_vec, /* Dispatch function */ + IM_NUMBER( one_in_one_out ), /* Size of arg list */ + one_in_one_out /* Arg list */ +}; + +/* Call im_clip2d via arg vector. + */ +static int +clip2d_vec( im_object *argv ) +{ + return( im_clip2d( argv[0], argv[1] ) ); +} + +/* Description of im_clip2d. + */ +static im_function clip2d_desc = { + "im_clip2d", /* Name */ + "convert to double-precision float", + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + clip2d_vec, /* Dispatch function */ + IM_NUMBER( one_in_one_out ), /* Size of arg list */ + one_in_one_out /* Arg list */ +}; + +/* Call im_clip2f via arg vector. + */ +static int +clip2f_vec( im_object *argv ) +{ + return( im_clip2f( argv[0], argv[1] ) ); +} + +/* Description of im_clip2f. + */ +static im_function clip2f_desc = { + "im_clip2f", /* Name */ + "convert to single-precision float", + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + clip2f_vec, /* Dispatch function */ + IM_NUMBER( one_in_one_out ), /* Size of arg list */ + one_in_one_out /* Arg list */ +}; + +/* Call im_clip2c via arg vector. + */ +static int +clip2c_vec( im_object *argv ) +{ + return( im_clip2c( argv[0], argv[1] ) ); +} + +/* Description of im_clip2c. + */ +static im_function clip2c_desc = { + "im_clip2c", /* Name */ + "convert to signed 8-bit integer", + IM_FN_PTOP | IM_FN_PIO, /* Flags */ + clip2c_vec, /* Dispatch function */ + IM_NUMBER( one_in_one_out ), /* Size of arg list */ + one_in_one_out /* Arg list */ +}; + +/* Args to im_thresh. + */ +static im_arg_desc thresh_args[] = { + IM_INPUT_IMAGE( "input" ), + IM_OUTPUT_IMAGE( "output" ), + IM_INPUT_DOUBLE( "threshold" ) +}; + +/* Call im_thresh via arg vector. + */ +static int +thresh_vec( im_object *argv ) +{ + double t1 = *((double *) argv[2]); + + return( im_thresh( argv[0], argv[1], t1 ) ); +} + +/* Description of im_thresh. + */ +static im_function thresh_desc = { + "im_thresh", /* Name */ + "slice an image at a threshold", + 0, /* Flags */ + thresh_vec, /* Dispatch function */ + IM_NUMBER( thresh_args ), /* Size of arg list */ + thresh_args /* Arg list */ +}; + +/* Args to im_slice. + */ +static im_arg_desc slice_args[] = { + IM_INPUT_IMAGE( "input" ), + IM_OUTPUT_IMAGE( "output" ), + IM_INPUT_DOUBLE( "thresh1" ), + IM_INPUT_DOUBLE( "thresh2" ) +}; + +/* Call im_slice via arg vector. + */ +static int +slice_vec( im_object *argv ) +{ + double t1 = *((double *) argv[2]); + double t2 = *((double *) argv[3]); + + return( im_slice( argv[0], argv[1], t1, t2 ) ); +} + +/* Description of im_slice. + */ +static im_function slice_desc = { + "im_slice", /* Name */ + "slice an image using two thresholds", + 0, /* Flags */ + slice_vec, /* Dispatch function */ + IM_NUMBER( slice_args ), /* Size of arg list */ + slice_args /* Arg list */ +}; + + /* Package up all these functions. */ static im_function *deprecated_list[] = { @@ -364,6 +630,18 @@ static im_function *deprecated_list[] = { &icc_export_desc, &litecor_desc, &affine_desc, + &clip2c_desc, + &clip2cm_desc, + &clip2d_desc, + &clip2dcm_desc, + &clip2f_desc, + &clip2i_desc, + &clip2s_desc, + &clip2ui_desc, + &clip2us_desc, + &print_desc, + &slice_desc, + &thresh_desc, &similarity_area_desc, &similarity_desc }; diff --git a/libvips/freq_filt/im_fwfft.c b/libvips/freq_filt/im_fwfft.c index 2f568e13..a806ea98 100644 --- a/libvips/freq_filt/im_fwfft.c +++ b/libvips/freq_filt/im_fwfft.c @@ -113,7 +113,7 @@ rfwfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) im_error( "im_fwfft", _( "one band uncoded only" ) ); return( -1 ); } - if( im_clip2d( in, real ) ) + if( im_clip2fmt( in, real, IM_BANDFMT_DOUBLE ) ) return( -1 ); /* Make the plan for the transform. Yes, they really do use nx for @@ -218,7 +218,7 @@ cfwfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) im_error( "im_fwfft", _( "one band uncoded only" ) ); return( -1 ); } - if( im_clip2dcm( in, cmplx ) ) + if( im_clip2fmt( in, cmplx, IM_BANDFMT_DPCOMPLEX ) ) return( -1 ); /* Make the plan for the transform. @@ -309,7 +309,7 @@ rfwfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) im_error( "im_fwfft", "%s", _( "one band uncoded only" ) ); return( -1 ); } - if( im_clip2d( in, real ) ) + if( im_clip2fmt( in, real, IM_BANDFMT_DOUBLE ) ) return( -1 ); /* Make the plan for the transform. Yes, they really do use nx for @@ -423,7 +423,7 @@ cfwfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) "%s", _( "one band uncoded only" ) ); return( -1 ); } - if( im_clip2dcm( in, cmplx ) ) + if( im_clip2fmt( in, cmplx, IM_BANDFMT_DPCOMPLEX ) ) return( -1 ); /* Make the plan for the transform. @@ -523,14 +523,14 @@ fwfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) /* Make sure we have a float input image. */ - if( im_clip2f( in, real ) ) + if( im_clip2fmt( in, real, IM_BANDFMT_FLOAT ) ) return( -1 ); /* Make a buffer of 0 floats of the same size for the imaginary part. */ if( im_black( t1, in->Xsize, in->Ysize, 1 ) ) return( -1 ); - if( im_clip2f( t1, imag ) ) + if( im_clip2fmt( t1, imag, IM_BANDFMT_FLOAT ) ) return( -1 ); /* Transform! diff --git a/libvips/freq_filt/im_invfft.c b/libvips/freq_filt/im_invfft.c index 4b773859..bba480d0 100644 --- a/libvips/freq_filt/im_invfft.c +++ b/libvips/freq_filt/im_invfft.c @@ -95,7 +95,7 @@ invfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) im_error( "im_invfft", "%s", _( "one band uncoded only" ) ); return( -1 ); } - if( im_clip2dcm( in, cmplx ) ) + if( im_clip2fmt( in, cmplx, IM_BANDFMT_DPCOMPLEX ) ) return( -1 ); /* Make the plan for the transform. Yes, they really do use nx for @@ -145,7 +145,7 @@ invfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) "%s", _( "one band uncoded only" ) ); return( -1 ); } - if( im_clip2dcm( in, cmplx ) ) + if( im_clip2fmt( in, cmplx, IM_BANDFMT_DPCOMPLEX ) ) return( -1 ); /* Make the plan for the transform. Yes, they really do use nx for @@ -212,7 +212,7 @@ invfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) /* Make sure we have a single-precision complex input image. */ - if( im_clip2cm( in, t1 ) ) + if( im_clip2fmt( in, t1, IM_BANDFMT_COMPLEX ) ) return( -1 ); /* Extract real and imag parts. We have to complement the imaginary. diff --git a/libvips/freq_filt/im_invfftr.c b/libvips/freq_filt/im_invfftr.c index 314bbf5f..4d984abb 100644 --- a/libvips/freq_filt/im_invfftr.c +++ b/libvips/freq_filt/im_invfftr.c @@ -93,7 +93,7 @@ invfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) /* Make dp complex image for input. */ - if( im_clip2dcm( in, cmplx ) ) + if( im_clip2fmt( in, cmplx, IM_BANDFMT_DPCOMPLEX ) ) return( -1 ); /* Make mem buffer real image for output. @@ -176,7 +176,7 @@ invfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) /* Make dp complex image for input. */ - if( im_clip2dcm( in, cmplx ) ) + if( im_clip2fmt( in, cmplx, IM_BANDFMT_DPCOMPLEX ) ) return( -1 ); /* Make mem buffer real image for output. @@ -264,7 +264,7 @@ invfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) /* Make sure we have a single-precision complex input image. */ - if( im_clip2cm( in, t1 ) ) + if( im_clip2fmt( in, t1, IM_BANDFMT_COMPLEX ) ) return( -1 ); /* Extract real and imag parts. We have to complement the imaginary. diff --git a/libvips/histograms_lut/im_histspec.c b/libvips/histograms_lut/im_histspec.c index a15960c8..e27fecbb 100644 --- a/libvips/histograms_lut/im_histspec.c +++ b/libvips/histograms_lut/im_histspec.c @@ -175,18 +175,13 @@ match( IMAGE *in, IMAGE *ref, IMAGE *out ) int im_histspec( IMAGE *in, IMAGE *ref, IMAGE *out ) { - IMAGE *t1 = im_open_local( out, "im_histspec:1", "p" ); - IMAGE *t2 = im_open_local( out, "im_histspec:2", "p" ); - IMAGE *t3 = im_open_local( out, "im_histspec:3", "p" ); - IMAGE *t4 = im_open_local( out, "im_histspec:4", "p" ); - IMAGE *t5 = im_open_local( out, "im_histspec:5", "p" ); - + IMAGE *t[5]; int px; int fmt; - if( !t1 || !t2 || !t2 || !t4 || !t5 ) + if( im_open_local_array( out, t, 5, "im_histspec", "p" ) ) return( -1 ); - if( !im_isuint( in ) || !im_isuint( ref ) ) { + if( !im_isuint( in ) || !im_isuint( ref ) ) { im_error( "im_histspec", "%s", _( "input luts are not some unsigned integer type" ) ); return( -1 ); @@ -194,14 +189,16 @@ im_histspec( IMAGE *in, IMAGE *ref, IMAGE *out ) /* Match hists. */ - if( im_histeq( in, t1 ) || im_clip2ui( t1, t2 ) || - im_histeq( ref, t3 ) || im_clip2ui( t3, t4 ) || - match( t2, t4, t5 ) ) + if( im_histeq( in, t[0] ) || + im_clip2fmt( t[0], t[1], IM_BANDFMT_UINT ) || + im_histeq( ref, t[2] ) || + im_clip2fmt( t[2], t[3], IM_BANDFMT_UINT ) || + match( t[1], t[3], t[4] ) ) return( -1 ); /* Clip type down. */ - px = t5->Xsize * t5->Ysize; + px = t[4]->Xsize * t[4]->Ysize; if( px <= 256 ) fmt = IM_BANDFMT_UCHAR; else if( px <= 65536 ) @@ -209,7 +206,7 @@ im_histspec( IMAGE *in, IMAGE *ref, IMAGE *out ) else fmt = IM_BANDFMT_UINT; - if( im_clip2fmt( t5, out, fmt ) ) + if( im_clip2fmt( t[4], out, fmt ) ) return( -1 ); return( 0 ); diff --git a/libvips/histograms_lut/tone.c b/libvips/histograms_lut/tone.c index b445324a..b477b4a0 100644 --- a/libvips/histograms_lut/tone.c +++ b/libvips/histograms_lut/tone.c @@ -324,7 +324,7 @@ im_tone_build( IMAGE *out, if( !t1 || im_tone_build_range( t1, 1023, 32767, Lb, Lw, Ps, Pm, Ph, S, M, H ) || - im_clip2s( t1, out ) ) + im_clip2fmt( t1, out, IM_BANDFMT_SHORT ) ) return( -1 ); return( 0 ); @@ -434,7 +434,7 @@ im_tone_map( IMAGE *in, IMAGE *out, IMAGE *lut ) * sure we have an unsigned type we can use for indexing. */ if( im_shiftright( t2, t8, 5 ) || - im_clip2us( t8, t5 ) ) + im_clip2fmt( t8, t5, IM_BANDFMT_USHORT ) ) return( -1 ); /* Replace L. @@ -503,7 +503,7 @@ im_tone_analyse( */ if( im_extract_band( t1, t2, 0 ) || im_shiftright( t2, t3, 5 ) || - im_clip2us( t3, t4 ) ) + im_clip2fmt( t3, t4, IM_BANDFMT_USHORT ) ) return( -1 ); /* Take histogram, and make it a cumulative hist. diff --git a/libvips/include/vips/Makefile.am b/libvips/include/vips/Makefile.am index ab20c8d7..94d4b0b4 100644 --- a/libvips/include/vips/Makefile.am +++ b/libvips/include/vips/Makefile.am @@ -18,6 +18,7 @@ pkginclude_HEADERS = \ proto.h \ image.h \ vips \ + conversion.h \ rect.h \ region.h \ generate.h \ diff --git a/libvips/include/vips/colour.h b/libvips/include/vips/colour.h index 584cf17f..8d975e7d 100644 --- a/libvips/include/vips/colour.h +++ b/libvips/include/vips/colour.h @@ -42,8 +42,6 @@ extern "C" { #endif /*__cplusplus*/ -#include - /* Areas under curves for Dxx. 2 degree observer. */ #define IM_D93_X0 (89.7400) diff --git a/libvips/include/vips/conversion.h b/libvips/include/vips/conversion.h new file mode 100644 index 00000000..06d3b75c --- /dev/null +++ b/libvips/include/vips/conversion.h @@ -0,0 +1,118 @@ +/* conversion.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_CONVERSION_H +#define IM_CONVERSION_H + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus*/ + +/* Copy and swap types. + */ +typedef enum { + IM_ARCH_NATIVE, + IM_ARCH_BYTE_SWAPPED, + IM_ARCH_LSB_FIRST, + IM_ARCH_MSB_FIRST +} im_arch_type; + +gboolean im_isnative( im_arch_type arch ); + +DOUBLEMASK *im_vips2mask( IMAGE *in, const char *out ); +int im_mask2vips( DOUBLEMASK *in, IMAGE *out ); + +int im_copy_set( IMAGE *in, IMAGE *out, + int type, float xres, float yres, int x, int y ); +int im_copy_set_meta( IMAGE *in, IMAGE *out, const char *field, GValue *meta ); +int im_copy_morph( IMAGE *in, IMAGE *out, + int Bands, int BandFmt, int Coding ); +int im_copy( IMAGE *in, IMAGE *out ); +int im_copy_swap( IMAGE *in, IMAGE *out ); +int im_copy_from( IMAGE *in, IMAGE *out, im_arch_type architecture ); +int im_copy_file( IMAGE *in, IMAGE *out ); + +int im_extract_band( IMAGE *in, IMAGE *out, int band ); +int im_extract_bands( IMAGE *in, IMAGE *out, int band, int nbands ); +int im_extract_area( IMAGE *in, IMAGE *out, int x, int y, int w, int h ); +int im_extract_areabands( IMAGE *in, IMAGE *out, + int left, int top, int width, int height, int band, int nbands ); + +int im_subsample( IMAGE *in, IMAGE *out, int x, int y ); +int im_zoom( IMAGE *in, IMAGE *out, int x, int y ); + +int im_bandjoin( IMAGE *in, IMAGE *out, IMAGE * ); +int im_gbandjoin( IMAGE **in, IMAGE *out, int ); + +int im_black( IMAGE *out, int, int, int ); +int im_text( IMAGE *out, const char *text, const char *font, + int width, int alignment, int dpi ); + +int im_clip2fmt( IMAGE *in, IMAGE *out, int ofmt ); +int im_scale( IMAGE *in, IMAGE *out ); +int im_clip( IMAGE *in, IMAGE *out ); +int im_msb( IMAGE *in, IMAGE *out ); +int im_msb_band( IMAGE *in, IMAGE *out, int band ); + +int im_c2amph( IMAGE *in, IMAGE *out ); +int im_c2rect( IMAGE *in, IMAGE *out ); +int im_ri2c( IMAGE *real_in, IMAGE *imag_in, IMAGE *out ); +int im_c2imag( IMAGE *in, IMAGE *out ); +int im_c2real( IMAGE *in, IMAGE *out ); +int im_c2ps( IMAGE *in, IMAGE *out ); +int im_scaleps( IMAGE *in, IMAGE *out ); + +int im_falsecolour( IMAGE *in, IMAGE *out ); + +int im_recomb( IMAGE *in, IMAGE *out, DOUBLEMASK *recomb ); + +int im_insert( IMAGE *in, IMAGE *out, IMAGE *, int x, int y ); +int im_insert_noexpand( IMAGE *in, IMAGE *out, IMAGE *, int x, int y ); +int im_lrjoin( IMAGE *in1, IMAGE *in2, IMAGE *out ); +int im_tbjoin( IMAGE *in1, IMAGE *in2, IMAGE *out ); +int im_replicate( IMAGE *in, IMAGE *out, int across, int down ); +int im_grid( IMAGE *in, IMAGE *out, int tile_height, int across, int down ); +int im_wrap( IMAGE *in, IMAGE *out, int x, int y ); + +int im_fliphor( IMAGE *in, IMAGE *out ); +int im_flipver( IMAGE *in, IMAGE *out ); +int im_rot90( IMAGE *in, IMAGE *out ); +int im_rot180( IMAGE *in, IMAGE *out ); +int im_rot270( IMAGE *in, IMAGE *out ); + +int im_system( IMAGE *im, const char *cmd, char **out ); + +#ifdef __cplusplus +} +#endif /*__cplusplus*/ + +#endif /*IM_CONVERSION_H*/ diff --git a/libvips/include/vips/deprecated.h b/libvips/include/vips/deprecated.h index 67381a50..a3cfd093 100644 --- a/libvips/include/vips/deprecated.h +++ b/libvips/include/vips/deprecated.h @@ -326,6 +326,23 @@ int im_similarity_area( IMAGE *in, IMAGE *out, int im_icc_export( IMAGE *in, IMAGE *out, const char *output_profile_filename, VipsIntent intent ); +/* conversion + */ +int im_clip2dcm( IMAGE *in, IMAGE *out ); +int im_clip2cm( IMAGE *in, IMAGE *out ); +int im_clip2us( IMAGE *in, IMAGE *out ); +int im_clip2ui( IMAGE *in, IMAGE *out ); +int im_clip2s( IMAGE *in, IMAGE *out ); +int im_clip2i( IMAGE *in, IMAGE *out ); +int im_clip2d( IMAGE *in, IMAGE *out ); +int im_clip2f( IMAGE *in, IMAGE *out ); +int im_clip2c( IMAGE *in, IMAGE *out ); + +int im_slice( IMAGE *in, IMAGE *out, double, double ); +int im_thresh( IMAGE *in, IMAGE *out, double ); + +int im_print( const char *message ); + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/include/vips/format.h b/libvips/include/vips/format.h index 0d1b375f..d6e06fc7 100644 --- a/libvips/include/vips/format.h +++ b/libvips/include/vips/format.h @@ -117,6 +117,27 @@ VipsFormatFlags vips_format_get_flags( VipsFormatClass *format, int vips_format_read( const char *name, IMAGE *out ); int vips_format_write( IMAGE *im, const char *name ); +int im_jpeg2vips( const char *in, IMAGE * ); +int im_vips2jpeg( IMAGE *in, const char * ); +int im_vips2mimejpeg( IMAGE *in, int ); +int im_vips2bufjpeg( IMAGE *in, IMAGE *, int, char **, int * ); +int im_vips2tiff( IMAGE *in, const char * ); +int im_bernd( const char *in, int, int, int, int ); +int im_tiff2vips( const char *in, IMAGE * ); +int im_tile_cache( IMAGE *in, IMAGE *, int, int, int ); +int im_magick2vips( const char *in, IMAGE * ); +int im_png2vips( const char *in, IMAGE * ); +int im_exr2vips( const char *in, IMAGE * ); +int im_ppm2vips( const char *in, IMAGE * ); +int im_vips2ppm( IMAGE *in, const char * ); +int im_analyze2vips( const char *filename, IMAGE *out ); +int im_vips2csv( IMAGE *in, const char *filename ); +int im_csv2vips( const char *filename, IMAGE *out ); +int im_vips2png( IMAGE *, const char * ); +int im_raw2vips( const char *filename, IMAGE *out, + int width, int height, int bpp, int offset ); +int im_vips2raw( IMAGE *in, int fd ); + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/include/vips/proto.h b/libvips/include/vips/proto.h index b9a7ebbe..803c2d4a 100644 --- a/libvips/include/vips/proto.h +++ b/libvips/include/vips/proto.h @@ -205,101 +205,6 @@ int im_ismonotonic( IMAGE *lut, int *out ); int im_tone_map( IMAGE *in, IMAGE *out, IMAGE *lut ); int im_project( IMAGE *in, IMAGE *hout, IMAGE *vout ); -/* conversion - */ - -/* Copy and swap types. - */ -typedef enum { - IM_ARCH_NATIVE, - IM_ARCH_BYTE_SWAPPED, - IM_ARCH_LSB_FIRST, - IM_ARCH_MSB_FIRST -} im_arch_type; - -gboolean im_isnative( im_arch_type arch ); - -DOUBLEMASK *im_vips2mask( IMAGE *, const char * ); -int im_mask2vips( DOUBLEMASK *, IMAGE * ); -int im_copy_set( IMAGE *, IMAGE *, int, float, float, int, int ); -int im_copy_set_meta( IMAGE *in, IMAGE *out, const char *field, GValue *meta ); -int im_copy_morph( IMAGE *, IMAGE *, int, int, int ); -int im_copy( IMAGE *, IMAGE * ); -int im_copy_swap( IMAGE *in, IMAGE *out ); -int im_copy_from( IMAGE *in, IMAGE *out, im_arch_type architecture ); -int im_copy_file( IMAGE *in, IMAGE *out ); -int im_extract_band( IMAGE *in, IMAGE *out, int band ); -int im_extract_bands( IMAGE *in, IMAGE *out, int band, int nbands ); -int im_extract_area( IMAGE *in, IMAGE *out, int x, int y, int w, int h ); -int im_extract_areabands( IMAGE *in, IMAGE *out, - int left, int top, int width, int height, int band, int nbands ); -int im_subsample( IMAGE *, IMAGE *, int, int ); -int im_zoom( IMAGE *, IMAGE *, int, int ); -int im_bandjoin( IMAGE *, IMAGE *, IMAGE * ); -int im_gbandjoin( IMAGE **, IMAGE *, int ); -int im_black( IMAGE *, int, int, int ); -int im_text( IMAGE *out, const char *text, const char *font, - int width, int alignment, int dpi ); -int im_c2amph( IMAGE *, IMAGE * ); -int im_c2rect( IMAGE *, IMAGE * ); -int im_clip2fmt( IMAGE *in, IMAGE *out, int ofmt ); -int im_clip2dcm( IMAGE *, IMAGE * ); -int im_clip2cm( IMAGE *, IMAGE * ); -int im_clip2us( IMAGE *, IMAGE * ); -int im_clip2ui( IMAGE *, IMAGE * ); -int im_clip2s( IMAGE *, IMAGE * ); -int im_clip2i( IMAGE *, IMAGE * ); -int im_clip2d( IMAGE *, IMAGE * ); -int im_clip2f( IMAGE *, IMAGE * ); -int im_clip2c( IMAGE *, IMAGE * ); -int im_clip( IMAGE *, IMAGE * ); -int im_ri2c( IMAGE *, IMAGE *, IMAGE * ); -int im_c2imag( IMAGE *, IMAGE * ); -int im_c2real( IMAGE *, IMAGE * ); -int im_c2ps( IMAGE *, IMAGE * ); -int im_fliphor( IMAGE *, IMAGE * ); -int im_flipver( IMAGE *, IMAGE * ); -int im_falsecolour( IMAGE *, IMAGE * ); -int im_recomb( IMAGE *, IMAGE *, DOUBLEMASK * ); -int im_insert( IMAGE *, IMAGE *, IMAGE *, int, int ); -int im_insert_noexpand( IMAGE *, IMAGE *, IMAGE *, int, int ); -int im_rot90( IMAGE *, IMAGE * ); -int im_rot180( IMAGE *, IMAGE * ); -int im_rot270( IMAGE *, IMAGE * ); -int im_lrjoin( IMAGE *, IMAGE *, IMAGE * ); -int im_tbjoin( IMAGE *, IMAGE *, IMAGE * ); -int im_scale( IMAGE *, IMAGE * ); -int im_scaleps( IMAGE *, IMAGE * ); -int im_slice( IMAGE *, IMAGE *, double, double ); -int im_system( IMAGE *im, const char *cmd, char **out ); -int im_print( const char *message ); -int im_thresh( IMAGE *, IMAGE *, double ); -int im_jpeg2vips( const char *, IMAGE * ); -int im_vips2jpeg( IMAGE *, const char * ); -int im_vips2mimejpeg( IMAGE *, int ); -int im_vips2bufjpeg( IMAGE *, IMAGE *, int, char **, int * ); -int im_vips2tiff( IMAGE *, const char * ); -int im_bernd( const char *, int, int, int, int ); -int im_tiff2vips( const char *, IMAGE * ); -int im_tile_cache( IMAGE *, IMAGE *, int, int, int ); -int im_magick2vips( const char *, IMAGE * ); -int im_png2vips( const char *, IMAGE * ); -int im_exr2vips( const char *, IMAGE * ); -int im_ppm2vips( const char *, IMAGE * ); -int im_vips2ppm( IMAGE *, const char * ); -int im_analyze2vips( const char *filename, IMAGE *out ); -int im_vips2csv( IMAGE *in, const char *filename ); -int im_csv2vips( const char *filename, IMAGE *out ); -int im_vips2png( IMAGE *, const char * ); -int im_raw2vips( const char *filename, IMAGE *out, - int width, int height, int bpp, int offset ); -int im_replicate( IMAGE *in, IMAGE *out, int across, int down ); -int im_grid( IMAGE *in, IMAGE *out, int tile_height, int across, int down ); -int im_msb ( IMAGE * in, IMAGE * out ); -int im_msb_band ( IMAGE * in, IMAGE * out, int band ); -int im_wrap( IMAGE *in, IMAGE *out, int x, int y ); -int im_vips2raw( IMAGE *in, int fd ); - /* other */ int im_feye( IMAGE *image, diff --git a/libvips/include/vips/vips.h b/libvips/include/vips/vips.h index ac561ff4..30d33baa 100644 --- a/libvips/include/vips/vips.h +++ b/libvips/include/vips/vips.h @@ -128,8 +128,6 @@ typedef struct im__DOUBLEMASK { #include #include #include -#include -#include #include #include #include @@ -146,6 +144,9 @@ typedef struct im__DOUBLEMASK { #include #include #include +#include +#include +#include #ifdef IM_ENABLE_DEPRECATED #include diff --git a/libvips/mosaicing/global_balance.c b/libvips/mosaicing/global_balance.c index 6d47ba16..51d7a22c 100644 --- a/libvips/mosaicing/global_balance.c +++ b/libvips/mosaicing/global_balance.c @@ -1622,13 +1622,13 @@ transform( JoinNode *node, double *gamma ) double fac = st->fac[node->index]; IMAGE *out = im_open_local( st->im, node->name, "p" ); + IMAGE *t1 = im_open_local( out, "transform:1", "p" ); IMAGE *t2 = im_open_local( out, "transform:2", "p" ); IMAGE *t3 = im_open_local( out, "transform:3", "p" ); IMAGE *t4 = im_open_local( out, "transform:4", "p" ); IMAGE *t5 = im_open_local( out, "transform:5", "p" ); - if( !out || !t1 || !t2 || !t3 || !t4 || !t5 ) return( NULL ); @@ -1639,7 +1639,7 @@ transform( JoinNode *node, double *gamma ) } else if( in->BandFmt == IM_BANDFMT_UCHAR ) { if( im_identity( t1, 1 ) || - im_powtra( t1, t2, 1/(*gamma) ) || + im_powtra( t1, t2, 1.0 / (*gamma) ) || im_lintra( fac, t2, 0.0, t3 ) || im_powtra( t3, t4, *gamma ) || im_clip( t4, t5 ) || @@ -1648,10 +1648,10 @@ transform( JoinNode *node, double *gamma ) } else if( in->BandFmt == IM_BANDFMT_USHORT ) { if( im_identity_ushort( t1, 1, 65535 ) || - im_powtra( t1, t2, 1/(*gamma) ) || + im_powtra( t1, t2, 1.0 / (*gamma) ) || im_lintra( fac, t2, 0.0, t3 ) || im_powtra( t3, t4, *gamma ) || - im_clip2us( t4, t5 ) || + im_clip2fmt( t4, t5, IM_BANDFMT_USHORT ) || im_maplut( in, out, t5 ) ) return( NULL ); } diff --git a/tools/other/squares.c b/tools/other/squares.c index b8529115..62c42f81 100644 --- a/tools/other/squares.c +++ b/tools/other/squares.c @@ -44,6 +44,7 @@ #include #include +#include int main( int argc, char **argv )