fix up foreignflags
This commit is contained in:
parent
878edcf4ea
commit
89a65c81d2
4
TODO
4
TODO
@ -1,6 +1,4 @@
|
||||
- test vips_foreign_load_vips_get_flags(), sense inverted?
|
||||
|
||||
test load/save jpeg buffer
|
||||
- test load/save jpeg buffer
|
||||
|
||||
leaktest
|
||||
|
||||
|
@ -145,7 +145,7 @@ vips_copy_swap2( PEL *in, PEL *out, int width, VipsImage *im )
|
||||
int x;
|
||||
|
||||
for( x = 0; x < sz; x++ )
|
||||
out[x] = GUINT16_SWAP_LE_BE( in[x] );
|
||||
q[x] = GUINT16_SWAP_LE_BE( p[x] );
|
||||
}
|
||||
|
||||
/* Swap 4- of bytes.
|
||||
@ -160,7 +160,7 @@ vips_copy_swap4( PEL *in, PEL *out, int width, VipsImage *im )
|
||||
int x;
|
||||
|
||||
for( x = 0; x < sz; x++ )
|
||||
out[x] = GUINT32_SWAP_LE_BE( in[x] );
|
||||
q[x] = GUINT32_SWAP_LE_BE( p[x] );
|
||||
}
|
||||
|
||||
/* Swap 8- of bytes.
|
||||
@ -175,7 +175,7 @@ vips_copy_swap8( PEL *in, PEL *out, int width, VipsImage *im )
|
||||
int x;
|
||||
|
||||
for( x = 0; x < sz; x++ )
|
||||
out[x] = GUINT64_SWAP_LE_BE( in[x] );
|
||||
q[x] = GUINT64_SWAP_LE_BE( p[x] );
|
||||
}
|
||||
|
||||
typedef void (*SwapFn)( PEL *in, PEL *out, int width, VipsImage *im );
|
||||
|
@ -528,9 +528,12 @@ vips_foreign_load_build( VipsObject *object )
|
||||
VipsForeignLoad *load = VIPS_FOREIGN_LOAD( object );
|
||||
VipsForeignLoadClass *class = VIPS_FOREIGN_LOAD_GET_CLASS( object );
|
||||
|
||||
if( class->get_flags &&
|
||||
class->get_flags( load ) )
|
||||
return( -1 );
|
||||
VipsForeignFlags flags;
|
||||
|
||||
flags = 0;
|
||||
if( class->get_flags )
|
||||
flags |= class->get_flags( load );
|
||||
g_object_set( load, "flags", flags, NULL );
|
||||
|
||||
if( VIPS_OBJECT_CLASS( vips_foreign_load_parent_class )->
|
||||
build( object ) )
|
||||
@ -605,7 +608,6 @@ vips_foreign_load_class_init( VipsForeignLoadClass *class )
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoad, disc ),
|
||||
TRUE );
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -62,21 +62,18 @@ vips_foreign_load_vips_is_a( const char *filename )
|
||||
return( vips__file_magic( filename ) );
|
||||
}
|
||||
|
||||
static int
|
||||
static VipsForeignFlags
|
||||
vips_foreign_load_vips_get_flags( VipsForeignLoad *load )
|
||||
{
|
||||
VipsForeignLoadVips *vips = (VipsForeignLoadVips *) load;
|
||||
VipsForeignFlags flags;
|
||||
|
||||
load->flags = VIPS_FOREIGN_PARTIAL;
|
||||
flags = VIPS_FOREIGN_PARTIAL;
|
||||
|
||||
if( vips__file_magic( vips->filename ) == VIPS_MAGIC_INTEL ) {
|
||||
printf( "vips_foreign_load_vips_get_flags: "
|
||||
"%s is intel, setting bigendian\n",
|
||||
vips->filename );
|
||||
load->flags |= VIPS_FOREIGN_BIGENDIAN;
|
||||
}
|
||||
if( vips__file_magic( vips->filename ) == VIPS_MAGIC_SPARC )
|
||||
flags |= VIPS_FOREIGN_BIGENDIAN;
|
||||
|
||||
return( 0 );
|
||||
return( flags );
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -88,7 +88,8 @@ void *vips_foreign_map( const char *base,
|
||||
typedef enum {
|
||||
VIPS_FOREIGN_NONE = 0, /* No flags set */
|
||||
VIPS_FOREIGN_PARTIAL = 1, /* Lazy read OK (eg. tiled tiff) */
|
||||
VIPS_FOREIGN_BIGENDIAN = 2 /* Most-significant byte first */
|
||||
VIPS_FOREIGN_BIGENDIAN = 2, /* Most-significant byte first */
|
||||
VIPS_FOREIGN_ALL = 3 /* All flags set */
|
||||
} VipsForeignFlags;
|
||||
|
||||
#define VIPS_TYPE_FOREIGN_LOAD (vips_foreign_load_get_type())
|
||||
@ -134,15 +135,15 @@ typedef struct _VipsForeignLoadClass {
|
||||
|
||||
/*< public >*/
|
||||
|
||||
/* Is a foreign in this format.
|
||||
/* Is a file in this format.
|
||||
*/
|
||||
gboolean (*is_a)( const char * );
|
||||
|
||||
/* Get the flags for this foreign.
|
||||
/* Get the flags for this file.
|
||||
*/
|
||||
int (*get_flags)( VipsForeignLoad * );
|
||||
VipsForeignFlags (*get_flags)( VipsForeignLoad * );
|
||||
|
||||
/* Set the header fields in @out from @foreignname. If you can read the
|
||||
/* Set the header fields in @out from @filename. If you can read the
|
||||
* whole image as well with no performance cost (as with vipsload),
|
||||
* leave ->load() NULL and only @header will be used.
|
||||
*/
|
||||
|
@ -15,6 +15,7 @@ vips_foreign_flags_get_type( void )
|
||||
{VIPS_FOREIGN_NONE, "VIPS_FOREIGN_NONE", "none"},
|
||||
{VIPS_FOREIGN_PARTIAL, "VIPS_FOREIGN_PARTIAL", "partial"},
|
||||
{VIPS_FOREIGN_BIGENDIAN, "VIPS_FOREIGN_BIGENDIAN", "bigendian"},
|
||||
{VIPS_FOREIGN_ALL, "VIPS_FOREIGN_ALL", "all"},
|
||||
{0, NULL, NULL}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user