more hacking
yet more vipsimage twonking
This commit is contained in:
parent
16b032f8c1
commit
7155550c18
@ -72,6 +72,9 @@ int im_extract( IMAGE *, IMAGE *, IMAGE_BOX * );
|
|||||||
DOUBLEMASK *im_measure( IMAGE *im, IMAGE_BOX *box, int h, int v,
|
DOUBLEMASK *im_measure( IMAGE *im, IMAGE_BOX *box, int h, int v,
|
||||||
int *sel, int nsel, const char *name );
|
int *sel, int nsel, const char *name );
|
||||||
|
|
||||||
|
void error_exit( const char *fmt, ... )
|
||||||
|
__attribute__((noreturn, format(printf, 1, 2)));
|
||||||
|
|
||||||
gboolean im_isuint( IMAGE *im );
|
gboolean im_isuint( IMAGE *im );
|
||||||
gboolean im_isint( IMAGE *im );
|
gboolean im_isint( IMAGE *im );
|
||||||
gboolean im_isfloat( IMAGE *im );
|
gboolean im_isfloat( IMAGE *im );
|
||||||
|
@ -34,25 +34,22 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /*__cplusplus*/
|
#endif /*__cplusplus*/
|
||||||
|
|
||||||
const char *im_error_buffer( void );
|
const char *vips_error_buffer( void );
|
||||||
void im_error_clear( void );
|
void vips_error_clear( void );
|
||||||
|
|
||||||
void im_error( const char *domain, const char *fmt, ... )
|
void vips_error( const char *domain, const char *fmt, ... )
|
||||||
__attribute__((format(printf, 2, 3)));
|
__attribute__((format(printf, 2, 3)));
|
||||||
void im_verror( const char *domain, const char *fmt, va_list ap );
|
void vips_verror( const char *domain, const char *fmt, va_list ap );
|
||||||
void im_error_system( int err, const char *domain, const char *fmt, ... )
|
void vips_error_system( int err, const char *domain, const char *fmt, ... )
|
||||||
__attribute__((format(printf, 3, 4)));
|
__attribute__((format(printf, 3, 4)));
|
||||||
void im_verror_system( int err, const char *domain,
|
void vips_verror_system( int err, const char *domain,
|
||||||
const char *fmt, va_list ap );
|
const char *fmt, va_list ap );
|
||||||
void im_warn( const char *domain, const char *fmt, ... )
|
void vips_warn( const char *domain, const char *fmt, ... )
|
||||||
__attribute__((format(printf, 2, 3)));
|
__attribute__((format(printf, 2, 3)));
|
||||||
void im_vwarn( const char *domain, const char *fmt, va_list ap );
|
void vips_vwarn( const char *domain, const char *fmt, va_list ap );
|
||||||
void im_diag( const char *domain, const char *fmt, ... )
|
void vips_diag( const char *domain, const char *fmt, ... )
|
||||||
__attribute__((format(printf, 2, 3)));
|
__attribute__((format(printf, 2, 3)));
|
||||||
void im_vdiag( const char *domain, const char *fmt, va_list ap );
|
void vips_vdiag( const char *domain, const char *fmt, va_list ap );
|
||||||
|
|
||||||
void error_exit( const char *fmt, ... )
|
|
||||||
__attribute__((noreturn, format(printf, 1, 2)));
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -361,18 +361,6 @@ int vips_format_sizeof( VipsBandFormat format );
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char *vips_get_argv0( void );
|
|
||||||
int vips_init_world( const char *argv0 );
|
|
||||||
GOptionGroup *vips_get_option_group( void );
|
|
||||||
|
|
||||||
const char *vips_version_string( void );
|
|
||||||
int vips_version( int flag );
|
|
||||||
|
|
||||||
const char *vips_guess_prefix( const char *argv0, const char *env_name );
|
|
||||||
const char *vips_guess_libdir( const char *argv0, const char *env_name );
|
|
||||||
|
|
||||||
VipsImage *vips_open( const char *filename, const char *mode );
|
|
||||||
|
|
||||||
#define vips_open_local( IM, NAME, MODE ) \
|
#define vips_open_local( IM, NAME, MODE ) \
|
||||||
((IMAGE *) vips_local( (IM), \
|
((IMAGE *) vips_local( (IM), \
|
||||||
(vips_construct_fn) im_open, (im_callback_fn) im_close, \
|
(vips_construct_fn) im_open, (im_callback_fn) im_close, \
|
||||||
@ -385,8 +373,6 @@ VipsImage *vips_open( const char *filename, const char *mode );
|
|||||||
(im_construct_fn) im_open, (im_callback_fn) im_close, \
|
(im_construct_fn) im_open, (im_callback_fn) im_close, \
|
||||||
(void *) (NAME), (void *) (MODE), NULL ))
|
(void *) (NAME), (void *) (MODE), NULL ))
|
||||||
|
|
||||||
int vips_close( VipsImage *im );
|
|
||||||
|
|
||||||
void vips_invalidate( VipsImage *im );
|
void vips_invalidate( VipsImage *im );
|
||||||
|
|
||||||
void vips_initdesc( VipsImage *image,
|
void vips_initdesc( VipsImage *image,
|
||||||
|
@ -275,6 +275,12 @@ void *vips_class_map_concrete_all( GType base, VipsClassMap fn, void *a );
|
|||||||
VipsObjectClass *vips_class_find( const char *basename, const char *nickname );
|
VipsObjectClass *vips_class_find( const char *basename, const char *nickname );
|
||||||
GType vips_type_find( const char *basename, const char *nickname );
|
GType vips_type_find( const char *basename, const char *nickname );
|
||||||
|
|
||||||
|
// void vips_object_local( VipsObject *vobject, GObject *gobject );
|
||||||
|
void vips_object_local_cb( VipsObject *vobject, GObject *gobject );
|
||||||
|
#define vips_object_local( V, G ) \
|
||||||
|
g_signal_connect( V, "close", \
|
||||||
|
G_CALLBACK( vips_object_local_cb ), G );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /*__cplusplus*/
|
#endif /*__cplusplus*/
|
||||||
|
@ -144,6 +144,16 @@ extern "C" {
|
|||||||
#include <vips/deprecated.h>
|
#include <vips/deprecated.h>
|
||||||
#endif /*VIPS_ENABLE_DEPRECATED*/
|
#endif /*VIPS_ENABLE_DEPRECATED*/
|
||||||
|
|
||||||
|
const char *vips_get_argv0( void );
|
||||||
|
int vips_init( const char *argv0 );
|
||||||
|
GOptionGroup *vips_get_option_group( void );
|
||||||
|
|
||||||
|
const char *vips_version_string( void );
|
||||||
|
int vips_version( int flag );
|
||||||
|
|
||||||
|
const char *vips_guess_prefix( const char *argv0, const char *env_name );
|
||||||
|
const char *vips_guess_libdir( const char *argv0, const char *env_name );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /*__cplusplus*/
|
#endif /*__cplusplus*/
|
||||||
|
@ -382,7 +382,7 @@ vips_image_finalize( GObject *gobject )
|
|||||||
if( image->dtype == VIPS_IMAGE_OPENOUT )
|
if( image->dtype == VIPS_IMAGE_OPENOUT )
|
||||||
(void) im__writehist( image );
|
(void) im__writehist( image );
|
||||||
if( close( image->fd ) == -1 )
|
if( close( image->fd ) == -1 )
|
||||||
im_error( "VipsImage",
|
vips_error( "VipsImage",
|
||||||
_( "unable to close fd for %s" ),
|
_( "unable to close fd for %s" ),
|
||||||
image->filename );
|
image->filename );
|
||||||
image->fd = -1;
|
image->fd = -1;
|
||||||
@ -471,7 +471,7 @@ static void
|
|||||||
lazy_free_cb( Lazy *lazy )
|
lazy_free_cb( Lazy *lazy )
|
||||||
{
|
{
|
||||||
VIPS_FREE( lazy->filename );
|
VIPS_FREE( lazy->filename );
|
||||||
VIPS_UNREF( lazy->image );
|
VIPS_UNREF( lazy->real );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Lazy *
|
static Lazy *
|
||||||
@ -617,16 +617,16 @@ open_lazy_start( VipsImage *out, void *a, void *dummy )
|
|||||||
{
|
{
|
||||||
Lazy *lazy = (Lazy *) a;
|
Lazy *lazy = (Lazy *) a;
|
||||||
|
|
||||||
if( !lazy->image ) {
|
if( !lazy->real ) {
|
||||||
if( !(lazy->real = lazy_real_image( lazy )) ||
|
if( !(lazy->real = lazy_real_image( lazy )) ||
|
||||||
lazy->format->load( lazy->filename, lazy->image ) ||
|
lazy->format->load( lazy->filename, lazy->real ) ||
|
||||||
im_pincheck( lazy->image ) ) {
|
im_pincheck( lazy->real ) ) {
|
||||||
VIPS_UNREF( lazy->image );
|
VIPS_UNREF( lazy->real );
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return( im_region_create( lazy->image ) );
|
return( im_region_create( lazy->real ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Just copy.
|
/* Just copy.
|
||||||
@ -792,17 +792,19 @@ vips_image_add_progress( VipsImage *image )
|
|||||||
static int
|
static int
|
||||||
vips_image_build( VipsObject *object )
|
vips_image_build( VipsObject *object )
|
||||||
{
|
{
|
||||||
VipsImage *image = VIPS_IMAGE (object);
|
VipsImage *image = VIPS_IMAGE( object );
|
||||||
|
const char *filename = image->filename;
|
||||||
|
const char *mode = image->mode;
|
||||||
VipsFormatClass *format;
|
VipsFormatClass *format;
|
||||||
|
|
||||||
VIPS_DEBUG_MSG( "vips_image_build: %p\n", image );
|
VIPS_DEBUG_MSG( "vips_image_build: %p\n", image );
|
||||||
|
|
||||||
/* name defaults to filename.
|
/* name defaults to filename.
|
||||||
*/
|
*/
|
||||||
if( image->filename ) {
|
if( filename ) {
|
||||||
char *basename;
|
char *basename;
|
||||||
|
|
||||||
basename = g_path_get_basename( image->filename );
|
basename = g_path_get_basename( filename );
|
||||||
g_object_set( image, "name", basename, NULL );
|
g_object_set( image, "name", basename, NULL );
|
||||||
g_free( basename );
|
g_free( basename );
|
||||||
}
|
}
|
||||||
@ -812,64 +814,49 @@ vips_image_build( VipsObject *object )
|
|||||||
|
|
||||||
/* Parse the mode string.
|
/* Parse the mode string.
|
||||||
*/
|
*/
|
||||||
switch( image->mode[0] ) {
|
switch( mode[0] ) {
|
||||||
case 'r':
|
case 'r':
|
||||||
if( !(format = vips_format_for_file( image->filename )) )
|
if( !(format = vips_format_for_file( filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips_format_is_vips( format ) ) {
|
if( vips_format_is_vips( format ) ) {
|
||||||
/* We may need to byteswap.
|
/* We may need to byteswap.
|
||||||
*/
|
*/
|
||||||
VipsFormatFlags flags =
|
VipsFormatFlags flags =
|
||||||
vips_format_get_flags( format,
|
vips_format_get_flags( format, filename );
|
||||||
image->filename );
|
gboolean native = (flags & VIPS_FORMAT_BIGENDIAN) ==
|
||||||
gboolean bigendian = flags & VIPS_FORMAT_BIGENDIAN;
|
im_amiMSBfirst();
|
||||||
gboolean swap = bigendian != im_amiMSBfirst();
|
|
||||||
|
|
||||||
if( swap ) {
|
|
||||||
VipsImage *real;
|
|
||||||
|
|
||||||
if( !(real = im_open_local( image, "p" );
|
if( native ) {
|
||||||
image->dtype = VIPS_IMAGE_PARTIAL;
|
if( vips_open_input( image ) )
|
||||||
|
|
||||||
|
|
||||||
if( vips_open_input( image ) )
|
|
||||||
return( -1 );
|
|
||||||
|
|
||||||
if( image->mode[1] == 'w' ) {
|
|
||||||
/* "rw" mode ... just sanity check and tag.
|
|
||||||
* The "rw" bit happens when we do an
|
|
||||||
* operation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* If we have a different byte order
|
|
||||||
* from the image, we can only process
|
|
||||||
* 8 bit images.
|
|
||||||
*/
|
|
||||||
if( vips_image_isMSBfirst( image ) !=
|
|
||||||
im_amiMSBfirst() &&
|
|
||||||
vips_format_sizeof( image->BandFmt ) !=
|
|
||||||
1 ) {
|
|
||||||
im_error( "VipsImage", "%s",
|
|
||||||
_( "open read-"
|
|
||||||
"write for native format "
|
|
||||||
"images only" ) );
|
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
|
||||||
|
|
||||||
image->dtype = VIPS_IMAGE_OPENINRW;
|
if( mode[1] == 'w' )
|
||||||
|
image->dtype = VIPS_IMAGE_MMAPINRW;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
VipsImage *x;
|
||||||
|
|
||||||
|
if( !(x = vips_open( filename, "p" )) )
|
||||||
|
return( -1 );
|
||||||
|
vips_object_local( image, x );
|
||||||
|
if( vips_open_input( x ) )
|
||||||
|
return( -1 );
|
||||||
|
image->dtype = VIPS_IMAGE_PARTIAL;
|
||||||
|
if( im_copy_swap( x, image ) )
|
||||||
|
return( -1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( vips_open_lazy( image, format,
|
if( vips_open_lazy( image, format,
|
||||||
image->filename, image->mode[1] == 'd' ) )
|
filename, mode[1] == 'd' ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'w':
|
case 'w':
|
||||||
if( !(format = vips_format_for_name( image->filename )) )
|
if( !(format = vips_format_for_name( filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips_format_is_vips( format ) )
|
if( vips_format_is_vips( format ) )
|
||||||
@ -877,13 +864,13 @@ vips_image_build( VipsObject *object )
|
|||||||
else {
|
else {
|
||||||
image->dtype = VIPS_IMAGE_PARTIAL;
|
image->dtype = VIPS_IMAGE_PARTIAL;
|
||||||
vips_attach_save( image,
|
vips_attach_save( image,
|
||||||
format->save, image->filename );
|
format->save, filename );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
image->dtype = VIPS_IMAGE_SETBUF;
|
image->dtype = VIPS_IMAGE_SETBUF;
|
||||||
image->dhint = VIPS_DEMAND_ANY;
|
image->dhint = VIPS_DEMAND_STYLE_ANY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
@ -891,7 +878,7 @@ vips_image_build( VipsObject *object )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
im_error( "VipsImage", _( "bad mode \"%s\"" ), mode );
|
vips_error( "VipsImage", _( "bad mode \"%s\"" ), mode );
|
||||||
|
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
@ -918,8 +905,8 @@ vips_image_class_init( VipsImageClass *class )
|
|||||||
* for old programs which are missing an im_init_world() call. We must
|
* for old programs which are missing an im_init_world() call. We must
|
||||||
* have threads set up before we can process.
|
* have threads set up before we can process.
|
||||||
*/
|
*/
|
||||||
if( im_init_world( "vips" ) )
|
if( vips_init( "vips" ) )
|
||||||
im_error_clear();
|
vips_error_clear();
|
||||||
|
|
||||||
gobject_class->finalize = vips_image_finalize;
|
gobject_class->finalize = vips_image_finalize;
|
||||||
gobject_class->dispose = vips_image_dispose;
|
gobject_class->dispose = vips_image_dispose;
|
||||||
@ -997,7 +984,7 @@ vips_image_class_init( VipsImageClass *class )
|
|||||||
|
|
||||||
pspec = g_param_spec_enum( "demand", "Demand",
|
pspec = g_param_spec_enum( "demand", "Demand",
|
||||||
_( "Preferred demand style for this image" ),
|
_( "Preferred demand style for this image" ),
|
||||||
VIPS_TYPE_DEMAND, VIPS_DEMAND_SMALLTILE,
|
VIPS_TYPE_DEMAND_STYLE, VIPS_DEMAND_STYLE_SMALLTILE,
|
||||||
G_PARAM_READWRITE );
|
G_PARAM_READWRITE );
|
||||||
g_object_class_install_property( gobject_class, PROP_DEMAND, pspec );
|
g_object_class_install_property( gobject_class, PROP_DEMAND, pspec );
|
||||||
vips_object_class_install_argument( vobject_class, pspec,
|
vips_object_class_install_argument( vobject_class, pspec,
|
||||||
@ -1420,7 +1407,7 @@ int
|
|||||||
vips_format_sizeof( VipsBandFormat format )
|
vips_format_sizeof( VipsBandFormat format )
|
||||||
{
|
{
|
||||||
return( (format < 0 || format > VIPS_FORMAT_DPCOMPLEX) ?
|
return( (format < 0 || format > VIPS_FORMAT_DPCOMPLEX) ?
|
||||||
im_error( "vips_format_sizeof",
|
vips_error( "vips_format_sizeof",
|
||||||
_( "unknown band format %d" ), format ), -1 :
|
_( "unknown band format %d" ), format ), -1 :
|
||||||
vips_image__sizeof_bandfmt[format] );
|
vips_image__sizeof_bandfmt[format] );
|
||||||
}
|
}
|
||||||
|
@ -1173,3 +1173,16 @@ vips_object_map( VSListMap2Fn fn, void *a, void *b )
|
|||||||
|
|
||||||
return( args.result );
|
return( args.result );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vips_object_local_cb( VipsObject *vobject, GObject *gobject )
|
||||||
|
{
|
||||||
|
g_object_unref( gobject );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vips_object_local( VipsObject *vobject, GObject *gobject )
|
||||||
|
{
|
||||||
|
g_signal_connect( vobject, "close",
|
||||||
|
G_CALLBACK( vips_object_local_cb ), gobject );
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user