added cimg to vips trunk

This commit is contained in:
John Cupitt 2007-10-19 17:14:25 +00:00
parent b824e03d10
commit 36f7ed76b5
31 changed files with 224 additions and 143 deletions

View File

@ -1,6 +1,8 @@
28/9/07 started 7.13.1
- vips2dj can print RGB images
- oop, include <stdexcept> missing
- add protos for generate/iterate function args, started fixing warnings
- add cimg package
29/8/07 started 7.13.0
- we now have a trunk and the version is 7.13.x, woo!

2
TODO
View File

@ -1,3 +1,5 @@
- test maxpos_avg, quite a few changes
Python binding
==============

View File

@ -326,6 +326,7 @@ AC_OUTPUT([
libsrc/acquire/Makefile
libsrc/arithmetic/Makefile
libsrc/boolean/Makefile
libsrc/cimg/Makefile
libsrc/colour/Makefile
libsrc/conversion/Makefile
libsrc/convolution/Makefile

View File

@ -4,6 +4,10 @@
#ifndef IM_VIPS_INTL_H
#define IM_VIPS_INTL_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
const char *im__gettext( const char *msgid );
const char *im__ngettext( const char *msgid,
const char *plural, unsigned long int n );
@ -39,6 +43,10 @@ const char *im__ngettext( const char *msgid,
#endif /* ENABLE_NLS */
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /* IM_VIPS_INTL_H */

View File

@ -358,6 +358,13 @@ 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,
int iterations, float amplitude, float sharpness, float anisotropy,
float alpha, float sigma, float dl, float da, float gauss_prec,
int interpolation, int fast_approx );
/* histogram
*/
int im_maplut( IMAGE *, IMAGE *, IMAGE * );

View File

@ -141,28 +141,30 @@ int im_region_position( REGION *reg1, int x, int y );
typedef int (*im_region_fill_fn)( REGION *, void * );
int im_region_fill( REGION *reg, Rect *r, im_region_fill_fn fn, void *a );
/* IMAGE functions which use regions. We do not strictly type the function
* arguments to avoid hassle.
/* IMAGE functions which use regions.
*/
typedef void *(*im_start_fn)( IMAGE *, void *, void * );
typedef int (*im_generate_fn)( REGION *, void *, void *, void *);
typedef int (*im_stop_fn)( void *, void *, void * );
int im_prepare( REGION *reg, Rect *r );
int im_prepare_many( REGION **reg, Rect *r );
int im_prepare_to( REGION *reg, REGION *dest, Rect *r, int x, int y );
int im_generate( IMAGE *im,
void *(*start_fn)(), int (*gen_fn)(), int (*stop_fn)(),
im_start_fn start, im_generate_fn generate, im_stop_fn stop,
void *a, void *b
);
int im_iterate( IMAGE *im,
void *(*start_fn)(), int (*scan_fn)(), int (*stop_fn)(),
im_start_fn start, im_generate_fn generate, im_stop_fn stop,
void *a, void *b
);
void im__copy_region( REGION *reg, REGION *dest, Rect *r, int x, int y );
/* Convenience functions for im_generate()/im_iterate().
*/
void *im_start_one( IMAGE *out, IMAGE *in, void *dummy );
int im_stop_one( REGION *reg, void *dummy1, void *dummy2 );
void *im_start_many( IMAGE *out, IMAGE **in, void *dummy );
int im_stop_many( REGION **out, void *dummy1, void *dummy2 );
void *im_start_one( IMAGE *out, void *in, void *dummy );
int im_stop_one( void *seq, void *dummy1, void *dummy2 );
void *im_start_many( IMAGE *out, void *in, void *dummy );
int im_stop_many( void *seq, void *dummy1, void *dummy2 );
IMAGE **im_allocate_input_array( IMAGE *out, ... );
int im_demand_hint( IMAGE *im, im_demand_type hint, ... )
__attribute__((sentinel));

View File

@ -6,6 +6,7 @@ SUBDIRS = \
colour \
conversion \
convolution \
cimg \
freq_filt \
histograms_lut \
inplace \
@ -30,6 +31,7 @@ libvips_la_LIBADD = \
colour/libcolour.la \
conversion/libconversion.la \
convolution/libconvolution.la \
cimg/libcimg.la \
freq_filt/libfreq_filt.la \
histograms_lut/libhistograms_lut.la \
inplace/libinplace.la \

View File

@ -82,7 +82,7 @@
* sum.
*/
static void *
start_fn( IMAGE *out )
start_fn( IMAGE *out, void *a, void *b )
{
double *tmp;
@ -96,8 +96,11 @@ start_fn( IMAGE *out )
/* Stop function. Add this little sum to the main sum.
*/
static int
stop_fn( double *tmp, double *sum )
stop_fn( void *seq, void *a, void *b )
{
double *tmp = (double *) seq;
double *sum = (double *) a;
*sum += *tmp;
return( 0 );
@ -106,8 +109,9 @@ stop_fn( double *tmp, double *sum )
/* Loop over region, accumulating a sum in *tmp.
*/
static int
scan_fn( REGION *reg, double *tmp )
scan_fn( REGION *reg, void *seq, void *a, void *b )
{
double *tmp = (double *) seq;
Rect *r = &reg->valid;
IMAGE *im = reg->im;
int le = r->left;

View File

@ -83,7 +83,7 @@
* accumulate the sum and the sum of squares.
*/
static void *
start_fn( IMAGE *out )
start_fn( IMAGE *out, void *a, void *b )
{
double *tmp;
@ -98,8 +98,11 @@ start_fn( IMAGE *out )
/* Stop function. Add this little sum to the main sum.
*/
static int
stop_fn( double *tmp, double *sum )
stop_fn( void *seq, void *a, void *b )
{
double *tmp = (double *) seq;
double *sum = (double *) a;
sum[0] += tmp[0];
sum[1] += tmp[1];
@ -109,8 +112,9 @@ stop_fn( double *tmp, double *sum )
/* Loop over region, adding information to the appropriate fields of tmp.
*/
static int
scan_fn( REGION *reg, double *tmp )
scan_fn( REGION *reg, void *seq, void *a, void *b )
{
double *tmp = (double *) seq;
Rect *r = &reg->valid;
IMAGE *im = reg->im;
int le = r->left;

View File

@ -66,8 +66,10 @@
* invert_gen(), or points to the memory we should write to and ir is blank.
*/
static int
invert_gen( REGION *or, REGION *ir, IMAGE *in )
invert_gen( REGION *or, void *seq, void *a, void *b )
{
REGION *ir = (REGION *) seq;
/* Left, right, top and bottom for the output region.
*/
int le = or->valid.left;

View File

@ -91,9 +91,9 @@ LINREG_SEQ( double );
x_set *x_anal( IMAGE *im, double *xs, unsigned int n );
#define LINREG_START_DECL( TYPE ) static linreg_seq_ ## TYPE *linreg_start_ ## TYPE( IMAGE *out, IMAGE **ins, x_set *x_vals )
#define LINREG_GEN_DECL( TYPE ) static int linreg_gen_ ## TYPE( REGION *to_make, linreg_seq_ ## TYPE *seq, void *unrequired, x_set *x_vals )
#define LINREG_STOP_DECL( TYPE ) static int linreg_stop_ ## TYPE( linreg_seq_ ## TYPE *seq )
#define LINREG_START_DECL( TYPE ) static void * linreg_start_ ## TYPE( IMAGE *, void *, void * );
#define LINREG_GEN_DECL( TYPE ) static int linreg_gen_ ## TYPE( REGION *, void *, void *, void * );
#define LINREG_STOP_DECL( TYPE ) static int linreg_stop_ ## TYPE( void *, void *, void * );
#define INCR_ALL_DECL( TYPE ) static void incr_all_ ## TYPE( TYPE **ptrs, unsigned int n )
#define SKIP_ALL_DECL( TYPE ) static void skip_all_ ## TYPE( TYPE **ptrs, size_t *skips, unsigned int n )
@ -211,7 +211,7 @@ int im_linreg( IMAGE **ins, IMAGE *out, double *xs ){
return( -1 );
switch( ins[ 0 ]-> BandFmt ){
#define LINREG_RET( TYPE ) return im_generate( out, (void*) linreg_start_ ## TYPE, linreg_gen_ ## TYPE, linreg_stop_ ## TYPE, ins, x_vals )
#define LINREG_RET( TYPE ) return im_generate( out, linreg_start_ ## TYPE, linreg_gen_ ## TYPE, linreg_stop_ ## TYPE, ins, x_vals )
case IM_BANDFMT_CHAR:
LINREG_RET( gint8 );
@ -279,24 +279,23 @@ x_set *x_anal( IMAGE *im, double *xs, unsigned int n ){
return( x_vals );
}
#define LINREG_START_DEFN( TYPE ) static linreg_seq_ ## TYPE *linreg_start_ ## TYPE( IMAGE *out, IMAGE **ins, x_set *x_vals ){ \
linreg_seq_ ## TYPE *seq= IM_NEW( NULL, linreg_seq_ ## TYPE ); \
#define LINREG_START_DEFN( TYPE ) static void *linreg_start_ ## TYPE( IMAGE *out, void *a, void *b ){ \
IMAGE **ins= (IMAGE **) a; \
x_set *x_vals= (x_set *) b; \
linreg_seq_ ## TYPE *seq= IM_NEW( out, linreg_seq_ ## TYPE ); \
\
if( ! seq ) \
return NULL; \
\
seq-> regs= im_start_many( NULL, ins, NULL ); \
seq-> ptrs= IM_ARRAY( NULL, x_vals-> n, TYPE* ); \
seq-> skips= IM_ARRAY( NULL, x_vals-> n, size_t ); \
seq-> ptrs= IM_ARRAY( out, x_vals-> n, TYPE* ); \
seq-> skips= IM_ARRAY( out, x_vals-> n, size_t ); \
\
if( ! seq-> ptrs || ! seq-> regs || ! seq-> skips ){ \
im_stop_many( seq-> regs, NULL, NULL ); \
im_free( seq-> ptrs ); \
im_free( seq-> skips ); \
im_free( seq ); \
linreg_stop_ ## TYPE( seq, NULL, NULL ); \
return NULL; \
} \
return seq; \
return (void *) seq; \
}
#define N ( (double) n )
@ -313,7 +312,9 @@ x_set *x_anal( IMAGE *im, double *xs, unsigned int n ){
#define d_dy_dx ( out[5] )
#define R ( out[6] )
#define LINREG_GEN_DEFN( TYPE ) static int linreg_gen_ ## TYPE( REGION *to_make, linreg_seq_ ## TYPE *seq, void *unrequired, x_set *x_vals ){ \
#define LINREG_GEN_DEFN( TYPE ) static int linreg_gen_ ## TYPE( REGION *to_make, void *vseq, void *unrequired, void *b ){ \
linreg_seq_ ## TYPE *seq= (linreg_seq_ ## TYPE *) vseq; \
x_set *x_vals= (x_set *) b; \
unsigned int n= x_vals-> n; \
double *out= (double*) IM_REGION_ADDR_TOPLEFT( to_make ); \
size_t out_skip= IM_REGION_LSKIP( to_make ) / sizeof( double ); \
@ -364,11 +365,10 @@ x_set *x_anal( IMAGE *im, double *xs, unsigned int n ){
return 0; \
}
#define LINREG_STOP_DEFN( TYPE ) static int linreg_stop_ ## TYPE( linreg_seq_ ## TYPE *seq ){ \
im_stop_many( seq-> regs, NULL, NULL ); \
im_free( seq-> ptrs ); \
im_free( seq-> skips ); \
im_free( seq ); \
#define LINREG_STOP_DEFN( TYPE ) static int linreg_stop_ ## TYPE( void *vseq, void *a, void *b ){ \
linreg_seq_ ## TYPE *seq = (linreg_seq_ ## TYPE *) vseq; \
if( seq-> regs ) \
im_stop_many( seq-> regs, NULL, NULL ); \
return 0; \
}

View File

@ -77,8 +77,9 @@
/* log10tra a small area.
*/
static int
log10tra_gen( REGION *or, REGION *ir )
log10tra_gen( REGION *or, void *seq, void *a, void *b )
{
REGION *ir = (REGION *) seq;
Rect *r = &or->valid;
int le = r->left;
int to = r->top;

View File

@ -77,8 +77,9 @@
/* logtra a small area.
*/
static int
logtra_gen( REGION *or, REGION *ir )
{
logtra_gen( REGION *or, void *seq, void *a, void *b )
{
REGION *ir = (REGION *) seq;
Rect *r = &or->valid;
int le = r->left;
int to = r->top;

View File

@ -23,6 +23,8 @@
* - partialed
* 3/4/02 JC
* - random wrong result for >1 thread :-( (thanks Joe)
* 15/10/07
* - oh, heh, seq->inf was not being set correctly, not that it mattered
*/
/*
@ -97,8 +99,9 @@ typedef struct _Seq {
/* New sequence value.
*/
static void *
start_fn( MaxInfo *inf )
max_start( IMAGE *in, void *a, void *b )
{
MaxInfo *inf = (MaxInfo *) a;
Seq *seq = IM_NEW( NULL, Seq );
seq->inf = inf;
@ -110,8 +113,11 @@ start_fn( MaxInfo *inf )
/* Merge the sequence value back into the per-call state.
*/
static int
stop_fn( Seq *seq, MaxInfo *inf )
max_stop( void *vseq, void *a, void *b )
{
Seq *seq = (Seq *) vseq;
MaxInfo *inf = (MaxInfo *) a;
if( seq->valid ) {
if( !inf->valid )
/* Just copy.
@ -133,8 +139,9 @@ stop_fn( Seq *seq, MaxInfo *inf )
/* Loop over region, adding to seq.
*/
static int
scan_fn( REGION *reg, Seq *seq )
max_scan( REGION *reg, void *vseq, void *a, void *b )
{
Seq *seq = (Seq *) vseq;
Rect *r = &reg->valid;
IMAGE *im = reg->im;
int le = r->left;
@ -233,7 +240,7 @@ im_max( IMAGE *in, double *out )
return( -1 );
}
if( im_iterate( in, start_fn, scan_fn, stop_fn, &inf, NULL ) )
if( im_iterate( in, max_start, max_scan, max_stop, &inf, NULL ) )
return( -1 );
*out = inf.value;

View File

@ -16,6 +16,10 @@
* Author: Tom Vajzovic
*
* Written on: 2006-09-25
* 15/10/07 JC
* - changed spelling of occurrences
* - check for !occurrences before using val
* - renamed avg as sum, a bit clearer
*/
/*
@ -62,30 +66,19 @@
/** LOCAL TYPES **/
typedef struct {
double x_avg;
double y_avg;
double x_sum;
double y_sum;
double val;
unsigned int occurances;
unsigned int occurrences;
} pos_avg_t;
/** LOCAL FUNCTIONS DECLARATIONS **/
static pos_avg_t *
maxpos_avg_start(
IMAGE *im
);
static int /* should be void (always returns 0) */
maxpos_avg_scan(
REGION *reg,
pos_avg_t *seq
);
static int
maxpos_avg_stop(
pos_avg_t *seq,
pos_avg_t *master
);
static void *maxpos_avg_start( IMAGE *im , void *, void * );
static int maxpos_avg_scan( REGION *reg, void *seq, void *, void * );
static int maxpos_avg_stop( void *seq, void *, void * );
/** EXPORTED FUNCTION **/
@ -114,35 +107,36 @@ int im_maxpos_avg( IMAGE *im, double *xpos, double *ypos, double *out ){
im_error( FUNCTION_NAME, _("invalid argument") );
return -1;
}
if( im_iterate( im, (void*)maxpos_avg_start, maxpos_avg_scan, maxpos_avg_stop, &master, NULL ) )
if( im_iterate( im, maxpos_avg_start, maxpos_avg_scan, maxpos_avg_stop, &master, NULL ) )
return -1;
*xpos= master. x_avg / master. occurances;
*ypos= master. y_avg / master. occurances;
*xpos= master. x_sum / master. occurrences;
*ypos= master. y_sum / master. occurrences;
return im_point_bilinear( im, *xpos, *ypos, 0, out );
#undef FUNCTION_NAME
}
static pos_avg_t *maxpos_avg_start( IMAGE *im ){
static void *maxpos_avg_start( IMAGE *im, void *a, void *b ){
pos_avg_t *seq;
seq= im_malloc( NULL, sizeof( pos_avg_t ) );
seq= IM_NEW( NULL, pos_avg_t );
if( ! seq )
return NULL;
seq-> x_avg= 0.0;
seq-> y_avg= 0.0;
seq-> x_sum= 0.0;
seq-> y_sum= 0.0;
seq-> val= 0.0;
seq-> occurances= 0;
seq-> occurrences= 0;
return seq;
return (void *) seq;
}
/* should be void (always returns 0) */
static int maxpos_avg_scan( REGION *reg, pos_avg_t *seq ){
static int maxpos_avg_scan( REGION *reg, void *vseq, void *a, void *b ) {
pos_avg_t *seq= (pos_avg_t *) vseq;
const int right= reg-> valid. left + reg-> valid. width;
const int bottom= reg-> valid. top + reg-> valid. height;
int x;
@ -154,16 +148,17 @@ static int maxpos_avg_scan( REGION *reg, pos_avg_t *seq ){
\
for( y= reg-> valid. top; y < bottom; ++y, read+= skip ) \
for( x= reg-> valid. left; x < right; ++x ) \
if( read[x] > seq-> val ){ \
if( !seq-> occurrences || \
read[x] > seq-> val ){ \
seq-> val= read[x]; \
seq-> x_avg= x; \
seq-> y_avg= y; \
seq-> occurances= 1; \
seq-> x_sum= x; \
seq-> y_sum= y; \
seq-> occurrences= 1; \
} \
else if( read[x] == seq-> val ){ \
seq-> x_avg+= x; \
seq-> y_avg+= y; \
++ (seq-> occurances); \
seq-> x_sum+= x; \
seq-> y_sum+= y; \
++ (seq-> occurrences); \
} \
}
@ -183,19 +178,24 @@ static int maxpos_avg_scan( REGION *reg, pos_avg_t *seq ){
}
/* should be void (always returns 0) */
static int maxpos_avg_stop( pos_avg_t *seq, pos_avg_t *master ){
static int maxpos_avg_stop( void *vseq, void *a, void *b ) {
if( seq-> val > master-> val ){
pos_avg_t *seq = (pos_avg_t *) vseq;
pos_avg_t *master = (pos_avg_t *) a;
if( !master->occurrences ||
seq-> val > master-> val ){
master-> val= seq-> val;
master-> x_avg= seq-> x_avg;
master-> y_avg= seq-> y_avg;
master-> occurances= seq-> occurances;
master-> x_sum= seq-> x_sum;
master-> y_sum= seq-> y_sum;
master-> occurrences= seq-> occurrences;
}
else if( seq-> val == master-> val ){
master-> x_avg+= seq-> x_avg;
master-> y_avg+= seq-> y_avg;
master-> occurances+= seq-> occurances;
master-> x_sum+= seq-> x_sum;
master-> y_sum+= seq-> y_sum;
master-> occurrences+= seq-> occurrences;
}
return im_free( seq );
im_free( seq );
return 0;
}

View File

@ -1,4 +1,4 @@
/* @(#) Find the coordinates and values of the maxima of an image.
/* @(#) Find the coordinates and values of the n maxima of an image.
* @(#)
* @(#) int im_maxpos_vec(
* @(#) IMAGE *im,
@ -8,7 +8,7 @@
* @(#) int n
* @(#) );
* @(#)
* @(#) Find the coordinates and values of the minima of an image.
* @(#) Find the coordinates and values of the n minima of an image.
* @(#)
* @(#) int im_minpos_vec(
* @(#) IMAGE *im,

View File

@ -100,14 +100,18 @@
/* Start and stop functions for one image in, input image is first user data.
*/
void *
im_start_one( IMAGE *out, IMAGE *in, void *dummy )
im_start_one( IMAGE *out, void *client, void *dummy )
{
IMAGE *in = (IMAGE *) client;
return( im_region_create( in ) );
}
int
im_stop_one( REGION *reg, void *dummy1, void *dummy2 )
im_stop_one( void *seq, void *dummy1, void *dummy2 )
{
REGION *reg = (REGION *) seq;
im_region_free( reg );
return( 0 );
@ -117,23 +121,26 @@ im_stop_one( REGION *reg, void *dummy1, void *dummy2 )
* null-terminated array of input images.
*/
int
im_stop_many( REGION **ar, void *dummy1, void *dummy2 )
im_stop_many( void *seq, void *dummy1, void *dummy2 )
{
int i;
REGION **ar = (REGION **) seq;
if( ! ar )
return 0;
if( ar ) {
int i;
for( i = 0; ar[i]; i++ )
im_region_free( ar[i] );
im_free( (char *) ar );
for( i = 0; ar[i]; i++ )
im_region_free( ar[i] );
im_free( (char *) ar );
}
return( 0 );
}
void *
im_start_many( IMAGE *out, IMAGE **in, void *dummy )
im_start_many( IMAGE *out, void *client, void *dummy )
{
IMAGE **in = (IMAGE **) client;
int i, n;
REGION **ar;
@ -704,7 +711,7 @@ eval_to_file( im_threadgroup_t *tg )
*/
int
im_generate( IMAGE *im,
void *(*start_fn)(), int (*gen_fn)(), int (*stop_fn)(),
im_start_fn start, im_generate_fn generate, im_stop_fn stop,
void *a, void *b )
{
int res;
@ -729,9 +736,9 @@ im_generate( IMAGE *im,
return( -1 );
}
im->start = start_fn;
im->generate = gen_fn;
im->stop = stop_fn;
im->start = start;
im->generate = generate;
im->stop = stop;
im->client1 = a;
im->client2 = b;
@ -759,9 +766,9 @@ im_generate( IMAGE *im,
/* Attach callbacks.
*/
im->start = start_fn;
im->generate = gen_fn;
im->stop = stop_fn;
im->start = start;
im->generate = generate;
im->stop = stop;
im->client1 = a;
im->client2 = b;

View File

@ -142,7 +142,8 @@ eval_to_image( im_threadgroup_t *tg, IMAGE *im )
static int
iterate( im_threadgroup_t *tg, IMAGE *im,
void *(*start)(), int (*generate)(), int (*stop)(), void *b, void *c )
im_start_fn start, im_generate_fn generate, im_stop_fn stop,
void *b, void *c )
{
int i;
int res;
@ -193,7 +194,8 @@ iterate( im_threadgroup_t *tg, IMAGE *im,
*/
int
im_iterate( IMAGE *im,
void *(*start)(), int (*generate)(), int (*stop)(), void *b, void *c )
im_start_fn start, im_generate_fn generate, im_stop_fn stop,
void *b, void *c )
{
IMAGE *t;
im_threadgroup_t *tg;

View File

@ -272,11 +272,12 @@ typedef struct _OpenLazy {
* on the new image.
*/
static void *
open_lazy_start( IMAGE *out, OpenLazy *lazy, void *dummy )
open_lazy_start( IMAGE *out, void *a, void *dummy )
{
OpenLazy *lazy = (OpenLazy *) a;
if( !lazy->lazy_im ) {
if( !(lazy->lazy_im = im_open_local( out,
"open_lazy_start", "p" )) ||
if( !(lazy->lazy_im = im_open_local( out, "olstart", "p" )) ||
lazy->read_pixels( lazy->filename, lazy->lazy_im ) ) {
IM_FREEF( im_close, lazy->lazy_im );
return( NULL );
@ -289,8 +290,10 @@ open_lazy_start( IMAGE *out, OpenLazy *lazy, void *dummy )
/* Just copy.
*/
static int
open_lazy_generate( REGION *or, REGION *ir )
open_lazy_generate( REGION *or, void *seq, void *a, void *b )
{
REGION *ir = (REGION *) seq;
Rect *r = &or->valid;
/* Ask for input we need.

View File

@ -999,8 +999,9 @@ tile_copy( Tile *tile, REGION *to )
/* Loop over the output region, filling with data from cache.
*/
static int
region_fill( REGION *out, void *seq, Render *render )
region_fill( REGION *out, void *seq, void *a, void *b )
{
Render *render = (Render *) a;
Rect *r = &out->valid;
int x, y;
@ -1078,8 +1079,9 @@ tile_paint_mask( Tile *tile, REGION *to )
/* The mask image is 255 .. 0 for the state of painted for each tile.
*/
static int
mask_fill( REGION *out, void *seq, Render *render )
mask_fill( REGION *out, void *seq, void *a, void *b )
{
Render *render = (Render *) a;
Rect *r = &out->valid;
int x, y;
@ -1154,10 +1156,12 @@ im_render_fade( IMAGE *in, IMAGE *out, IMAGE *mask,
printf( "im_render: max = %d, %p\n", max, render );
#endif /*DEBUG_MAKE*/
if( im_generate( out, NULL, region_fill, NULL, render, NULL ) )
if( im_generate( out, NULL, region_fill, NULL,
render, NULL ) )
return( -1 );
if( mask &&
im_generate( mask, NULL, mask_fill, NULL, render, NULL ) )
im_generate( mask, NULL, mask_fill, NULL,
render, NULL ) )
return( -1 );
return( 0 );

View File

@ -76,8 +76,11 @@ typedef struct {
/* Convert a REGION.
*/
static int
process_region( REGION *or, REGION **ir, IMAGE *im, UserBundle *bun )
process_region( REGION *or, void *seq, void *a, void *b )
{
REGION **ir = (REGION **) seq;
UserBundle *bun = (UserBundle *) b;
PEL *p[IM_MAX_INPUT_IMAGES], *q;
int i, y;

View File

@ -61,8 +61,11 @@ typedef struct {
/* Build or->valid a line at a time from ir.
*/
static int
process_region( REGION *or, REGION *ir, IMAGE *im, UserBundle *bun )
process_region( REGION *or, void *seq, void *a, void *b )
{
REGION *ir = (REGION *) seq;
UserBundle *bun = (UserBundle *) b;
PEL *p, *q;
int y;

View File

@ -54,6 +54,7 @@
/* Standard VIPS packages.
*/
extern im_package im__arithmetic;
extern im_package im__cimg;
extern im_package im__boolean;
extern im_package im__colour;
extern im_package im__conversion;
@ -396,6 +397,7 @@ static im_package im__iofuncs = {
static im_package *built_in[] = {
&im__arithmetic,
&im__boolean,
&im__cimg,
&im__colour,
&im__conversion,
&im__convolution,

View File

@ -433,8 +433,12 @@ invert_rect( Transformation *trn,
}
static int
affine_gen( REGION *or, REGION *ir, IMAGE *in, Transformation *trn )
affine_gen( REGION *or, void *seq, void *a, void *b )
{
REGION *ir = (REGION *) seq;
IMAGE *in = (IMAGE *) a;
Transformation *trn = (Transformation *) b;
/* Output area for this call.
*/
Rect *r = &or->valid;

View File

@ -219,7 +219,7 @@ find_first( REGION *ir, int *pos, int x, int y, int w )
case IM_BANDFMT_DPCOMPLEX:lsearch( double ); break;
default:
im_errormsg( "im_lrmerge: internal error" );
im_error( "im_lrmerge", _( "internal error" ) );
return( -1 );
}
@ -268,7 +268,7 @@ find_last( REGION *ir, int *pos, int x, int y, int w )
case IM_BANDFMT_DPCOMPLEX:rsearch( double ); break;
default:
im_errormsg( "im_lrmerge: internal error" );
im_error( "im_lrmerge", _( "internal error" ) );
return( -1 );
}
@ -609,7 +609,7 @@ lr_blend( REGION *or, MergeInfo *inf, Overlapping *ovlap, Rect *oreg )
fblend( double, im->Bands*2, pr, ps, q ); break;
default:
im_errormsg( "im_lrmerge: internal error" );
im_error( "im_lrmerge", _( "internal error" ) );
return( -1 );
}
}
@ -707,7 +707,7 @@ im__build_mergestate( IMAGE *ref, IMAGE *sec, IMAGE *out,
if( !ovlap )
return( NULL );
if( mwidth < -1 ) {
im_errormsg( "im_lr/tbmerge: mwidth must be -1 or >= 0" );
im_error( "im_lr/tbmerge", _( "mwidth must be -1 or >= 0" ) );
return( NULL );
}
@ -736,7 +736,7 @@ im__build_mergestate( IMAGE *ref, IMAGE *sec, IMAGE *out,
*/
im_rect_intersectrect( &ovlap->rarea, &ovlap->sarea, &ovlap->overlap );
if( im_rect_isempty( &ovlap->overlap ) ) {
im_errormsg( "im_lr/tbmerge: no overlap" );
im_error( "im_lr/tbmerge", _( "no overlap" ) );
return( NULL );
}
@ -806,7 +806,7 @@ build_lrstate( IMAGE *ref, IMAGE *sec, IMAGE *out, int dx, int dy, int mwidth )
break;
default:
im_errormsg( "im_lrmerge: unknown coding type" );
im_error( "im_lrmerge", _( "unknown coding type" ) );
return( NULL );
}
@ -823,7 +823,7 @@ build_lrstate( IMAGE *ref, IMAGE *sec, IMAGE *out, int dx, int dy, int mwidth )
*/
if( IM_RECT_RIGHT( &ovlap->rarea ) > IM_RECT_RIGHT( &ovlap->sarea ) ||
ovlap->rarea.left > ovlap->sarea.left ) {
im_errormsg( "im_lrmerge: too much overlap" );
im_error( "im_lrmerge", _( "too much overlap" ) );
return( NULL );
}
@ -905,8 +905,10 @@ im__black_region( REGION *reg )
* im_tbmerge().
*/
int
im__merge_gen( REGION *or, MergeInfo *inf, Overlapping *ovlap )
im__merge_gen( REGION *or, void *seq, void *a, void *b )
{
MergeInfo *inf = (MergeInfo *) seq;
Overlapping *ovlap = (Overlapping *) a;
Rect *r = &or->valid;
Rect rreg, sreg, oreg;
@ -973,8 +975,10 @@ im__merge_gen( REGION *or, MergeInfo *inf, Overlapping *ovlap )
* requirements quickly for large mosaics.
*/
int
im__stop_merge( MergeInfo *inf )
im__stop_merge( void *seq, void *a, void *b )
{
MergeInfo *inf = (MergeInfo *) seq;
if( inf->rir ) {
im_region_free( inf->rir );
inf->rir = NULL;
@ -1003,13 +1007,14 @@ im__stop_merge( MergeInfo *inf )
/* Start function. Shared with im_tbmerge().
*/
void *
im__start_merge( IMAGE *out, Overlapping *ovlap )
im__start_merge( IMAGE *out, void *a, void *b )
{
MergeInfo *inf = IM_NEW( NULL, MergeInfo );
Overlapping *ovlap = (Overlapping *) a;
MergeInfo *inf;
if( !inf )
if( !(inf = IM_NEW( NULL, MergeInfo )) )
return( NULL );
/* Clear all ptrs.
*/
inf->rir = NULL;
@ -1018,14 +1023,15 @@ im__start_merge( IMAGE *out, Overlapping *ovlap )
inf->from2 = NULL;
inf->merge = NULL;
/* If this is going to be a IM_CODING_LABQ, we need IM_CODING_LABQ blend buffers.
/* If this is going to be a IM_CODING_LABQ, we need IM_CODING_LABQ
* blend buffers.
*/
if( out->Coding == IM_CODING_LABQ ) {
inf->from1 = IM_ARRAY( NULL, ovlap->blsize * 3, float );
inf->from2 = IM_ARRAY( NULL, ovlap->blsize * 3, float );
inf->merge = IM_ARRAY( NULL, ovlap->blsize * 3, float );
if( !inf->from1 || !inf->from2 || !inf->merge ) {
im__stop_merge( inf );
im__stop_merge( inf, NULL, NULL );
return( NULL );
}
}
@ -1036,7 +1042,7 @@ im__start_merge( IMAGE *out, Overlapping *ovlap )
inf->sir = im_region_create( ovlap->sec );
if( !inf->rir || !inf->sir ) {
im__stop_merge( inf );
im__stop_merge( inf, NULL, NULL );
return( NULL );
}
@ -1061,11 +1067,12 @@ im__lrmerge( IMAGE *ref, IMAGE *sec, IMAGE *out, int dx, int dy, int mwidth )
if( ref->Bands != sec->Bands || ref->Bbits != sec->Bbits ||
ref->BandFmt != sec->BandFmt ||
ref->Coding != sec->Coding ) {
im_errormsg( "im_lrmerge: input images incompatible" );
im_error( "im_lrmerge", _( "input images incompatible" ) );
return( -1 );
}
if( ref->Coding != IM_CODING_NONE && ref->Coding != IM_CODING_LABQ ) {
im_errormsg( "im_lrmerge: inputs not uncoded or IM_CODING_LABQ" );
im_error( "im_lrmerge",
_( "inputs not uncoded or IM_CODING_LABQ" ) );
return( -1 );
}
if( dx > 0 || dx < 1 - ref->Xsize ) {

View File

@ -116,9 +116,9 @@ int im__attach_input( REGION *or, REGION *ir, Rect *area );
int im__copy_input( REGION *or, REGION *ir, Rect *area, Rect *reg );
Overlapping *im__build_mergestate( IMAGE *ref, IMAGE *sec, IMAGE *out,
int dx, int dy, int mwidth );
void *im__start_merge( IMAGE *out, Overlapping *ovlap );
int im__merge_gen( REGION *or, MergeInfo *inf, Overlapping *ovlap );
int im__stop_merge( MergeInfo *inf );
void *im__start_merge( IMAGE *out, void *, void * );
int im__merge_gen( REGION *or, void *seq, void *a, void * );
int im__stop_merge( void *seq, void *, void * );
void im__black_region( REGION *reg );
int im__extract_area( IMAGE *in, IMAGE *out,
int x, int y, int w, int h );

View File

@ -73,7 +73,7 @@
/* Generate function.
*/
static int
fgrey_gen( REGION *or )
fgrey_gen( REGION *or, void *seq, void *a, void *b )
{
Rect *r = &or->valid;
int le = r->left;

View File

@ -59,7 +59,7 @@
/* Generate function.
*/
static int
make_xy_gen( REGION *or )
make_xy_gen( REGION *or, void *seq, void *a, void *b )
{
Rect *r = &or->valid;
int le = r->left;

View File

@ -214,8 +214,9 @@ blendn_buffer( PEL *qp, PEL *c, PEL *ap, PEL *bp, int width, IMAGE *im )
}
static int
blend_gen( REGION *or, REGION **ir )
blend_gen( REGION *or, void *seq, void *a, void *b )
{
REGION **ir = (REGION **) seq;
Rect *r = &or->valid;
int le = r->left;
int to = r->top;

View File

@ -64,8 +64,9 @@
#endif /*WITH_DMALLOC*/
static int
ifthenelse_gen( REGION *or, REGION **ir )
ifthenelse_gen( REGION *or, void *seq, void *a, void *b )
{
REGION **ir = (REGION **) seq;
Rect *r = &or->valid;
int le = r->left;
int to = r->top;

View File

@ -82,7 +82,8 @@ REGION on this image and returns a pointer to the region as a sequence value.
.B im_stop_one(3)
assumes the sequence value is a REGION pointer, and frees it.
.B im_allocate_input_array(3) takes as arguments the output image and a list of
.B im_allocate_input_array(3)
takes as arguments the output image and a list of
input images, terminated with a NULL. It allocates a NULL-terminated array to
hold the images, and attaches a close callback to the output image to free
that array. Example: