1 /* rename.c --- wrappers for various renamed functions
2  *
3  * 20/9/09
4  */
5 
6 /*
7 
8     This file is part of VIPS.
9 
10     VIPS is free software; you can redistribute it and/or modify
11     it under the terms of the GNU Lesser General Public License as published by
12     the Free Software Foundation; either version 2 of the License, or
13     (at your option) any later version.
14 
15     This program is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18     GNU Lesser General Public License for more details.
19 
20     You should have received a copy of the GNU Lesser General Public License
21     along with this program; if not, write to the Free Software
22     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23     02110-1301  USA
24 
25  */
26 
27 /*
28 
29     These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
30 
31  */
32 
33 #ifdef HAVE_CONFIG_H
34 #include <config.h>
35 #endif /*HAVE_CONFIG_H*/
36 #include <vips/intl.h>
37 
38 #include <string.h>
39 
40 #include <vips/vips.h>
41 #include <vips/vips7compat.h>
42 #include <vips/internal.h>
43 
44 int
im_remainderconst_vec(IMAGE * in,IMAGE * out,int n,double * c)45 im_remainderconst_vec( IMAGE *in, IMAGE *out, int n, double *c )
46 {
47 	return( im_remainder_vec( in, out, n, c ) );
48 }
49 
50 int
im_and_vec(IMAGE * in,IMAGE * out,int n,double * c)51 im_and_vec( IMAGE *in, IMAGE *out, int n, double *c )
52 {
53 	return( im_andimage_vec( in, out, n, c ) );
54 }
55 
56 int
im_or_vec(IMAGE * in,IMAGE * out,int n,double * c)57 im_or_vec( IMAGE *in, IMAGE *out, int n, double *c )
58 {
59 	return( im_orimage_vec( in, out, n, c ) );
60 }
61 
62 int
im_eor_vec(IMAGE * in,IMAGE * out,int n,double * c)63 im_eor_vec( IMAGE *in, IMAGE *out, int n, double *c )
64 {
65 	return( im_eorimage_vec( in, out, n, c ) );
66 }
67 
68 int
im_andconst(IMAGE * in,IMAGE * out,double c)69 im_andconst( IMAGE *in, IMAGE *out, double c )
70 {
71 	return( im_andimageconst( in, out, c ) );
72 }
73 
74 int
im_orconst(IMAGE * in,IMAGE * out,double c)75 im_orconst( IMAGE *in, IMAGE *out, double c )
76 {
77 	return( im_orimageconst( in, out, c ) );
78 }
79 
80 int
im_eorconst(IMAGE * in,IMAGE * out,double c)81 im_eorconst( IMAGE *in, IMAGE *out, double c )
82 {
83 	return( im_eorimageconst( in, out, c ) );
84 }
85 
86 void
im_errormsg(const char * fmt,...)87 im_errormsg( const char *fmt, ... )
88 {
89 	va_list ap;
90 
91 	va_start( ap, fmt );
92 	im_verror( "untranslated", fmt, ap );
93 	va_end( ap );
94 }
95 
96 void
im_verrormsg(const char * fmt,va_list ap)97 im_verrormsg( const char *fmt, va_list ap )
98 {
99 	im_verror( "untranslated", fmt, ap );
100 }
101 
102 void
im_errormsg_system(int err,const char * fmt,...)103 im_errormsg_system( int err,  const char *fmt, ... )
104 {
105 	va_list ap;
106 
107 	va_start( ap, fmt );
108 	im_verror_system( err, "untranslated", fmt, ap );
109 	va_end( ap );
110 }
111 
112 void
im_diagnostics(const char * fmt,...)113 im_diagnostics( const char *fmt, ... )
114 {
115 	va_list ap;
116 
117 	va_start( ap, fmt );
118 	im_vdiag( "untranslated", fmt, ap );
119 	va_end( ap );
120 }
121 
122 void
im_warning(const char * fmt,...)123 im_warning( const char *fmt, ... )
124 {
125 	va_list ap;
126 
127 	va_start( ap, fmt );
128 	im_vwarn( "untranslated", fmt, ap );
129 	va_end( ap );
130 }
131 
132 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)133 im_affine( IMAGE *in, IMAGE *out,
134 	double a, double b, double c, double d, double dx, double dy,
135 	int ox, int oy, int ow, int oh )
136 {
137 	return( im_affinei( in, out,
138 		vips_interpolate_bilinear_static(),
139 		a, b, c, d, dx, dy,
140 		ox, oy, ow, oh ) );
141 }
142 
143 int
im_similarity_area(IMAGE * in,IMAGE * out,double a,double b,double dx,double dy,int ox,int oy,int ow,int oh)144 im_similarity_area( IMAGE *in, IMAGE *out,
145 	double a, double b, double dx, double dy,
146 	int ox, int oy, int ow, int oh )
147 {
148 	return( im_affinei( in, out,
149 		vips_interpolate_bilinear_static(),
150 		a, -b, b, a, dx, dy,
151 		ox, oy, ow, oh ) );
152 }
153 
154 int
im_similarity(IMAGE * in,IMAGE * out,double a,double b,double dx,double dy)155 im_similarity( IMAGE *in, IMAGE *out,
156 	double a, double b, double dx, double dy )
157 {
158 	return( im_affinei_all( in, out,
159 		vips_interpolate_bilinear_static(),
160 		a, -b, b, a, dx, dy ) );
161 }
162 
163 DOUBLEMASK *
im_measure(IMAGE * im,IMAGE_BOX * box,int h,int v,int * sel,int nsel,const char * name)164 im_measure( IMAGE *im, IMAGE_BOX *box, int h, int v,
165 	int *sel, int nsel, const char *name )
166 {
167 	return( im_measure_area( im,
168 		box->xstart,
169 		box->ystart,
170 		box->xsize,
171 		box->ysize,
172 		h, v, sel, nsel, name ) );
173 }
174 
175 int
im_extract(IMAGE * in,IMAGE * out,IMAGE_BOX * box)176 im_extract( IMAGE *in, IMAGE *out, IMAGE_BOX *box )
177 {
178 	if( box->chsel == -1 )
179 		return( im_extract_areabands( in, out,
180 			box->xstart, box->ystart, box->xsize, box->ysize,
181 			0, in->Bands ) );
182 	else
183 		return( im_extract_areabands( in, out,
184 			box->xstart, box->ystart, box->xsize, box->ysize,
185 			box->chsel, 1 ) );
186 }
187 
188 /* The public proto has this in the argument.
189  */
190 typedef void (*notify_fn)( IMAGE *, Rect *, void * );
191 
192 int
im_render_fade(IMAGE * in,IMAGE * out,IMAGE * mask,int width,int height,int max,int fps,int steps,int priority,notify_fn notify,void * client)193 im_render_fade( IMAGE *in, IMAGE *out, IMAGE *mask,
194 	int width, int height, int max,
195 	int fps, int steps,
196 	int priority,
197 	notify_fn notify, void *client )
198 {
199 	return( im_render_priority( in, out, mask,
200 		width, height, max,
201 		priority,
202 		notify, client ) );
203 }
204 
205 int
im_render(IMAGE * in,IMAGE * out,IMAGE * mask,int width,int height,int max,notify_fn notify,void * client)206 im_render( IMAGE *in, IMAGE *out, IMAGE *mask,
207 	int width, int height, int max,
208 	notify_fn notify, void *client )
209 {
210 	return( im_render_priority( in, out, mask,
211 		width, height, max,
212 		0,
213 		notify, client ) );
214 }
215 
216 int
im_makerw(IMAGE * im)217 im_makerw( IMAGE *im )
218 {
219 	return( im_rwcheck( im ) );
220 }
221 
222 int
im_icc_export(IMAGE * in,IMAGE * out,const char * output_profile_filename,int intent)223 im_icc_export( IMAGE *in, IMAGE *out,
224 	const char *output_profile_filename, int intent )
225 {
226 	return( im_icc_export_depth( in, out,
227 		8, output_profile_filename, (VipsIntent) intent ) );
228 }
229 
230 int
im_segment(IMAGE * test,IMAGE * mask,int * segments)231 im_segment( IMAGE *test, IMAGE *mask, int *segments )
232 {
233 	return( im_label_regions( test, mask, segments ) );
234 }
235 
236 int
im_convf(IMAGE * in,IMAGE * out,DOUBLEMASK * mask)237 im_convf( IMAGE *in, IMAGE *out, DOUBLEMASK *mask )
238 {
239 	return( im_conv_f( in, out, mask ) );
240 }
241 
242 int
im_convf_raw(IMAGE * in,IMAGE * out,DOUBLEMASK * mask)243 im_convf_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask )
244 {
245 	return( im_conv_f_raw( in, out, mask ) );
246 }
247 
248 int
im_convsepf(IMAGE * in,IMAGE * out,DOUBLEMASK * mask)249 im_convsepf( IMAGE *in, IMAGE *out, DOUBLEMASK *mask )
250 {
251 	return( im_convsep_f( in, out, mask ) );
252 }
253 
254 int
im_convsepf_raw(IMAGE * in,IMAGE * out,DOUBLEMASK * mask)255 im_convsepf_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask )
256 {
257 	return( im_convsep_f_raw( in, out, mask ) );
258 }
259 
260 gboolean
im_isint(IMAGE * im)261 im_isint( IMAGE *im )
262 {
263 	return( vips_bandfmt_isint( im->BandFmt ) );
264 }
265 
266 gboolean
im_isuint(IMAGE * im)267 im_isuint( IMAGE *im )
268 {
269 	return( vips_bandfmt_isuint( im->BandFmt ) );
270 }
271 
272 gboolean
im_isfloat(IMAGE * im)273 im_isfloat( IMAGE *im )
274 {
275 	return( vips_bandfmt_isfloat( im->BandFmt ) );
276 }
277 
278 gboolean
im_iscomplex(IMAGE * im)279 im_iscomplex( IMAGE *im )
280 {
281 	return( vips_band_format_iscomplex( im->BandFmt ) );
282 }
283 
284 gboolean
im_isscalar(IMAGE * im)285 im_isscalar( IMAGE *im )
286 {
287 	return( !im_iscomplex( im ) );
288 }
289 
290 int
im_c2ps(IMAGE * in,IMAGE * out)291 im_c2ps( IMAGE *in, IMAGE *out )
292 {
293 	return( im_abs( in, out ) );
294 }
295 
296 int
im_clip(IMAGE * in,IMAGE * out)297 im_clip( IMAGE *in, IMAGE *out )
298 {
299 	return( im_clip2fmt( in, out, IM_BANDFMT_UCHAR ) );
300 }
301 
302 int
im_clip2c(IMAGE * in,IMAGE * out)303 im_clip2c( IMAGE *in, IMAGE *out )
304 {
305 	return( im_clip2fmt( in, out, IM_BANDFMT_CHAR ) );
306 }
307 
308 int
im_clip2us(IMAGE * in,IMAGE * out)309 im_clip2us( IMAGE *in, IMAGE *out )
310 {
311 	return( im_clip2fmt( in, out, IM_BANDFMT_USHORT ) );
312 }
313 
314 int
im_clip2s(IMAGE * in,IMAGE * out)315 im_clip2s( IMAGE *in, IMAGE *out )
316 {
317 	return( im_clip2fmt( in, out, IM_BANDFMT_SHORT ) );
318 }
319 
320 int
im_clip2ui(IMAGE * in,IMAGE * out)321 im_clip2ui( IMAGE *in, IMAGE *out )
322 {
323 	return( im_clip2fmt( in, out, IM_BANDFMT_UINT ) );
324 }
325 
326 int
im_clip2i(IMAGE * in,IMAGE * out)327 im_clip2i( IMAGE *in, IMAGE *out )
328 {
329 	return( im_clip2fmt( in, out, IM_BANDFMT_INT ) );
330 }
331 
332 int
im_clip2f(IMAGE * in,IMAGE * out)333 im_clip2f( IMAGE *in, IMAGE *out )
334 {
335 	return( im_clip2fmt( in, out, IM_BANDFMT_FLOAT ) );
336 }
337 
338 int
im_clip2d(IMAGE * in,IMAGE * out)339 im_clip2d( IMAGE *in, IMAGE *out )
340 {
341 	return( im_clip2fmt( in, out, IM_BANDFMT_DOUBLE ) );
342 }
343 
344 int
im_clip2cm(IMAGE * in,IMAGE * out)345 im_clip2cm( IMAGE *in, IMAGE *out )
346 {
347 	return( im_clip2fmt( in, out, IM_BANDFMT_COMPLEX ) );
348 }
349 
350 int
im_clip2dcm(IMAGE * in,IMAGE * out)351 im_clip2dcm( IMAGE *in, IMAGE *out )
352 {
353 	return( im_clip2fmt( in, out, IM_BANDFMT_DPCOMPLEX ) );
354 }
355 
356 int
im_copy_from(IMAGE * in,IMAGE * out,im_arch_type architecture)357 im_copy_from( IMAGE *in, IMAGE *out, im_arch_type architecture )
358 {
359 	switch( architecture ) {
360 	case IM_ARCH_NATIVE:
361 		return( im_copy( in, out ) );
362 
363 	case IM_ARCH_BYTE_SWAPPED:
364 		return( im_copy_swap( in, out ) );
365 
366 	case IM_ARCH_LSB_FIRST:
367 		return( im_amiMSBfirst() ?
368 			im_copy_swap( in, out ) : im_copy( in, out ) );
369 
370 	case IM_ARCH_MSB_FIRST:
371 		return( im_amiMSBfirst() ?
372 			im_copy( in, out ) : im_copy_swap( in, out ) );
373 
374 	default:
375 		im_error( "im_copy_from",
376 			_( "bad architecture: %d" ), architecture );
377 		return( -1 );
378 	}
379 }
380 
381 /* Check whether arch corresponds to native byte order.
382  */
383 gboolean
im_isnative(im_arch_type arch)384 im_isnative( im_arch_type arch )
385 {
386 	switch( arch ) {
387 	case IM_ARCH_NATIVE:
388 		return( TRUE );
389 	case IM_ARCH_BYTE_SWAPPED:
390 		return( FALSE );
391 	case IM_ARCH_LSB_FIRST:
392 		return( !im_amiMSBfirst() );
393 	case IM_ARCH_MSB_FIRST:
394 		return( im_amiMSBfirst() );
395 
396 	default:
397 		g_assert( 0 );
398 	}
399 
400 	/* Keep -Wall happy.
401 	 */
402 	return( -1 );
403 }
404 
405 int
im_iterate(IMAGE * im,im_start_fn start,im_generate_fn generate,im_stop_fn stop,void * b,void * c)406 im_iterate( IMAGE *im,
407 	im_start_fn start, im_generate_fn generate, im_stop_fn stop,
408 	void *b, void *c )
409 {
410 	return( vips_sink( im, start, (VipsGenerateFn) generate, stop, b, c ) );
411 }
412 
413 int
im_render_priority(IMAGE * in,IMAGE * out,IMAGE * mask,int width,int height,int max,int priority,notify_fn notify,void * client)414 im_render_priority( IMAGE *in, IMAGE *out, IMAGE *mask,
415 	int width, int height, int max,
416 	int priority,
417 	notify_fn notify, void *client )
418 {
419 	return( vips_sink_screen( in, out, mask,
420 		width, height, max, priority, notify, client ) );
421 }
422 
423 /**
424  * im_circle:
425  * @im: image to draw on
426  * @cx: centre of circle
427  * @cy: centre of circle
428  * @radius: circle radius
429  * @intensity: value to draw
430  *
431  * Draws a circle on a 1-band 8-bit image.
432  *
433  * This an inplace operation, so @im is changed. It does not thread and will
434  * not work well as part of a pipeline. On 32-bit machines it will be limited
435  * to 2GB images.
436  *
437  * See also: im_fastline().
438  *
439  * Returns: 0 on success, or -1 on error.
440  */
441 int
im_circle(IMAGE * im,int cx,int cy,int radius,int intensity)442 im_circle( IMAGE *im, int cx, int cy, int radius, int intensity )
443 {
444 	PEL ink[1];
445 
446 	if( im_rwcheck( im ) ||
447 		im_check_uncoded( "im_circle", im ) ||
448 		im_check_mono( "im_circle", im ) ||
449 		im_check_format( "im_circle", im, IM_BANDFMT_UCHAR ) )
450 		return( -1 );
451 
452 	ink[0] = intensity;
453 
454 	return( im_draw_circle( im, cx, cy, radius, FALSE, ink ) );
455 }
456 
457 /* A flood blob we can call from nip. Grr! Should be a way to wrap these
458  * automatically. Maybe nip could do it if it sees a RW image argument?
459  */
460 
461 int
im_flood_copy(IMAGE * in,IMAGE * out,int x,int y,PEL * ink)462 im_flood_copy( IMAGE *in, IMAGE *out, int x, int y, PEL *ink )
463 {
464 	IMAGE *t;
465 
466 	if( !(t = im_open_local( out, "im_flood_blob_copy", "t" )) ||
467 		im_copy( in, t ) ||
468 		im_flood( t, x, y, ink, NULL ) ||
469 		im_copy( t, out ) )
470 		return( -1 );
471 
472 	return( 0 );
473 }
474 
475 int
im_flood_blob_copy(IMAGE * in,IMAGE * out,int x,int y,PEL * ink)476 im_flood_blob_copy( IMAGE *in, IMAGE *out, int x, int y, PEL *ink )
477 {
478 	IMAGE *t;
479 
480 	if( !(t = im_open_local( out, "im_flood_blob_copy", "t" )) ||
481 		im_copy( in, t ) ||
482 		im_flood_blob( t, x, y, ink, NULL ) ||
483 		im_copy( t, out ) )
484 		return( -1 );
485 
486 	return( 0 );
487 }
488 
489 int
im_flood_other_copy(IMAGE * test,IMAGE * mark,IMAGE * out,int x,int y,int serial)490 im_flood_other_copy( IMAGE *test, IMAGE *mark, IMAGE *out,
491 	int x, int y, int serial )
492 {
493 	IMAGE *t;
494 
495 	if( !(t = im_open_local( out, "im_flood_other_copy", "t" )) ||
496 		im_copy( mark, t ) ||
497 		im_flood_other( test, t, x, y, serial, NULL ) ||
498 		im_copy( t, out ) )
499 		return( -1 );
500 
501 	return( 0 );
502 }
503 
504 int
im_paintrect(IMAGE * im,Rect * r,PEL * ink)505 im_paintrect( IMAGE *im, Rect *r, PEL *ink )
506 {
507 	return( im_draw_rect( im,
508 		r->left, r->top, r->width, r->height, 1, ink ) );
509 }
510 
511 int
im_insertplace(IMAGE * main,IMAGE * sub,int x,int y)512 im_insertplace( IMAGE *main, IMAGE *sub, int x, int y )
513 {
514 	return( im_draw_image( main, sub, x, y ) );
515 }
516 
517 int
im_fastline(IMAGE * im,int x1,int y1,int x2,int y2,PEL * pel)518 im_fastline( IMAGE *im, int x1, int y1, int x2, int y2, PEL *pel )
519 {
520 	return( im_draw_line( im, x1, y1, x2, y2, pel ) );
521 }
522 
523 int
im_fastlineuser(IMAGE * im,int x1,int y1,int x2,int y2,VipsPlotFn fn,void * client1,void * client2,void * client3)524 im_fastlineuser( IMAGE *im,
525 	int x1, int y1, int x2, int y2,
526 	VipsPlotFn fn, void *client1, void *client2, void *client3 )
527 {
528 	return( im_draw_line_user( im, x1, y1, x2, y2,
529 		fn, client1, client2, client3 ) );
530 }
531 
532 int
im_plotmask(IMAGE * im,int ix,int iy,PEL * ink,PEL * mask,Rect * r)533 im_plotmask( IMAGE *im, int ix, int iy, PEL *ink, PEL *mask, Rect *r )
534 {
535 	IMAGE *mask_im;
536 
537 	if( !(mask_im = im_image( mask,
538 		r->width, r->height, 1, IM_BANDFMT_UCHAR )) )
539 		return( -1 );
540 	if( im_draw_mask( im, mask_im, ix + r->left, iy + r->top, ink ) ) {
541 		im_close( mask_im );
542 		return( -1 );
543 	}
544 	im_close( mask_im );
545 
546 	return( 0 );
547 }
548 
549 int
im_readpoint(IMAGE * im,int x,int y,PEL * pel)550 im_readpoint( IMAGE *im, int x, int y, PEL *pel )
551 {
552 	return( im_read_point( im, x, y, pel ) );
553 }
554 
555 int
im_plotpoint(IMAGE * im,int x,int y,PEL * pel)556 im_plotpoint( IMAGE *im, int x, int y, PEL *pel )
557 {
558 	return( im_draw_point( im, x, y, pel ) );
559 }
560 
561 /* Smear a section of an IMAGE. As above, but shift it left a bit.
562  */
563 int
im_smear(IMAGE * im,int ix,int iy,Rect * r)564 im_smear( IMAGE *im, int ix, int iy, Rect *r )
565 {
566 	int x, y, a, b, c;
567 	int ba = im->Bands;
568 	int el = ba * im->Xsize;
569 	Rect area, image, clipped;
570 	double total[ 256 ];
571 
572 	if( im_rwcheck( im ) )
573 		return( -1 );
574 
575 	/* Don't do the margins.
576 	 */
577 	area = *r;
578 	area.left += ix;
579 	area.top += iy;
580 	image.left = 0;
581 	image.top = 0;
582 	image.width = im->Xsize;
583 	image.height = im->Ysize;
584 	im_rect_marginadjust( &image, -1 );
585 	image.left--;
586 	im_rect_intersectrect( &area, &image, &clipped );
587 
588 	/* Any left?
589 	 */
590 	if( im_rect_isempty( &clipped ) )
591 		return( 0 );
592 
593 /* What we do for each type.
594  */
595 #define SMEAR(TYPE) \
596 	for( y = clipped.top; y < clipped.top + clipped.height; y++ ) \
597 		for( x = clipped.left;  \
598 			x < clipped.left + clipped.width; x++ ) { \
599 			TYPE *to = (TYPE *) im->data + x * ba + y * el; \
600 			TYPE *from = to - el; \
601 			TYPE *f; \
602  			\
603 			for( a = 0; a < ba; a++ ) \
604 				total[a] = 0.0; \
605 			\
606 			for( a = 0; a < 3; a++ ) { \
607 				f = from; \
608 				for( b = 0; b < 3; b++ ) \
609 					for( c = 0; c < ba; c++ ) \
610 						total[c] += *f++; \
611 				from += el; \
612 			} \
613  			\
614 			for( a = 0; a < ba; a++ ) \
615 				to[a] = (40 * (double) to[a+ba] + total[a]) \
616 					/ 49.0; \
617 		}
618 
619 	/* Loop through the remaining pixels.
620 	 */
621 	switch( im->BandFmt ) {
622 	case IM_BANDFMT_UCHAR:
623 		SMEAR(unsigned char);
624 		break;
625 
626 	case IM_BANDFMT_CHAR:
627 		SMEAR(char);
628 		break;
629 
630 	case IM_BANDFMT_USHORT:
631 		SMEAR(unsigned short);
632 		break;
633 
634 	case IM_BANDFMT_SHORT:
635 		SMEAR(short);
636 		break;
637 
638 	case IM_BANDFMT_UINT:
639 		SMEAR(unsigned int);
640 		break;
641 
642 	case IM_BANDFMT_INT:
643 		SMEAR(int);
644 		break;
645 
646 	case IM_BANDFMT_FLOAT:
647 		SMEAR(float);
648 		break;
649 
650 	case IM_BANDFMT_DOUBLE:
651 		SMEAR(double);
652 		break;
653 
654 	/* Do complex types too. Just treat as float and double, but with
655 	 * twice the number of bands.
656 	 */
657 	case IM_BANDFMT_COMPLEX:
658 		/* Twice number of bands: double size and bands.
659 		 */
660 		ba *= 2;
661 		el *= 2;
662 
663 		SMEAR(float);
664 
665 		break;
666 
667 	case IM_BANDFMT_DPCOMPLEX:
668 		/* Twice number of bands: double size and bands.
669 		 */
670 		ba *= 2;
671 		el *= 2;
672 
673 		SMEAR(double);
674 
675 		break;
676 
677 	default:
678 		im_error( "im_smear", "%s", _( "unknown band format" ) );
679 		return( -1 );
680 	}
681 
682 	return( 0 );
683 }
684 
685 int
im_smudge(VipsImage * image,int ix,int iy,Rect * r)686 im_smudge( VipsImage *image, int ix, int iy, Rect *r )
687 {
688 	return( im_draw_smudge( image,
689 		r->left + ix, r->top + iy, r->width, r->height ) );
690 }
691 
692 int
im_flood(IMAGE * im,int x,int y,PEL * ink,Rect * dout)693 im_flood( IMAGE *im, int x, int y, PEL *ink, Rect *dout )
694 {
695 	return( im_draw_flood( im, x, y, ink, dout ) );
696 }
697 
698 int
im_flood_blob(IMAGE * im,int x,int y,PEL * ink,Rect * dout)699 im_flood_blob( IMAGE *im, int x, int y, PEL *ink, Rect *dout )
700 {
701 	return( im_draw_flood_blob( im, x, y, ink, dout ) );
702 }
703 
704 int
im_flood_other(IMAGE * test,IMAGE * mark,int x,int y,int serial,Rect * dout)705 im_flood_other( IMAGE *test, IMAGE *mark,
706 	int x, int y, int serial, Rect *dout )
707 {
708 	return( im_draw_flood_other( mark, test, x, y, serial, dout ) );
709 }
710 
711 int
vips_check_coding_rad(const char * domain,VipsImage * im)712 vips_check_coding_rad( const char *domain, VipsImage *im )
713 {
714 	return( vips_check_coding( domain, im, VIPS_CODING_RAD ) );
715 }
716 
717 int
vips_check_coding_labq(const char * domain,VipsImage * im)718 vips_check_coding_labq( const char *domain, VipsImage *im )
719 {
720 	return( vips_check_coding( domain, im, VIPS_CODING_LABQ ) );
721 }
722 
723 int
vips_check_bands_3ormore(const char * domain,VipsImage * im)724 vips_check_bands_3ormore( const char *domain, VipsImage *im )
725 {
726 	return( vips_check_bands_atleast( domain, im, 3 ) );
727 }
728 
729 /* The old vips_info() stuff, now replaced by g_warning() / g_info().
730  */
731 
732 int vips__info = 0;
733 
734 void
vips_info_set(gboolean info)735 vips_info_set( gboolean info )
736 {
737 	vips__info = info;
738 
739 	if( info ) {
740 		const char *old;
741 		char *new;
742 
743 		old = g_getenv( "G_MESSAGES_DEBUG" );
744 		if( !old )
745 			old = "";
746 		new = g_strdup_printf( "%s VIPS", old );
747 		g_setenv( "G_MESSAGES_DEBUG", new, TRUE );
748 		g_free( new );
749 	}
750 }
751 
752 void
vips_vinfo(const char * domain,const char * fmt,va_list ap)753 vips_vinfo( const char *domain, const char *fmt, va_list ap )
754 {
755 	if( vips__info ) {
756 		g_mutex_lock( vips__global_lock );
757 		(void) fprintf( stderr, _( "%s: " ), _( "info" ) );
758 		if( domain )
759 			(void) fprintf( stderr, _( "%s: " ), domain );
760 		(void) vfprintf( stderr, fmt, ap );
761 		(void) fprintf( stderr, "\n" );
762 		g_mutex_unlock( vips__global_lock );
763 	}
764 }
765 
766 void
vips_info(const char * domain,const char * fmt,...)767 vips_info( const char *domain, const char *fmt, ... )
768 {
769 	va_list ap;
770 
771 	va_start( ap, fmt );
772 	vips_vinfo( domain, fmt, ap );
773 	va_end( ap );
774 }
775 
776 void
vips_vwarn(const char * domain,const char * fmt,va_list ap)777 vips_vwarn( const char *domain, const char *fmt, va_list ap )
778 {
779 	if( !g_getenv( "IM_WARNING" ) &&
780 		!g_getenv( "VIPS_WARNING" ) ) {
781 		g_mutex_lock( vips__global_lock );
782 		(void) fprintf( stderr, _( "%s: " ), _( "vips warning" ) );
783 		if( domain )
784 			(void) fprintf( stderr, _( "%s: " ), domain );
785 		(void) vfprintf( stderr, fmt, ap );
786 		(void) fprintf( stderr, "\n" );
787 		g_mutex_unlock( vips__global_lock );
788 	}
789 
790 	if( vips__fatal )
791 		vips_error_exit( "vips__fatal" );
792 }
793 
794 void
vips_warn(const char * domain,const char * fmt,...)795 vips_warn( const char *domain, const char *fmt, ... )
796 {
797 	va_list ap;
798 
799 	va_start( ap, fmt );
800 	vips_vwarn( domain, fmt, ap );
801 	va_end( ap );
802 }
803 
804 /**
805  * vips_autorot_get_angle:
806  * @image: image to fetch orientation from
807  *
808  * This function is deprecated. Use vips_autorot() instead.
809  */
810 VipsAngle
vips_autorot_get_angle(VipsImage * im)811 vips_autorot_get_angle( VipsImage *im )
812 {
813 	return( VIPS_ANGLE_D0 );
814 }
815 
816 /* The old vips_free(), now replaced by g_free() and vips_area_free_cb().
817  */
818 int
vips_free(void * buf)819 vips_free( void *buf )
820 {
821 	g_free( buf );
822 
823 	return( 0 );
824 }
825 
826