more VipsImage props

expose more fields of VipsImage as props
This commit is contained in:
John Cupitt 2011-09-30 13:59:05 +01:00
parent 1c65d74325
commit c0610db15d
4 changed files with 125 additions and 78 deletions

View File

@ -19,6 +19,7 @@
- added vips_shutdown() - added vips_shutdown()
- added --vips-leak flag - added --vips-leak flag
- added VipsCopy - added VipsCopy
- more VipsImage props
10/8/11 started 7.26.3 10/8/11 started 7.26.3
- don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this - don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this

14
TODO
View File

@ -1,20 +1,10 @@
- VipsCopy needs optional params for all header fields it can change - vipscopy
need a vips_argument_lookup(), see vips_argument_map(), since we need to
be able to find out if an optional arg has been set
added vips_object_get_argument(), look for use of
g_object_class_find_property() and swap for new thing, then back to copy.c
operation.c could use it too in places
copy.c things to set interpretation etc. could go into image.c
how would we do meta sets? how would we do meta sets?
copy_swap needs doing too, a separate class I guess copy_swap needs doing too, a separate class I guess
or add a "swap" prop and an enum like VIPS_SWAP8, VIPS_SWAP2 etc.? or add a "swap" prop? we have a enum for native etc. somewhere

View File

@ -109,22 +109,19 @@
*/ */
/* Properties. /* Properties.
*
* Order important! Keep in sync with vips_copy_names[] below.
*/ */
enum { enum {
PROP_INPUT = 1, PROP_INPUT = 1,
PROP_WIDTH,
PROP_HEIGHT,
PROP_BANDS,
PROP_FORMAT,
PROP_CODING,
PROP_INTERPRETATION, PROP_INTERPRETATION,
PROP_XRES, PROP_XRES,
PROP_YRES, PROP_YRES,
PROP_XOFFSET, PROP_XOFFSET,
PROP_YOFFSET, PROP_YOFFSET,
PROP_BANDS,
PROP_FORMAT,
PROP_CODING,
PROP_WIDTH,
PROP_HEIGHT,
PROP_LAST PROP_LAST
}; };
@ -178,18 +175,16 @@ vips_copy_gen( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop )
/* The props we copy, if set, from the operation to the image. /* The props we copy, if set, from the operation to the image.
*/ */
static const char *vips_copy_names[] = { static const char *vips_copy_names[] = {
NULL, /* unused */ "interpretation",
NULL, /* PROP_INPUT = 1 */ "xres",
"interpretation", /* PROP_INTERPRETATION, */ "yres",
"xres", /* PROP_XRES, */ "xoffset",
"yres", /* PROP_YRES, */ "xoffset",
"xoffset", /* PROP_XOFFSET, */ "bands",
"xoffset", /* PROP_YOFFSET, */ "format",
"bands", /* PROP_BANDS, */ "coding",
"format", /* PROP_FORMAT, */ "width",
"coding", /* PROP_CODING, */ "height"
"width", /* PROP_WIDTH, */
"height" /* PROP_HEIGHT, */
}; };
static int static int
@ -214,7 +209,7 @@ vips_copy_build( VipsObject *object )
/* Use props to adjust header fields. /* Use props to adjust header fields.
*/ */
for( i = 2; i < PROP_LAST; i++ ) { for( i = 0; i < VIPS_NUMBER( vips_copy_names ); i++ ) {
const char *name = vips_copy_names[i]; const char *name = vips_copy_names[i];
GParamSpec *pspec; GParamSpec *pspec;
@ -274,6 +269,51 @@ vips_copy_class_init( VipsCopyClass *class )
VIPS_ARGUMENT_REQUIRED_INPUT, VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsCopy, input ) ); G_STRUCT_OFFSET( VipsCopy, input ) );
pspec = g_param_spec_int( "width", "Width",
_( "Image width in pixels" ),
0, 1000000, 0,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_WIDTH, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsCopy, width ) );
pspec = g_param_spec_int( "height", "Height",
_( "Image height in pixels" ),
0, 1000000, 0,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_HEIGHT, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsCopy, height ) );
pspec = g_param_spec_int( "bands", "Bands",
_( "Number of bands in image" ),
0, 1000000, 0,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_BANDS, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsCopy, bands ) );
pspec = g_param_spec_enum( "format", "Format",
_( "Pixel format in image" ),
VIPS_TYPE_BAND_FORMAT, VIPS_FORMAT_UCHAR,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_FORMAT, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsCopy, format ) );
pspec = g_param_spec_enum( "coding", "Coding",
_( "Pixel coding" ),
VIPS_TYPE_CODING, VIPS_CODING_NONE,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_CODING, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsCopy, coding ) );
pspec = g_param_spec_enum( "interpretation", "Interpretation", pspec = g_param_spec_enum( "interpretation", "Interpretation",
_( "Pixel interpretation" ), _( "Pixel interpretation" ),
VIPS_TYPE_INTERPRETATION, VIPS_INTERPRETATION_MULTIBAND, VIPS_TYPE_INTERPRETATION, VIPS_INTERPRETATION_MULTIBAND,
@ -320,51 +360,6 @@ vips_copy_class_init( VipsCopyClass *class )
VIPS_ARGUMENT_SET_ONCE, VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsCopy, yoffset ) ); G_STRUCT_OFFSET( VipsCopy, yoffset ) );
pspec = g_param_spec_int( "bands", "Bands",
_( "Number of bands in image" ),
0, 1000000, 0,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_BANDS, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsCopy, bands ) );
pspec = g_param_spec_enum( "format", "Format",
_( "Pixel format in image" ),
VIPS_TYPE_BAND_FORMAT, VIPS_FORMAT_UCHAR,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_FORMAT, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsCopy, format ) );
pspec = g_param_spec_enum( "coding", "Coding",
_( "Pixel coding" ),
VIPS_TYPE_CODING, VIPS_CODING_NONE,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_FORMAT, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsCopy, coding ) );
pspec = g_param_spec_int( "width", "Width",
_( "Image width in pixels" ),
0, 1000000, 0,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_WIDTH, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsCopy, width ) );
pspec = g_param_spec_int( "height", "Height",
_( "Image height in pixels" ),
0, 1000000, 0,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_HEIGHT, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsCopy, height ) );
} }
static void static void

View File

@ -150,6 +150,12 @@ enum {
PROP_HEIGHT, PROP_HEIGHT,
PROP_BANDS, PROP_BANDS,
PROP_FORMAT, PROP_FORMAT,
PROP_CODING,
PROP_INTERPRETATION,
PROP_XRES,
PROP_YRES,
PROP_XOFFSET,
PROP_YOFFSET,
PROP_FILENAME, PROP_FILENAME,
PROP_KILL, PROP_KILL,
PROP_MODE, PROP_MODE,
@ -1002,6 +1008,61 @@ vips_image_class_init( VipsImageClass *class )
VIPS_ARGUMENT_SET_ONCE, VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, BandFmt ) ); G_STRUCT_OFFSET( VipsImage, BandFmt ) );
pspec = g_param_spec_enum( "coding", "Coding",
_( "Pixel coding" ),
VIPS_TYPE_CODING, VIPS_CODING_NONE,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_CODING, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Coding ) );
pspec = g_param_spec_enum( "interpretation", "Interpretation",
_( "Pixel interpretation" ),
VIPS_TYPE_INTERPRETATION, VIPS_INTERPRETATION_MULTIBAND,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class,
PROP_INTERPRETATION, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Type ) );
pspec = g_param_spec_double( "xres", "XRes",
_( "Horizontal resolution in pixels/mm" ),
0, 1000000, 0,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_XRES, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Xres ) );
pspec = g_param_spec_double( "yres", "YRes",
_( "Vertical resolution in pixels/mm" ),
0, 1000000, 0,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_YRES, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Yres ) );
pspec = g_param_spec_int( "xoffset", "XOffset",
_( "Horizontal offset of origin" ),
-10000000, 1000000, 0,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_XOFFSET, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Xoffset ) );
pspec = g_param_spec_int( "yoffset", "YOffset",
_( "Vertical offset of origin" ),
-10000000, 1000000, 0,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_YOFFSET, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Yoffset ) );
pspec = g_param_spec_string( "filename", "Filename", pspec = g_param_spec_string( "filename", "Filename",
_( "Image filename" ), _( "Image filename" ),
NULL, NULL,