get the new arg system working
This commit is contained in:
John Cupitt 2011-10-16 17:48:28 +01:00
parent 8dfb3056ac
commit 26792ed4e1
10 changed files with 70 additions and 99 deletions

60
TODO
View File

@ -1,52 +1,16 @@
- embed args are in the wrong order
$ vips embed
vips_embed_class_init
VipsEmbed (embed), embed an image in a larger image
embed input type x y width height out
- try
$ vips max
im_max (max), maximum value of image, from package "arithmetic"
max in
where:
input :: VipsImage (input)
type :: gint (input)
x :: gint (input)
y :: gint (input)
width :: gint (input)
height :: gint (input)
out :: VipsImage (output)
in :: VipsImage (input)
from package "arithmetic"
flags: (PIO function) (no coordinate transformation) (area
operation) (result can be cached)
how can we fix this?
no output arg?
need to give an extra arg to vips_object_class_install_argument() to
specify 'argument priority' ... show args in priority order
- try some macros for arg specification
pspec = g_param_spec_int( "y", "Y",
_( "Top edge of input in output" ),
0, 1000000, 0,
G_PARAM_READWRITE );
g_object_class_install_property( gobject_class, PROP_Y, pspec );
vips_object_class_install_argument( vobject_class, pspec,
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsEmbed, y ) );
could become
VIPS_ARG_INT( class, "y", "Y",
_( "Top edge of input in output" ),
0, 1000000, 0,
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsEmbed, y ) );
could get rid of PROP_ enums as well
doing binary.c next
- make 'type' field to embed an enum?
@ -64,9 +28,11 @@
- do clip/embed etc. in new style, good to get everything that VipsAdd uses in
- do clip etc. in new style, good to get everything that VipsAdd uses in
the new stack
embed needs flip* *join extract_area replicate insert

View File

@ -94,20 +94,20 @@ vips_arithmetic_class_init( VipsArithmeticClass *class )
vobject_class->description = _( "arithmetic operations" );
vobject_class->build = vips_arithmetic_build;
VIPS_ARG_IMAGE( class, "out", 1,
VIPS_ARG_IMAGE( class, "out", 100,
_( "Output" ),
_( "Output image" ),
VIPS_ARGUMENT_REQUIRED_OUTPUT,
G_STRUCT_OFFSET( VipsArithmetic, output ) );
VIPS_ARG_BOOL( class, "booltest", 2,
VIPS_ARG_BOOL( class, "booltest", 1,
_( "Bool test" ),
_( "Test optional boolean argument" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsArithmetic, booltest ),
FALSE );
VIPS_ARG_IMAGE( class, "imtest", 3,
VIPS_ARG_IMAGE( class, "imtest", 2,
_( "Image test" ),
_( "Test optional image argument" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -349,17 +349,19 @@ vips_binary_class_init( VipsBinaryClass *class )
/* Create properties.
*/
VIPS_ARG_IMAGE( class, "right", 1,
VIPS_ARG_IMAGE( class, "left", 1,
_( "Left" ),
_( "Left-hand image argument" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsBinary, left ) );
VIPS_ARG_IMAGE( class, "right", 2,
_( "Right" ),
_( "Right-hand image argument" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsBinary, right ) );
VIPS_ARG_IMAGE( class, "left", 2,
_( "Left" ),
_( "Left-hand image argument" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsBinary, left ) );
}
static void

View File

@ -147,7 +147,7 @@ vips_statistic_class_init( VipsStatisticClass *class )
vobject_class->description = _( "VIPS statistic operations" );
vobject_class->build = vips_statistic_build;
VIPS_ARG_IMAGE( class, "in", 1,
VIPS_ARG_IMAGE( class, "in", 0,
_( "Input" ),
_( "Input image" ),
VIPS_ARGUMENT_REQUIRED_INPUT,

View File

@ -348,70 +348,70 @@ vips_copy_class_init( VipsCopyClass *class )
G_STRUCT_OFFSET( VipsCopy, swap ),
FALSE );
VIPS_ARG_INT( class, "width", 2,
VIPS_ARG_INT( class, "width", 3,
_( "Width" ),
_( "Image width in pixels" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsCopy, width ),
0, 1000000, 0 );
VIPS_ARG_INT( class, "height", 3,
VIPS_ARG_INT( class, "height", 4,
_( "Height" ),
_( "Image height in pixels" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsCopy, height ),
0, 1000000, 0 );
VIPS_ARG_INT( class, "bands", 4,
VIPS_ARG_INT( class, "bands", 5,
_( "Bands" ),
_( "Number of bands in image" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsCopy, bands ),
0, 1000000, 0 );
VIPS_ARG_ENUM( class, "format", 5,
VIPS_ARG_ENUM( class, "format", 6,
_( "Format" ),
_( "Pixel format in image" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsCopy, format ),
VIPS_TYPE_BAND_FORMAT, VIPS_FORMAT_UCHAR );
VIPS_ARG_ENUM( class, "coding", 6,
VIPS_ARG_ENUM( class, "coding", 7,
_( "Coding" ),
_( "Pixel coding" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsCopy, coding ),
VIPS_TYPE_CODING, VIPS_CODING_NONE );
VIPS_ARG_ENUM( class, "interpretation", 7,
VIPS_ARG_ENUM( class, "interpretation", 8,
_( "Interpretation" ),
_( "Pixel interpretation" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsCopy, interpretation ),
VIPS_TYPE_INTERPRETATION, VIPS_INTERPRETATION_MULTIBAND );
VIPS_ARG_DOUBLE( class, "xres", 8,
VIPS_ARG_DOUBLE( class, "xres", 9,
_( "Xres" ),
_( "Horizontal resolution in pixels/mm" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsCopy, xres ),
0, 1000000, 0 );
VIPS_ARG_DOUBLE( class, "yres", 9,
VIPS_ARG_DOUBLE( class, "yres", 10,
_( "Yres" ),
_( "Vertical resolution in pixels/mm" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsCopy, yres ),
0, 1000000, 0 );
VIPS_ARG_INT( class, "xoffset", 10,
VIPS_ARG_INT( class, "xoffset", 11,
_( "Xoffset" ),
_( "Horizontal offset of origin" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsCopy, xoffset ),
-1000000, 1000000, 0 );
VIPS_ARG_INT( class, "yoffset", 11,
VIPS_ARG_INT( class, "yoffset", 12,
_( "Yoffset" ),
_( "Vertical offset of origin" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -75,13 +75,14 @@
* VipsEmbed:
* @in: input image
* @out: output image
* @type: how to generate the edge pixels
* @extend: how to generate the edge pixels
* @x: place @in at this x position in @out
* @y: place @in at this y position in @out
* @width: @out should be this many pixels across
* @height: @out should be this many pixels down
*
* The opposite of im_extract(): embed an image within a larger image. @type
* The opposite of im_extract(): embed @in within an image of size @width by
* @height at position @x, @y. @extend
* controls what appears in the new pels, see #VipsExtend.
*
* See also: im_extract_area(), im_insert().
@ -96,7 +97,7 @@ typedef struct _VipsEmbed {
*/
VipsImage *input;
VipsExtend type;
VipsExtend extend;
int x;
int y;
int width;
@ -104,13 +105,13 @@ typedef struct _VipsEmbed {
/* Geometry calculations.
*/
Rect rout; /* Whole output area */
Rect rsub; /* Rect occupied by image */
VipsRect rout; /* Whole output area */
VipsRect rsub; /* Rect occupied by image */
/* The 8 border pieces. The 4 borders strictly up/down/left/right of
* the main image, and the 4 corner pieces.
*/
Rect border[8];
VipsRect border[8];
} VipsEmbed;
typedef VipsConversionClass VipsEmbedClass;
@ -267,17 +268,17 @@ vips_embed_gen( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop )
ovl.top += embed->y;
}
switch( embed->type ) {
case 0:
case 4:
switch( embed->extend ) {
case VIPS_EXTEND_BLACK:
case VIPS_EXTEND_WHITE:
/* Paint the borders a solid value.
*/
for( i = 0; i < 8; i++ )
vips_region_paint( or, &embed->border[i],
embed->type == 0 ? 0 : 255 );
embed->extend == 0 ? 0 : 255 );
break;
case 1:
case VIPS_EXTEND_COPY:
/* Extend the borders.
*/
for( i = 0; i < 8; i++ ) {
@ -338,8 +339,8 @@ vips_embed_build( VipsObject *object )
if( vips_image_pio_input( embed->input ) ||
vips_image_pio_output( conversion->output ) )
return( -1 );
if( embed->type < 0 || embed->type > 4 ) {
vips_error( "VipsEmbed", "%s", _( "unknown type" ) );
if( embed->extend < 0 || embed->extend >= VIPS_EXTEND_LAST ) {
vips_error( "VipsEmbed", "%s", _( "unknown VipsExtend" ) );
return( -1 );
}
@ -351,8 +352,8 @@ vips_embed_build( VipsObject *object )
embed->height == embed->input->Ysize )
return( vips_image_write( embed->input, conversion->output ) );
switch( embed->type ) {
case 2:
switch( embed->extend ) {
case VIPS_EXTEND_REPEAT:
{
/* Clock arithmetic: we want negative x/y to wrap around
* nicely.
@ -377,7 +378,7 @@ vips_embed_build( VipsObject *object )
}
break;
case 3:
case VIPS_EXTEND_MIRROR:
{
/* As case 2, but the tiles are twice the size because of
* mirroring.
@ -586,11 +587,11 @@ vips_embed_class_init( VipsEmbedClass *class )
G_STRUCT_OFFSET( VipsEmbed, y ),
-1000000, 1000000, 0 );
VIPS_ARG_ENUM( class, "type", 6,
_( "type" ),
VIPS_ARG_ENUM( class, "extend", 6,
_( "Extend" ),
_( "How to generate the extra pixels" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsEmbed, type ),
G_STRUCT_OFFSET( VipsEmbed, extend ),
VIPS_TYPE_EXTEND, VIPS_EXTEND_BLACK );
}

View File

@ -72,7 +72,8 @@ typedef enum {
VIPS_EXTEND_COPY = 1,
VIPS_EXTEND_REPEAT = 2,
VIPS_EXTEND_MIRROR = 3,
VIPS_EXTEND_WHITE = 4
VIPS_EXTEND_WHITE = 4,
VIPS_EXTEND_LAST = 5
} VipsExtend;
int vips_copy( VipsImage *in, VipsImage **out, ... )

View File

@ -17,6 +17,7 @@ vips_extend_get_type( void )
{VIPS_EXTEND_REPEAT, "VIPS_EXTEND_REPEAT", "repeat"},
{VIPS_EXTEND_MIRROR, "VIPS_EXTEND_MIRROR", "mirror"},
{VIPS_EXTEND_WHITE, "VIPS_EXTEND_WHITE", "white"},
{VIPS_EXTEND_LAST, "VIPS_EXTEND_LAST", "last"},
{0, NULL, NULL}
};

View File

@ -952,70 +952,70 @@ vips_image_class_init( VipsImageClass *class )
VIPS_ARG_INT( class, "width", 2,
_( "Width" ),
_( "Image width in pixels" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Xsize ),
0, 1000000, 0 );
VIPS_ARG_INT( class, "height", 3,
_( "Height" ),
_( "Image height in pixels" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Ysize ),
0, 1000000, 0 );
VIPS_ARG_INT( class, "bands", 4,
_( "Bands" ),
_( "Number of bands in image" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Bands ),
0, 1000000, 0 );
VIPS_ARG_ENUM( class, "format", 5,
_( "Format" ),
_( "Pixel format in image" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, BandFmt ),
VIPS_TYPE_BAND_FORMAT, VIPS_FORMAT_UCHAR );
VIPS_ARG_ENUM( class, "coding", 6,
_( "Coding" ),
_( "Pixel coding" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Coding ),
VIPS_TYPE_CODING, VIPS_CODING_NONE );
VIPS_ARG_ENUM( class, "interpretation", 7,
_( "Interpretation" ),
_( "Pixel interpretation" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Type ),
VIPS_TYPE_INTERPRETATION, VIPS_INTERPRETATION_MULTIBAND );
VIPS_ARG_DOUBLE( class, "xres", 8,
_( "Xres" ),
_( "Horizontal resolution in pixels/mm" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Xres ),
0, 1000000, 0 );
VIPS_ARG_DOUBLE( class, "yres", 9,
_( "Yres" ),
_( "Vertical resolution in pixels/mm" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Yres ),
0, 1000000, 0 );
VIPS_ARG_INT( class, "xoffset", 10,
_( "Xoffset" ),
_( "Horizontal offset of origin" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Xoffset ),
-1000000, 1000000, 0 );
VIPS_ARG_INT( class, "yoffset", 11,
_( "Yoffset" ),
_( "Vertical offset of origin" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
VIPS_ARGUMENT_SET_ONCE,
G_STRUCT_OFFSET( VipsImage, Yoffset ),
-1000000, 1000000, 0 );
@ -1030,7 +1030,7 @@ vips_image_class_init( VipsImageClass *class )
_( "Mode" ),
_( "Open mode" ),
VIPS_ARGUMENT_CONSTRUCT,
G_STRUCT_OFFSET( VipsImage, filename ),
G_STRUCT_OFFSET( VipsImage, mode ),
"p" );
VIPS_ARG_BOOL( class, "kill", 14,

View File

@ -64,7 +64,7 @@ static GMutex *vips__object_all_lock = NULL;
static guint vips_object_signals[SIG_LAST] = { 0 };
int _vips__argument_id = 0;
int _vips__argument_id = 1;
G_DEFINE_ABSTRACT_TYPE( VipsObject, vips_object, G_TYPE_OBJECT );