remove vips__image_sizeof_bandformat

we had main API macros which used an array behind the scenes,
vips__image_sizeof_bandformat[]. Swap this for a function,
vips_format_sizeof(), to help DLLs.

the array symbol is still there for compatibility
This commit is contained in:
John Cupitt 2015-04-20 14:18:17 +01:00
parent 46259f934f
commit 7495690cd6
5 changed files with 12 additions and 13 deletions

View File

@ -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;

View File

@ -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 ) {

View File

@ -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 ) \

View File

@ -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.

View File

@ -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