remove vips7 stuff from API

You must now include vips7 support explicitly with

	#include <vips/vips7compat.h>

in your code just after including `vips.h`.

The old vips7 names, such as `Rect`, were starting to cause problems
with other packages like opencv.
This commit is contained in:
John Cupitt 2018-05-16 15:08:21 +01:00
parent fd7b04fb9d
commit b085908558
130 changed files with 273 additions and 197 deletions

View File

@ -21,6 +21,7 @@
- tiffload, pdfload, magickload set VIPS_META_N_PAGES "n-pages" metadata item
- add fontfile option to vips_text() [fangqiao]
- add vips_transpose3d() -- swap major dimensions in a volumetric image
- remove vips7 stuff from default API ... you must now #include it explicitly
12/3/18 started 8.6.4
- better fitting of fonts with overhanging edges [Adrià]

View File

@ -1278,7 +1278,6 @@ AC_OUTPUT([
libvips/mosaicing/Makefile
libvips/create/Makefile
libvips/resample/Makefile
libvips/video/Makefile
libvipsCC/include/Makefile
libvipsCC/include/vips/Makefile
libvipsCC/Makefile

View File

@ -24,8 +24,7 @@ SUBDIRS = \
iofuncs \
morphology \
mosaicing \
create \
video \
create
.
lib_LTLIBRARIES = libvips.la
@ -52,7 +51,6 @@ libvips_la_LIBADD = \
morphology/libmorphology.la \
mosaicing/libmosaicing.la \
create/libcreate.la \
video/libvideo.la \
@VIPS_LIBS@
libvips_la_LDFLAGS = \

View File

@ -409,7 +409,7 @@ vips_stats_class_init( VipsStatsClass *class )
gobject_class->get_property = vips_object_get_property;
object_class->nickname = "stats";
object_class->description = _( "find image average" );
object_class->description = _( "find many image stats" );
object_class->build = vips_stats_build;
sclass->start = vips_stats_start;

View File

@ -372,7 +372,7 @@ vips_convasep_stop( void *vseq, void *a, void *b )
static void *
vips_convasep_start( VipsImage *out, void *a, void *b )
{
VipsImage *in = (IMAGE *) a;
VipsImage *in = (VipsImage *) a;
VipsConvasep *convasep = (VipsConvasep *) b;
VipsConvasepSeq *seq;

View File

@ -176,7 +176,7 @@ vips_convf_start( VipsImage *out, void *a, void *b )
/* Convolve!
*/
static int
vips_convf_gen( REGION *or, void *vseq, void *a, void *b, gboolean *stop )
vips_convf_gen( VipsRegion *or, void *vseq, void *a, void *b, gboolean *stop )
{
VipsConvfSequence *seq = (VipsConvfSequence *) vseq;
VipsConvf *convf = (VipsConvf *) b;
@ -337,8 +337,8 @@ vips_convf_build( VipsObject *object )
/* Prepare output. Consider a 7x7 mask and a 7x7 image --- the output
* would be 1x1.
*/
if( vips_bandfmt_isint( in->BandFmt ) )
convolution->out->BandFmt = IM_BANDFMT_FLOAT;
if( vips_band_format_isint( in->BandFmt ) )
convolution->out->BandFmt = VIPS_FORMAT_FLOAT;
convolution->out->Xsize -= M->Xsize - 1;
convolution->out->Ysize -= M->Ysize - 1;

View File

@ -1,6 +1,8 @@
noinst_LTLIBRARIES = libdeprecated.la
libdeprecated_la_SOURCES = \
video_dispatch.c \
im_video_test.c \
cimg_dispatch.c \
inplace_dispatch.c \
tone.c \

View File

@ -38,6 +38,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* One image in, one out.
*/

View File

@ -36,6 +36,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
static int
greyc_vec( im_object *argv )

View File

@ -38,6 +38,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* One image in, one out.
*/

View File

@ -36,6 +36,7 @@
#include <vips/intl.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
static int
system_vec( im_object *argv )

View File

@ -38,6 +38,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* One image in, one out.
*/

View File

@ -75,6 +75,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
static
int im_cooc_sym(IMAGE *im, IMAGE *m, int xpos, int ypos, int xsize, int ysize, int dx, int dy)

View File

@ -36,6 +36,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
/* One image in, one out.

View File

@ -47,6 +47,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
/* String containing each of the characters which can be used within a

View File

@ -41,6 +41,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
#include <vips/debug.h>

View File

@ -36,6 +36,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
/* To iterate over supported formats, we build a temp list of subclasses of

View File

@ -36,6 +36,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
static int
jpeg2vips_vec( im_object *argv )

View File

@ -41,6 +41,7 @@
#include <stdarg.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* One image in, one out.
*/

View File

@ -72,6 +72,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* Keep the greylevel difference matrix as a 256x1 double image */

View File

@ -38,6 +38,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* One image in, one out.
*/

View File

@ -39,6 +39,7 @@
#include <vips/intl.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/**
* im_align_bands:

View File

@ -41,6 +41,7 @@
#include <vips/intl.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
static VipsFormatFlags
analyze_flags( const char *filename )

View File

@ -45,6 +45,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/*

View File

@ -52,6 +52,7 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
static int
extract( IMAGE *in, int x, int y, int w, int h )

View File

@ -48,6 +48,7 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
int

View File

@ -47,6 +47,7 @@
#include <vips/intl.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -55,6 +55,7 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
/* Create multiplication luts for all non zero elements of the original mask;

View File

@ -43,6 +43,7 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include "../foreign/pforeign.h"

View File

@ -57,6 +57,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
int
im_debugim( IMAGE *in )

View File

@ -45,6 +45,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
static int

View File

@ -46,6 +46,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/thread.h>
#include <vips/internal.h>

View File

@ -38,6 +38,7 @@ Copyright (C) 1992, Kirk Martinez, History of Art Dept, Birkbeck College
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#define ARGS "fav4: frame average 4 frames\nARGS: im1 im2 im3 im4 outfile"
#define NFRAMES 4

View File

@ -46,6 +46,7 @@
#include <stdarg.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
/* Make a mask image.

View File

@ -57,6 +57,7 @@
#include <assert.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
int im_gfadd(double a, IMAGE *in1, double b, IMAGE *in2, double c, IMAGE *out);
int im_gaddim(double a, IMAGE *in1, double b, IMAGE *in2, double c, IMAGE *out);

View File

@ -58,6 +58,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* This function works on either mmaped files or on images in buffer
*/

View File

@ -61,6 +61,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* uchar char ushort short uint int float double */
static int array[8][8] = {

View File

@ -47,6 +47,7 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/** LOCAL TYPES **/

View File

@ -47,6 +47,7 @@
#include <setjmp.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include "../foreign/pforeign.h"

View File

@ -45,6 +45,7 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
int

View File

@ -52,6 +52,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
int im_line(image, x1, y1, x2, y2, pelval)
IMAGE *image;

View File

@ -50,6 +50,7 @@
#include <stdlib.h>
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/** TYPES **/

View File

@ -66,6 +66,7 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* If maximum output is > 255 scale output between minout and maxout,
* by normalising maxout to 255.

View File

@ -41,6 +41,7 @@
#include <vips/intl.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include "../foreign/pforeign.h"

View File

@ -45,6 +45,7 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/**
* im_mask2vips:

View File

@ -42,6 +42,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/**
* im_matcat:

View File

@ -54,6 +54,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/** CONSTANTS **/

View File

@ -41,6 +41,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/**
* im_matmul:

View File

@ -39,6 +39,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/**
* im_mattrn:

View File

@ -62,6 +62,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
/* A position and maximum.

View File

@ -42,6 +42,7 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#define MOST_OF( A, B ) ( (A) > 0.9 * (B) )

View File

@ -60,6 +60,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* Measure into array.
*/

View File

@ -50,6 +50,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/thread.h>
#include <vips/internal.h>

View File

@ -43,6 +43,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
#include "../foreign/pforeign.h"

View File

@ -45,6 +45,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/**
* im_point:

View File

@ -37,6 +37,7 @@
#include <vips/intl.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
int
im_ppm2vips( const char *filename, IMAGE *out )

View File

@ -36,6 +36,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* Print a string to stdout, with a "\n". Sometimes useful for debugging
* language bindings.

View File

@ -54,6 +54,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* Useful: Call a macro with the name, type pairs for all VIPS functions.
*/

View File

@ -48,6 +48,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* What we do for each pel.
*/

View File

@ -48,6 +48,7 @@
#include <sys/types.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
void im_setbox(IMAGE_BOX *pbox, int xst, int yst, int xsiz, int ysiz, int ch_select)
{

View File

@ -49,6 +49,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/**
* im_simcontr:

View File

@ -55,6 +55,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#define BRIGHT 255
#define GREY 128

View File

@ -52,6 +52,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
int
im_spatres( IMAGE *in, IMAGE *out, int step )

View File

@ -62,6 +62,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* Data for the cubic interpolation function.
*/

View File

@ -51,6 +51,7 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* Useful: Call a macro with the name, type pairs for all VIPS functions. */
#define BRIGHT 255

View File

@ -46,6 +46,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
#include <vips/thread.h>

View File

@ -34,6 +34,7 @@
#include <vips/intl.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/**
* im_video_test:

View File

@ -37,6 +37,7 @@
#include <vips/intl.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
int
im_vips2csv( IMAGE *in, const char *filename )

View File

@ -45,6 +45,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
int
im_vips2dz( IMAGE *in, const char *filename )

View File

@ -46,6 +46,7 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
int

View File

@ -48,6 +48,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/**
* im_vips2mask:

View File

@ -45,6 +45,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
#include <vips/debug.h>

View File

@ -39,6 +39,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
int
im_vips2ppm( IMAGE *in, const char *filename )

View File

@ -45,6 +45,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
int
im_vips2tiff( IMAGE *in, const char *filename )

View File

@ -39,6 +39,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
#include <vips/debug.h>

View File

@ -37,6 +37,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
#include "../foreign/pforeign.h"

View File

@ -51,6 +51,7 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#define LOOP( TYPE ) { \
for( i = 0; i < ne; i++ ) { \

View File

@ -38,6 +38,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* Calculate a pixel for an image from a vec of double. Valid while im is
* valid.

View File

@ -46,6 +46,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/debug.h>
#include <vips/internal.h>

View File

@ -38,6 +38,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* One matrix in, one out.
*/

View File

@ -13,6 +13,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#define TINY 1.0e-200

View File

@ -37,6 +37,7 @@
#include <vips/intl.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
int
im_mat2vips( const char *filename, IMAGE *out )

View File

@ -38,6 +38,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* Args to im_profile.
*/

View File

@ -38,6 +38,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
#include <vips/transform.h>

View File

@ -38,6 +38,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* Args for im_sines.
*/

View File

@ -58,6 +58,7 @@
#include <limits.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
#include <vips/debug.h>

View File

@ -37,6 +37,7 @@
#include <vips/intl.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
int
im_rad2vips( const char *filename, IMAGE *out )

View File

@ -41,6 +41,7 @@
#include <vips/intl.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
int
im_raw2vips( const char *filename, IMAGE *out,

View File

@ -38,6 +38,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
int

View File

@ -38,6 +38,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
#include <vips/transform.h>

View File

@ -55,6 +55,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/* The type of the vips operations we support.
*/

View File

@ -95,6 +95,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/**
* INTMASK:

View File

@ -52,6 +52,7 @@
#include <math.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/**
* im_tone_map:

View File

@ -36,6 +36,7 @@
#include <stdio.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
/**
* SECTION: video

View File

@ -46,6 +46,7 @@
#include <ctype.h>
#include <vips/vips.h>
#include <vips/vips7compat.h>
#include <vips/internal.h>
#include <vips/debug.h>
#include <vips/vector.h>
@ -5190,6 +5191,23 @@ im_global_balance( IMAGE *in, IMAGE *out, double gamma )
return( 0 );
}
int
im_histplot( IMAGE *in, IMAGE *out )
{
VipsImage *x;
if( vips_hist_plot( in, &x, NULL ) )
return( -1 );
if( vips_image_write( x, out ) ) {
g_object_unref( x );
return( -1 );
}
g_object_unref( x );
return( 0 );
}
int
im_global_balancef( IMAGE *in, IMAGE *out, double gamma )
{

View File

@ -413,8 +413,7 @@ vips_image_resolution_from_exif( VipsImage *image, ExifData *ed )
break;
default:
vips_warn( "exif",
"%s", _( "unknown EXIF resolution unit" ) );
g_warning( "%s", _( "unknown EXIF resolution unit" ) );
return( -1 );
}
@ -773,8 +772,7 @@ vips_exif_resolution_from_image( ExifData *ed, VipsImage *image )
break;
default:
vips_warn( "exif",
"%s", _( "unknown EXIF resolution unit" ) );
g_warning( "%s", _( "unknown EXIF resolution unit" ) );
return( 0 );
}
@ -946,7 +944,7 @@ vips_exif_image_field( VipsImage *image,
/* value must be a string.
*/
if( vips_image_get_string( image, field, &string ) ) {
vips_warn( "exif", _( "bad exif meta \"%s\"" ), field );
g_warning( _( "bad exif meta \"%s\"" ), field );
return( NULL );
}
@ -956,12 +954,12 @@ vips_exif_image_field( VipsImage *image,
for( ; isdigit( *p ); p++ )
;
if( *p != '-' ) {
vips_warn( "exif", _( "bad exif meta \"%s\"" ), field );
g_warning( _( "bad exif meta \"%s\"" ), field );
return( NULL );
}
if( !(tag = exif_tag_from_name( p + 1 )) ) {
vips_warn( "exif", _( "bad exif meta \"%s\"" ), field );
g_warning( _( "bad exif meta \"%s\"" ), field );
return( NULL );
}

View File

@ -244,7 +244,7 @@ read_header( Read *read, VipsImage *out )
bitstream.bytes = read->data;
bitstream.size = read->length;
if( !(mux = WebPMuxCreate( &bitstream, 0 )) ) {
vips_warn( "webp", "%s", _( "unable to read image metadata" ) );
g_warning( "%s", _( "unable to read image metadata" ) );
return( 0 );
}

View File

@ -70,52 +70,16 @@
#include "phistogram.h"
static int
plotalise( IMAGE *in, IMAGE *out )
{
if( im_check_uncoded( "im_histplot", in ) ||
im_check_noncomplex( "im_histplot", in ) )
return( -1 );
typedef struct _VipsHistPlot {
VipsOperation parent_instance;
if( vips_bandfmt_isuint( in->BandFmt ) ) {
if( im_copy( in, out ) )
return( -1 );
}
else if( vips_bandfmt_isint( in->BandFmt ) ) {
double min;
VipsImage *in;
VipsImage *out;
} VipsHistPlot;
/* Move min up to 0.
*/
if( im_min( in, &min ) ||
im_lintra( 1.0, in, -min, out ) )
return( -1 );
}
else {
/* Float image: scale min--max to 0--any. Output square
* graph.
*/
DOUBLEMASK *stats;
double min, max;
int any;
typedef VipsOperationClass VipsHistPlotClass;
if( in->Xsize == 1 )
any = in->Ysize;
else
any = in->Xsize;
if( !(stats = im_stats( in )) )
return( -1 );
min = IM_MASK( stats, 0, 0 );
max = IM_MASK( stats, 1, 0 );
im_free_dmask( stats );
if( im_lintra( any / (max - min), in,
-min * any / (max - min), out ) )
return( -1 );
}
return( 0 );
}
G_DEFINE_TYPE( VipsHistPlot, vips_hist_plot, VIPS_TYPE_OPERATION );
#define VERT( TYPE ) { \
TYPE *p1 = (TYPE *) p; \
@ -131,31 +95,32 @@ plotalise( IMAGE *in, IMAGE *out )
/* Generate function.
*/
static int
make_vert_gen( REGION *or, void *seq, void *a, void *b )
vips_hist_plot_vert_gen( VipsRegion *or, void *seq, void *a, void *b,
gboolean *stop )
{
IMAGE *in = (IMAGE *) a;
Rect *r = &or->valid;
VipsImage *in = (VipsImage *) a;
VipsRect *r = &or->valid;
int le = r->left;
int to = r->top;
int ri = IM_RECT_RIGHT( r );
int bo = IM_RECT_BOTTOM( r );
int ri = VIPS_RECT_RIGHT( r );
int bo = VIPS_RECT_BOTTOM( r );
int nb = in->Bands;
int x, y, z;
for( y = to; y < bo; y++ ) {
VipsPel *q = IM_REGION_ADDR( or, le, y );
VipsPel *p = IM_IMAGE_ADDR( in, 0, y );
VipsPel *q = VIPS_REGION_ADDR( or, le, y );
VipsPel *p = VIPS_IMAGE_ADDR( in, 0, y );
switch( in->BandFmt ) {
case IM_BANDFMT_UCHAR: VERT( unsigned char ); break;
case IM_BANDFMT_CHAR: VERT( signed char ); break;
case IM_BANDFMT_USHORT: VERT( unsigned short ); break;
case IM_BANDFMT_SHORT: VERT( signed short ); break;
case IM_BANDFMT_UINT: VERT( unsigned int ); break;
case IM_BANDFMT_INT: VERT( signed int ); break;
case IM_BANDFMT_FLOAT: VERT( float ); break;
case IM_BANDFMT_DOUBLE: VERT( double ); break;
case VIPS_FORMAT_UCHAR: VERT( unsigned char ); break;
case VIPS_FORMAT_CHAR: VERT( signed char ); break;
case VIPS_FORMAT_USHORT: VERT( unsigned short ); break;
case VIPS_FORMAT_SHORT: VERT( signed short ); break;
case VIPS_FORMAT_UINT: VERT( unsigned int ); break;
case VIPS_FORMAT_INT: VERT( signed int ); break;
case VIPS_FORMAT_FLOAT: VERT( float ); break;
case VIPS_FORMAT_DOUBLE: VERT( double ); break;
default:
g_assert_not_reached();
@ -179,33 +144,34 @@ make_vert_gen( REGION *or, void *seq, void *a, void *b )
/* Generate function.
*/
static int
make_horz_gen( REGION *or, void *seq, void *a, void *b )
vips_hist_plot_horz_gen( VipsRegion *or, void *seq, void *a, void *b,
gboolean *stop )
{
IMAGE *in = (IMAGE *) a;
Rect *r = &or->valid;
VipsImage *in = (VipsImage *) a;
VipsRect *r = &or->valid;
int le = r->left;
int to = r->top;
int ri = IM_RECT_RIGHT( r );
int bo = IM_RECT_BOTTOM( r );
int ri = VIPS_RECT_RIGHT( r );
int bo = VIPS_RECT_BOTTOM( r );
int nb = in->Bands;
int lsk = IM_REGION_LSKIP( or );
int lsk = VIPS_REGION_LSKIP( or );
int ht = or->im->Ysize;
int x, y, z;
for( x = le; x < ri; x++ ) {
VipsPel *q = IM_REGION_ADDR( or, x, to );
VipsPel *p = IM_IMAGE_ADDR( in, x, 0 );
VipsPel *q = VIPS_REGION_ADDR( or, x, to );
VipsPel *p = VIPS_IMAGE_ADDR( in, x, 0 );
switch( in->BandFmt ) {
case IM_BANDFMT_UCHAR: HORZ( unsigned char ); break;
case IM_BANDFMT_CHAR: HORZ( signed char ); break;
case IM_BANDFMT_USHORT: HORZ( unsigned short ); break;
case IM_BANDFMT_SHORT: HORZ( signed short ); break;
case IM_BANDFMT_UINT: HORZ( unsigned int ); break;
case IM_BANDFMT_INT: HORZ( signed int ); break;
case IM_BANDFMT_FLOAT: HORZ( float ); break;
case IM_BANDFMT_DOUBLE: HORZ( double ); break;
case VIPS_FORMAT_UCHAR: HORZ( unsigned char ); break;
case VIPS_FORMAT_CHAR: HORZ( signed char ); break;
case VIPS_FORMAT_USHORT: HORZ( unsigned short ); break;
case VIPS_FORMAT_SHORT: HORZ( signed short ); break;
case VIPS_FORMAT_UINT: HORZ( unsigned int ); break;
case VIPS_FORMAT_INT: HORZ( signed int ); break;
case VIPS_FORMAT_FLOAT: HORZ( float ); break;
case VIPS_FORMAT_DOUBLE: HORZ( double ); break;
default:
g_assert_not_reached();
@ -215,26 +181,68 @@ make_horz_gen( REGION *or, void *seq, void *a, void *b )
return( 0 );
}
/* Plot image.
*/
static int
plot( IMAGE *in, IMAGE *out )
vips_hist_plot_build( VipsObject *object )
{
double max;
int tsize;
int xsize;
int ysize;
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
VipsHistPlot *plot = (VipsHistPlot *) object;
VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 );
if( im_incheck( in ) ||
im_poutcheck( out ) )
VipsImage *in;
double min, max;
int width, height, tsize;
VipsGenerateFn generate_fn;
g_object_set( plot, "out", vips_image_new(), NULL );
if( VIPS_OBJECT_CLASS( vips_hist_plot_parent_class )->build( object ) )
return( -1 );
in = plot->in;
if( vips_check_uncoded( class->nickname, in ) ||
vips_check_noncomplex( class->nickname, in ) ||
vips_check_hist( class->nickname, in ) )
return( -1 );
if( vips_band_format_isint( in->BandFmt ) ) {
double min;
/* Move min up to 0.
*/
if( vips_min( in, &min, NULL ) ||
vips_linear1( in, &t[0], 1.0, -min, NULL ) )
return( -1 );
in = t[0];
}
else if( vips_band_format_isfloat( in->BandFmt ) ) {
/* Float image: scale min--max to 0--any. Output square
* graph.
*/
int any = in->Xsize * in->Ysize;
if( vips_stats( in, &t[0], NULL ) )
return( -1 );
min = *VIPS_MATRIX( t[0], 0, 0 );
max = *VIPS_MATRIX( t[0], 1, 0 );
if( vips_linear1( in, &t[1],
any / (max - min), -min * any / (max - min), NULL ) )
return( -1 );
in = t[1];
}
if( vips_image_wio_input( in ) )
return( -1 );
/* Find range we will plot.
*/
if( im_max( in, &max ) )
if( vips_max( in, &max, NULL ) )
return( -1 );
g_assert( max >= 0 );
if( in->BandFmt == IM_BANDFMT_UCHAR )
if( in->BandFmt == VIPS_FORMAT_UCHAR )
tsize = 256;
else
tsize = VIPS_CEIL( max );
@ -247,80 +255,30 @@ plot( IMAGE *in, IMAGE *out )
if( in->Xsize == 1 ) {
/* Vertical graph.
*/
xsize = tsize;
ysize = in->Ysize;
width = tsize;
height = in->Ysize;
generate_fn = vips_hist_plot_vert_gen;
}
else {
/* Horizontal graph.
*/
xsize = in->Xsize;
ysize = tsize;
width = in->Xsize;
height = tsize;
generate_fn = vips_hist_plot_horz_gen;
}
/* Set image.
*/
im_initdesc( out, xsize, ysize, in->Bands,
IM_BBITS_BYTE, IM_BANDFMT_UCHAR,
IM_CODING_NONE, IM_TYPE_HISTOGRAM, 1.0, 1.0, 0, 0 );
vips_image_init_fields( plot->out, width, height, in->Bands,
VIPS_FORMAT_UCHAR, VIPS_CODING_NONE,
VIPS_INTERPRETATION_HISTOGRAM,
1.0, 1.0 );
vips_image_pipelinev( plot->out,
VIPS_DEMAND_STYLE_ANY, NULL );
/* Set hints - ANY is ok with us.
*/
if( im_demand_hint( out, IM_ANY, NULL ) )
if( vips_image_generate( plot->out,
NULL, generate_fn, NULL, in, NULL ) )
return( -1 );
/* Generate image.
*/
if( in->Xsize == 1 ) {
if( im_generate( out, NULL, make_vert_gen, NULL, in, NULL ) )
return( -1 );
}
else {
if( im_generate( out, NULL, make_horz_gen, NULL, in, NULL ) )
return( -1 );
}
return( 0 );
}
int
im_histplot( IMAGE *in, IMAGE *out )
{
IMAGE *t1;
if( im_check_hist( "im_histplot", in ) )
return( -1 );
if( !(t1 = im_open_local( out, "im_histplot:1", "p" )) ||
plotalise( in, t1 ) ||
plot( t1, out ) )
return( -1 );
return( 0 );
}
typedef struct _VipsHistPlot {
VipsOperation parent_instance;
VipsImage *in;
VipsImage *out;
} VipsHistPlot;
typedef VipsOperationClass VipsHistPlotClass;
G_DEFINE_TYPE( VipsHistPlot, vips_hist_plot, VIPS_TYPE_OPERATION );
static int
vips_hist_plot_build( VipsObject *object )
{
VipsHistPlot *plot = (VipsHistPlot *) object;
g_object_set( plot, "out", vips_image_new(), NULL );
if( VIPS_OBJECT_CLASS( vips_hist_plot_parent_class )->build( object ) )
return( -1 );
if( im_histplot( plot->in, plot->out ) )
return( -1 );
return( 0 );
}

View File

@ -233,6 +233,8 @@ int vips__byteswap_bool( VipsImage *in, VipsImage **out, gboolean swap );
char *vips__xml_properties( VipsImage *image );
void vips__cairo2rgba( guint32 *buf, int n );
void vips__Lab2LabQ_vec( VipsPel *out, float *in, int width );
void vips__LabQ2Lab_vec( float *out, VipsPel *in, int width );
#ifdef DEBUG_LEAK
extern GQuark vips__image_pixels_quark;
@ -251,6 +253,11 @@ int vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready,
VipsSaveable saveable, VipsBandFormat *format, VipsCoding *coding,
VipsArrayDouble *background );
int vips_foreign_load( const char *filename, VipsImage **out, ... )
__attribute__((sentinel));
int vips_foreign_save( VipsImage *in, const char *filename, ... )
__attribute__((sentinel));
int vips__image_intize( VipsImage *in, VipsImage **out );
void vips__reorder_init( void );

View File

@ -46,6 +46,8 @@
* - include <time.h>, thanks nicola
* 30/6/09
* - move deprecated stuff to its own header
* 16/5/18
* - remove old vips7 stuff, you must explicitly include it now
*/
/*
@ -147,20 +149,6 @@ extern "C" {
#include <vips/video.h>
#include <vips/cimg_funcs.h>
/* This stuff is very, very old and should not be used by anyone now.
*/
#ifdef VIPS_ENABLE_ANCIENT
#include <vips/deprecated.h>
#endif /*VIPS_ENABLE_ANCIENT*/
/* Still in use, but can be turned off.
*/
#ifdef VIPS_ENABLE_DEPRECATED
#include <vips/vips7compat.h>
#include <vips/dispatch.h>
#include <vips/almostdeprecated.h>
#endif /*VIPS_ENABLE_DEPRECATED*/
/* We can't use _ here since this will be compiled by our clients and they may
* not have _().
*/

Some files were not shown because too many files have changed in this diff Show More