diff --git a/libvips/arithmetic/project.c b/libvips/arithmetic/project.c index 6b61686a..69cb28e9 100644 --- a/libvips/arithmetic/project.c +++ b/libvips/arithmetic/project.c @@ -97,7 +97,7 @@ histogram_new( VipsProject *project ) VipsStatistic *statistic = VIPS_STATISTIC( project ); VipsImage *in = statistic->ready; VipsBandFormat outfmt = vips_project_format_table[in->BandFmt]; - int psize = vips__image_sizeof_bandformat[outfmt] * in->Bands; + int psize = vips_format_sizeof( outfmt ) * in->Bands; Histogram *hist; diff --git a/libvips/arithmetic/unaryconst.c b/libvips/arithmetic/unaryconst.c index 9bc7f0f5..a0fe5063 100644 --- a/libvips/arithmetic/unaryconst.c +++ b/libvips/arithmetic/unaryconst.c @@ -92,8 +92,7 @@ make_pixel( VipsObject *obj, VipsPel *q; int i; - if( !(q = VIPS_ARRAY( obj, - m * vips__image_sizeof_bandformat[fmt], VipsPel )) ) + if( !(q = VIPS_ARRAY( obj, m * vips_format_sizeof( fmt ), VipsPel )) ) return( NULL ); switch( fmt ) { diff --git a/libvips/include/vips/image.h b/libvips/include/vips/image.h index 3e1beea1..dfc3eba2 100644 --- a/libvips/include/vips/image.h +++ b/libvips/include/vips/image.h @@ -350,12 +350,10 @@ GType vips_image_get_type( void ); /* Has to be guint64 and not size_t/off_t since we have to be able to address * huge images on platforms with 32-bit files. */ -extern const guint64 vips__image_sizeof_bandformat[]; - /* Pixel address calculation macros. */ #define VIPS_IMAGE_SIZEOF_ELEMENT( I ) \ - (vips__image_sizeof_bandformat[(I)->BandFmt]) + (vips_format_sizeof((I)->BandFmt)) #define VIPS_IMAGE_SIZEOF_PEL( I ) \ (VIPS_IMAGE_SIZEOF_ELEMENT( I ) * (I)->Bands) #define VIPS_IMAGE_SIZEOF_LINE( I ) \ diff --git a/libvips/include/vips/vips7compat.h b/libvips/include/vips/vips7compat.h index 3bf8cdf5..03a76150 100644 --- a/libvips/include/vips/vips7compat.h +++ b/libvips/include/vips/vips7compat.h @@ -182,7 +182,7 @@ extern "C" { /* Renamed externs. */ - +extern const guint64 vips__image_sizeof_bandformat[]; #define im__sizeof_bandfmt vips__image_sizeof_bandformat /* Renamed functions. diff --git a/libvips/iofuncs/header.c b/libvips/iofuncs/header.c index b37dfb12..d38a8d87 100644 --- a/libvips/iofuncs/header.c +++ b/libvips/iofuncs/header.c @@ -165,10 +165,12 @@ static HeaderField old_double_field[] = { }; /* This is used by (eg.) VIPS_IMAGE_SIZEOF_ELEMENT() to calculate object - * size. + * size via vips_format_sizeof(). * * It needs to be guint64 and not size_t since we use this as the basis for * image address calcs and they have to be 64-bit, even on 32-bit machines. + * + * Can't be static, we need this to be visible for vips7 compat. */ const guint64 vips__image_sizeof_bandformat[] = { sizeof( unsigned char ), /* VIPS_FORMAT_UCHAR */ @@ -187,15 +189,15 @@ const guint64 vips__image_sizeof_bandformat[] = { * vips_format_sizeof: * @format: format type * - * Returns: number of bytes for a band format, or -1 on error. + * Returns: number of bytes for a band format. */ guint64 vips_format_sizeof( VipsBandFormat format ) { - return( (format < 0 || format > VIPS_FORMAT_DPCOMPLEX) ? - vips_error( "vips_format_sizeof", - _( "unknown band format %d" ), format ), -1 : - vips__image_sizeof_bandformat[format] ); + g_assert( format >= 0 && + format < VIPS_FORMAT_LAST ); + + return( vips__image_sizeof_bandformat[format] ); } #ifdef DEBUG