renaming header.c
reworking header.c
This commit is contained in:
parent
9f3c8d468a
commit
2938d9a086
@ -37,21 +37,36 @@
|
||||
extern "C" {
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
int im_header_int( VipsImage *im, const char *field, int *out );
|
||||
int im_header_double( VipsImage *im, const char *field, double *out );
|
||||
int im_header_string( VipsImage *im, const char *field, char **out );
|
||||
int im_header_as_string( VipsImage *im, const char *field, char **out );
|
||||
GType im_header_get_typeof( VipsImage *im, const char *field );
|
||||
int im_header_get( VipsImage *im, const char *field, GValue *value_copy );
|
||||
int vips_image_get_width( VipsImage *image );
|
||||
int vips_image_get_height( VipsImage *image );
|
||||
int vips_image_get_bands( VipsImage *image );
|
||||
VipsBandFormat vips_image_get_format( VipsImage *image );
|
||||
VipsCoding vips_image_get_coding( VipsImage *image );
|
||||
VipsInterpretation vips_image_get_interpretation( VipsImage *image );
|
||||
double vips_image_get_xres( VipsImage *image );
|
||||
double vips_image_get_yres( VipsImage *image );
|
||||
int vips_image_get_xoffset( VipsImage *image );
|
||||
int vips_image_get_yoffset( VipsImage *image );
|
||||
const char *vips_image_get_filename( VipsImage *image );
|
||||
const char *vips_image_get_mode( VipsImage *image );
|
||||
size_t vips_image_get_size( VipsImage *image );
|
||||
|
||||
typedef void *(*im_header_map_fn)( VipsImage *,
|
||||
const char *, GValue *, void * );
|
||||
void *im_header_map( VipsImage *im, im_header_map_fn fn, void *a );
|
||||
int vips_image_get_int( VipsImage *im, const char *field, int *out );
|
||||
int vips_image_get_double( VipsImage *im, const char *field, double *out );
|
||||
int vips_image_get_string( VipsImage *im, const char *field, char **out );
|
||||
int vips_image_get_as_string( VipsImage *im, const char *field, char **out );
|
||||
GType vips_image_get_typeof( VipsImage *im, const char *field );
|
||||
int vips_image_get( VipsImage *im, const char *field, GValue *value_copy );
|
||||
|
||||
int im_histlin( VipsImage *im, const char *fmt, ... )
|
||||
typedef void *(*VipsImageHeaderMapFn)( VipsImage *image,
|
||||
const char *field, GValue *value, void *a );
|
||||
void *vips_image_header_map( VipsImage *im, VipsImageHeaderMapFn fn, void *a );
|
||||
|
||||
int vips_image_history_printf( VipsImage *image, const char *format, ... )
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
int im_updatehist( VipsImage *out, const char *name, int argc, char *argv[] );
|
||||
const char *im_history_get( VipsImage *im );
|
||||
int vips_image_history_args( VipsImage *image,
|
||||
const char *name, int argc, char *argv[] );
|
||||
const char *vips_image_get_history( VipsImage *image );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -339,20 +339,6 @@ extern const size_t vips__image_sizeof_bandformat[];
|
||||
(X) * VIPS_IMAGE_SIZEOF_PEL( I ))
|
||||
#endif /*VIPS_DEBUG*/
|
||||
|
||||
int vips_image_get_width( VipsImage *image );
|
||||
int vips_image_get_height( VipsImage *image );
|
||||
int vips_image_get_bands( VipsImage *image );
|
||||
VipsBandFormat vips_image_get_format( VipsImage *image );
|
||||
VipsCoding vips_image_get_coding( VipsImage *image );
|
||||
VipsInterpretation vips_image_get_interpretation( VipsImage *image );
|
||||
double vips_image_get_xres( VipsImage *image );
|
||||
double vips_image_get_yres( VipsImage *image );
|
||||
int vips_image_get_xoffset( VipsImage *image );
|
||||
int vips_image_get_yoffset( VipsImage *image );
|
||||
const char *vips_image_get_filename( VipsImage *image );
|
||||
const char *vips_image_get_mode( VipsImage *image );
|
||||
size_t vips_image_size( VipsImage *image );
|
||||
|
||||
void vips_image_written( VipsImage *image );
|
||||
void vips_image_invalidate_all( VipsImage *image );
|
||||
void vips_image_preeval( VipsImage *image );
|
||||
|
@ -18,6 +18,9 @@
|
||||
* 1/10/09
|
||||
* - rename as header.c
|
||||
* - gtkdoc comments
|
||||
* 22/3/11
|
||||
* - rename fields for vips8
|
||||
* - move to vips_ prefix
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -98,29 +101,107 @@ typedef struct _HeaderField {
|
||||
/* Built in fields and struct offsets.
|
||||
*/
|
||||
static HeaderField int_field[] = {
|
||||
{ "Xsize", G_STRUCT_OFFSET( IMAGE, Xsize ) },
|
||||
{ "Ysize", G_STRUCT_OFFSET( IMAGE, Ysize ) },
|
||||
{ "Bands", G_STRUCT_OFFSET( IMAGE, Bands ) },
|
||||
{ "Bbits", G_STRUCT_OFFSET( IMAGE, Bbits ) },
|
||||
{ "BandFmt", G_STRUCT_OFFSET( IMAGE, BandFmt ) },
|
||||
{ "Coding", G_STRUCT_OFFSET( IMAGE, Coding ) },
|
||||
{ "Type", G_STRUCT_OFFSET( IMAGE, Type ) },
|
||||
{ "Xoffset", G_STRUCT_OFFSET( IMAGE, Xoffset ) },
|
||||
{ "Yoffset", G_STRUCT_OFFSET( IMAGE, Yoffset ) }
|
||||
{ "width", G_STRUCT_OFFSET( IMAGE, Xsize ) },
|
||||
{ "height", G_STRUCT_OFFSET( IMAGE, Ysize ) },
|
||||
{ "bands", G_STRUCT_OFFSET( IMAGE, Bands ) },
|
||||
{ "format", G_STRUCT_OFFSET( IMAGE, BandFmt ) },
|
||||
{ "coding", G_STRUCT_OFFSET( IMAGE, Coding ) },
|
||||
{ "interpretation", G_STRUCT_OFFSET( IMAGE, Type ) },
|
||||
{ "xoffset", G_STRUCT_OFFSET( IMAGE, Xoffset ) },
|
||||
{ "yoffset", G_STRUCT_OFFSET( IMAGE, Yoffset ) }
|
||||
};
|
||||
|
||||
/* These are actually floats :-( how annoying. We report them as doubles for
|
||||
* consistency with the im_meta_*() functions.
|
||||
*/
|
||||
static HeaderField double_field[] = {
|
||||
{ "Xres", G_STRUCT_OFFSET( IMAGE, Xres ) },
|
||||
{ "Yres", G_STRUCT_OFFSET( IMAGE, Yres ) }
|
||||
{ "xres", G_STRUCT_OFFSET( IMAGE, Xres ) },
|
||||
{ "yres", G_STRUCT_OFFSET( IMAGE, Yres ) }
|
||||
};
|
||||
|
||||
static HeaderField string_field[] = {
|
||||
{ "filename", G_STRUCT_OFFSET( IMAGE, filename ) }
|
||||
};
|
||||
|
||||
int
|
||||
vips_image_get_width( VipsImage *image )
|
||||
{
|
||||
return( image->Xsize );
|
||||
}
|
||||
|
||||
int
|
||||
vips_image_get_height( VipsImage *image )
|
||||
{
|
||||
return( image->Ysize );
|
||||
}
|
||||
|
||||
int
|
||||
vips_image_get_bands( VipsImage *image )
|
||||
{
|
||||
return( image->Bands );
|
||||
}
|
||||
|
||||
VipsBandFormat
|
||||
vips_image_get_format( VipsImage *image )
|
||||
{
|
||||
return( image->BandFmt );
|
||||
}
|
||||
|
||||
VipsCoding
|
||||
vips_image_get_coding( VipsImage *image )
|
||||
{
|
||||
return( image->Coding );
|
||||
}
|
||||
|
||||
VipsInterpretation
|
||||
vips_image_get_interpretation( VipsImage *image )
|
||||
{
|
||||
return( image->Type );
|
||||
}
|
||||
|
||||
double
|
||||
vips_image_get_xres( VipsImage *image )
|
||||
{
|
||||
return( image->Xres );
|
||||
}
|
||||
|
||||
double
|
||||
vips_image_get_yres( VipsImage *image )
|
||||
{
|
||||
return( image->Yres );
|
||||
}
|
||||
|
||||
int
|
||||
vips_image_get_xoffset( VipsImage *image )
|
||||
{
|
||||
return( image->Xoffset );
|
||||
}
|
||||
|
||||
int
|
||||
vips_image_get_yoffset( VipsImage *image )
|
||||
{
|
||||
return( image->Yoffset );
|
||||
}
|
||||
|
||||
const char *
|
||||
vips_image_get_filename( VipsImage *image )
|
||||
{
|
||||
return( image->filename );
|
||||
}
|
||||
|
||||
const char *
|
||||
vips_image_get_mode( VipsImage *image )
|
||||
{
|
||||
return( image->mode );
|
||||
}
|
||||
|
||||
size_t
|
||||
vips_image_get_size( VipsImage *image )
|
||||
{
|
||||
return( VIPS_IMAGE_SIZEOF_LINE( image ) * image->Ysize );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* im_header_int:
|
||||
* @im: image to get the header field from
|
||||
|
@ -433,10 +433,6 @@ print_field_fn( IMAGE *im, const char *field, GValue *value, VipsBuf *buf )
|
||||
const char *extra;
|
||||
char *str_value;
|
||||
|
||||
str_value = g_strdup_value_contents( value );
|
||||
vips_buf_appendf( buf, "%s: %s", field, str_value );
|
||||
g_free( str_value );
|
||||
|
||||
/* Look for known enums and decode them.
|
||||
*/
|
||||
extra = NULL;
|
||||
@ -450,6 +446,10 @@ print_field_fn( IMAGE *im, const char *field, GValue *value, VipsBuf *buf )
|
||||
extra = VIPS_ENUM_NICK(
|
||||
VIPS_TYPE_INTERPRETATION, g_value_get_int( value ) );
|
||||
|
||||
str_value = g_strdup_value_contents( value );
|
||||
vips_buf_appendf( buf, "%s: %s", field, str_value );
|
||||
g_free( str_value );
|
||||
|
||||
if( extra )
|
||||
vips_buf_appendf( buf, " - %s", extra );
|
||||
|
||||
@ -699,7 +699,7 @@ lazy_real_image( Lazy *lazy )
|
||||
disc_threshold() &&
|
||||
!(vips_format_get_flags( lazy->format, lazy->filename ) &
|
||||
VIPS_FORMAT_PARTIAL) &&
|
||||
vips_image_size( lazy->image ) > disc_threshold() ) {
|
||||
vips_image_get_size( lazy->image ) > disc_threshold() ) {
|
||||
if( !(real = vips_image_new_disc_temp( "%s.v" )) )
|
||||
return( NULL );
|
||||
|
||||
@ -1009,7 +1009,7 @@ vips_image_build( VipsObject *object )
|
||||
|
||||
/* Very common, so a special message.
|
||||
*/
|
||||
if( image->file_length < vips_image_size( image ) ) {
|
||||
if( image->file_length < vips_image_get_size( image ) ) {
|
||||
vips_error( "VipsImage",
|
||||
_( "unable to open %s: file too short" ),
|
||||
image->filename );
|
||||
@ -1019,7 +1019,7 @@ vips_image_build( VipsObject *object )
|
||||
/* Just weird. Only print a warning for this, since we should
|
||||
* still be able to process it without coredumps.
|
||||
*/
|
||||
if( image->file_length > vips_image_size( image ) )
|
||||
if( image->file_length > vips_image_get_size( image ) )
|
||||
vips_warn( "VipsImage",
|
||||
_( "%s is longer than expected" ),
|
||||
image->filename );
|
||||
@ -1256,87 +1256,6 @@ vips_image_init( VipsImage *image )
|
||||
image->sizeof_header = IM_SIZEOF_HEADER;
|
||||
}
|
||||
|
||||
/* Set of access functions.
|
||||
*/
|
||||
|
||||
int
|
||||
vips_image_get_width( VipsImage *image )
|
||||
{
|
||||
return( image->Xsize );
|
||||
}
|
||||
|
||||
int
|
||||
vips_image_get_height( VipsImage *image )
|
||||
{
|
||||
return( image->Ysize );
|
||||
}
|
||||
|
||||
int
|
||||
vips_image_get_bands( VipsImage *image )
|
||||
{
|
||||
return( image->Bands );
|
||||
}
|
||||
|
||||
VipsBandFormat
|
||||
vips_image_get_format( VipsImage *image )
|
||||
{
|
||||
return( image->BandFmt );
|
||||
}
|
||||
|
||||
VipsCoding
|
||||
vips_image_get_coding( VipsImage *image )
|
||||
{
|
||||
return( image->Coding );
|
||||
}
|
||||
|
||||
VipsInterpretation
|
||||
vips_image_get_interpretation( VipsImage *image )
|
||||
{
|
||||
return( image->Type );
|
||||
}
|
||||
|
||||
double
|
||||
vips_image_get_xres( VipsImage *image )
|
||||
{
|
||||
return( image->Xres );
|
||||
}
|
||||
|
||||
double
|
||||
vips_image_get_yres( VipsImage *image )
|
||||
{
|
||||
return( image->Yres );
|
||||
}
|
||||
|
||||
int
|
||||
vips_image_get_xoffset( VipsImage *image )
|
||||
{
|
||||
return( image->Xoffset );
|
||||
}
|
||||
|
||||
int
|
||||
vips_image_get_yoffset( VipsImage *image )
|
||||
{
|
||||
return( image->Yoffset );
|
||||
}
|
||||
|
||||
const char *
|
||||
vips_image_get_filename( VipsImage *image )
|
||||
{
|
||||
return( image->filename );
|
||||
}
|
||||
|
||||
const char *
|
||||
vips_image_get_mode( VipsImage *image )
|
||||
{
|
||||
return( image->mode );
|
||||
}
|
||||
|
||||
size_t
|
||||
vips_image_size( VipsImage *image )
|
||||
{
|
||||
return( VIPS_IMAGE_SIZEOF_LINE( image ) * image->Ysize );
|
||||
}
|
||||
|
||||
void
|
||||
vips_image_written( VipsImage *image )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user