rename VIPS_ANGLE_0 as VIPS_ANGLE_D0
and other similar cases VIPS_ANGLE_0 becomes Vips.Angle.0 in Python, which is very inconvenient, so we rename ... the D stands for degrees, I think
This commit is contained in:
parent
21ae8321f2
commit
154796a8dc
@ -14,6 +14,7 @@
|
|||||||
test_conversion.py
|
test_conversion.py
|
||||||
- better extra band handling by colour, again
|
- better extra band handling by colour, again
|
||||||
- move zoomify ImageProperties file, now a better match to the offical tool
|
- move zoomify ImageProperties file, now a better match to the offical tool
|
||||||
|
- rename VIPS_ANGLE_180 as VIPS_ANGLE_D180 etc. to help python
|
||||||
|
|
||||||
8/9/14 started 7.40.10
|
8/9/14 started 7.40.10
|
||||||
- icc_import and icc_transform checks the input profile for compatibility
|
- icc_import and icc_transform checks the input profile for compatibility
|
||||||
|
@ -85,10 +85,10 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* VipsAngle:
|
* VipsAngle:
|
||||||
* @VIPS_ANGLE_0: no rotate
|
* @VIPS_ANGLE_D0: no rotate
|
||||||
* @VIPS_ANGLE_90: 90 degrees anti-clockwise
|
* @VIPS_ANGLE_D90: 90 degrees anti-clockwise
|
||||||
* @VIPS_ANGLE_180: 180 degree rotate
|
* @VIPS_ANGLE_D180: 180 degree rotate
|
||||||
* @VIPS_ANGLE_270: 90 degrees clockwise
|
* @VIPS_ANGLE_D270: 90 degrees clockwise
|
||||||
*
|
*
|
||||||
* See vips_rot() and so on.
|
* See vips_rot() and so on.
|
||||||
*
|
*
|
||||||
@ -97,6 +97,24 @@
|
|||||||
* See also: vips_rot().
|
* See also: vips_rot().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VipsAngle45:
|
||||||
|
* @VIPS_ANGLE45_D0: no rotate
|
||||||
|
* @VIPS_ANGLE45_D45: 45 degrees anti-clockwise
|
||||||
|
* @VIPS_ANGLE45_D90: 90 degrees anti-clockwise
|
||||||
|
* @VIPS_ANGLE45_D135: 135 degrees anti-clockwise
|
||||||
|
* @VIPS_ANGLE45_D180: 180 degrees
|
||||||
|
* @VIPS_ANGLE45_D225: 135 degrees clockwise
|
||||||
|
* @VIPS_ANGLE45_D270: 90 degrees clockwise
|
||||||
|
* @VIPS_ANGLE45_D315: 45 degrees clockwise
|
||||||
|
*
|
||||||
|
* See vips_rot45() and so on.
|
||||||
|
*
|
||||||
|
* Fixed rotate angles.
|
||||||
|
*
|
||||||
|
* See also: vips_rot45().
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VipsExtend:
|
* VipsExtend:
|
||||||
* @VIPS_EXTEND_BLACK: extend with black (all 0) pixels
|
* @VIPS_EXTEND_BLACK: extend with black (all 0) pixels
|
||||||
|
@ -288,13 +288,13 @@ vips_rot_build( VipsObject *object )
|
|||||||
if( VIPS_OBJECT_CLASS( vips_rot_parent_class )->build( object ) )
|
if( VIPS_OBJECT_CLASS( vips_rot_parent_class )->build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( rot->angle == VIPS_ANGLE_0 )
|
if( rot->angle == VIPS_ANGLE_D0 )
|
||||||
return( vips_image_write( rot->in, conversion->out ) );
|
return( vips_image_write( rot->in, conversion->out ) );
|
||||||
|
|
||||||
if( vips_image_pio_input( rot->in ) )
|
if( vips_image_pio_input( rot->in ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
hint = rot->angle == VIPS_ANGLE_180 ?
|
hint = rot->angle == VIPS_ANGLE_D180 ?
|
||||||
VIPS_DEMAND_STYLE_THINSTRIP :
|
VIPS_DEMAND_STYLE_THINSTRIP :
|
||||||
VIPS_DEMAND_STYLE_SMALLTILE;
|
VIPS_DEMAND_STYLE_SMALLTILE;
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ vips_rot_build( VipsObject *object )
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
switch( rot->angle ) {
|
switch( rot->angle ) {
|
||||||
case VIPS_ANGLE_90:
|
case VIPS_ANGLE_D90:
|
||||||
generate_fn = vips_rot90_gen;
|
generate_fn = vips_rot90_gen;
|
||||||
conversion->out->Xsize = rot->in->Ysize;
|
conversion->out->Xsize = rot->in->Ysize;
|
||||||
conversion->out->Ysize = rot->in->Xsize;
|
conversion->out->Ysize = rot->in->Xsize;
|
||||||
@ -310,13 +310,13 @@ vips_rot_build( VipsObject *object )
|
|||||||
conversion->out->Yoffset = 0;
|
conversion->out->Yoffset = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_ANGLE_180:
|
case VIPS_ANGLE_D180:
|
||||||
generate_fn = vips_rot180_gen;
|
generate_fn = vips_rot180_gen;
|
||||||
conversion->out->Xoffset = rot->in->Xsize;
|
conversion->out->Xoffset = rot->in->Xsize;
|
||||||
conversion->out->Yoffset = rot->in->Ysize;
|
conversion->out->Yoffset = rot->in->Ysize;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_ANGLE_270:
|
case VIPS_ANGLE_D270:
|
||||||
generate_fn = vips_rot270_gen;
|
generate_fn = vips_rot270_gen;
|
||||||
conversion->out->Xsize = rot->in->Ysize;
|
conversion->out->Xsize = rot->in->Ysize;
|
||||||
conversion->out->Ysize = rot->in->Xsize;
|
conversion->out->Ysize = rot->in->Xsize;
|
||||||
@ -366,7 +366,7 @@ vips_rot_class_init( VipsRotClass *class )
|
|||||||
_( "Angle to rotate image" ),
|
_( "Angle to rotate image" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsRot, angle ),
|
G_STRUCT_OFFSET( VipsRot, angle ),
|
||||||
VIPS_TYPE_ANGLE, VIPS_ANGLE_90 );
|
VIPS_TYPE_ANGLE, VIPS_ANGLE_D90 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -194,7 +194,7 @@ vips_rot45_build( VipsObject *object )
|
|||||||
if( vips_check_oddsquare( class->nickname, rot45->in ) )
|
if( vips_check_oddsquare( class->nickname, rot45->in ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( rot45->angle == VIPS_ANGLE45_0 )
|
if( rot45->angle == VIPS_ANGLE45_D0 )
|
||||||
return( vips_image_write( rot45->in, conversion->out ) );
|
return( vips_image_write( rot45->in, conversion->out ) );
|
||||||
|
|
||||||
if( vips_image_wio_input( rot45->in ) )
|
if( vips_image_wio_input( rot45->in ) )
|
||||||
@ -210,31 +210,31 @@ vips_rot45_build( VipsObject *object )
|
|||||||
from = rot45->in;
|
from = rot45->in;
|
||||||
|
|
||||||
switch( rot45->angle ) {
|
switch( rot45->angle ) {
|
||||||
case VIPS_ANGLE45_315:
|
case VIPS_ANGLE45_D315:
|
||||||
vips_rot45_rot45( t[0], from );
|
vips_rot45_rot45( t[0], from );
|
||||||
from = t[0];
|
from = t[0];
|
||||||
|
|
||||||
case VIPS_ANGLE45_270:
|
case VIPS_ANGLE45_D270:
|
||||||
vips_rot45_rot45( t[0], from );
|
vips_rot45_rot45( t[0], from );
|
||||||
from = t[0];
|
from = t[0];
|
||||||
|
|
||||||
case VIPS_ANGLE45_225:
|
case VIPS_ANGLE45_D225:
|
||||||
vips_rot45_rot45( t[0], from );
|
vips_rot45_rot45( t[0], from );
|
||||||
from = t[0];
|
from = t[0];
|
||||||
|
|
||||||
case VIPS_ANGLE45_180:
|
case VIPS_ANGLE45_D180:
|
||||||
vips_rot45_rot45( t[0], from );
|
vips_rot45_rot45( t[0], from );
|
||||||
from = t[0];
|
from = t[0];
|
||||||
|
|
||||||
case VIPS_ANGLE45_135:
|
case VIPS_ANGLE45_D135:
|
||||||
vips_rot45_rot45( t[0], from );
|
vips_rot45_rot45( t[0], from );
|
||||||
from = t[0];
|
from = t[0];
|
||||||
|
|
||||||
case VIPS_ANGLE45_90:
|
case VIPS_ANGLE45_D90:
|
||||||
vips_rot45_rot45( t[0], from );
|
vips_rot45_rot45( t[0], from );
|
||||||
from = t[0];
|
from = t[0];
|
||||||
|
|
||||||
case VIPS_ANGLE45_45:
|
case VIPS_ANGLE45_D45:
|
||||||
vips_rot45_rot45( t[0], from );
|
vips_rot45_rot45( t[0], from );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -278,13 +278,13 @@ vips_rot45_class_init( VipsRot45Class *class )
|
|||||||
_( "Angle to rotate image" ),
|
_( "Angle to rotate image" ),
|
||||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsRot45, angle ),
|
G_STRUCT_OFFSET( VipsRot45, angle ),
|
||||||
VIPS_TYPE_ANGLE45, VIPS_ANGLE45_45 );
|
VIPS_TYPE_ANGLE45, VIPS_ANGLE45_D45 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vips_rot45_init( VipsRot45 *rot45 )
|
vips_rot45_init( VipsRot45 *rot45 )
|
||||||
{
|
{
|
||||||
rot45->angle = VIPS_ANGLE45_45;
|
rot45->angle = VIPS_ANGLE45_D45;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,7 +160,7 @@ vips_compass_class_init( VipsCompassClass *class )
|
|||||||
_( "Rotate mask by this much between convolutions" ),
|
_( "Rotate mask by this much between convolutions" ),
|
||||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsCompass, angle ),
|
G_STRUCT_OFFSET( VipsCompass, angle ),
|
||||||
VIPS_TYPE_ANGLE45, VIPS_ANGLE45_90 );
|
VIPS_TYPE_ANGLE45, VIPS_ANGLE45_D90 );
|
||||||
|
|
||||||
VIPS_ARG_ENUM( class, "combine", 104,
|
VIPS_ARG_ENUM( class, "combine", 104,
|
||||||
_( "Combine" ),
|
_( "Combine" ),
|
||||||
@ -196,7 +196,7 @@ static void
|
|||||||
vips_compass_init( VipsCompass *compass )
|
vips_compass_init( VipsCompass *compass )
|
||||||
{
|
{
|
||||||
compass->times = 2;
|
compass->times = 2;
|
||||||
compass->angle = VIPS_ANGLE45_90;
|
compass->angle = VIPS_ANGLE45_D90;
|
||||||
compass->combine = VIPS_COMBINE_MAX;
|
compass->combine = VIPS_COMBINE_MAX;
|
||||||
compass->precision = VIPS_PRECISION_INTEGER;
|
compass->precision = VIPS_PRECISION_INTEGER;
|
||||||
compass->layers = 5;
|
compass->layers = 5;
|
||||||
|
@ -71,7 +71,7 @@ vips_convsep_build( VipsObject *object )
|
|||||||
if( vips_check_separable( class->nickname, convolution->M ) )
|
if( vips_check_separable( class->nickname, convolution->M ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips_rot( convolution->M, &t[0], VIPS_ANGLE_90, NULL ) ||
|
if( vips_rot( convolution->M, &t[0], VIPS_ANGLE_D90, NULL ) ||
|
||||||
vips_conv( convolution->in, &t[1], convolution->M,
|
vips_conv( convolution->in, &t[1], convolution->M,
|
||||||
"precision", convsep->precision,
|
"precision", convsep->precision,
|
||||||
"layers", convsep->layers,
|
"layers", convsep->layers,
|
||||||
|
@ -61,7 +61,7 @@ im_vips2dz( IMAGE *in, const char *filename )
|
|||||||
int tile_size = 256;
|
int tile_size = 256;
|
||||||
VipsForeignDzDepth depth = VIPS_FOREIGN_DZ_DEPTH_1PIXEL;
|
VipsForeignDzDepth depth = VIPS_FOREIGN_DZ_DEPTH_1PIXEL;
|
||||||
gboolean centre = FALSE;
|
gboolean centre = FALSE;
|
||||||
VipsAngle angle = VIPS_ANGLE_0;
|
VipsAngle angle = VIPS_ANGLE_D0;
|
||||||
|
|
||||||
/* We can't use im_filename_split() --- it assumes that we have a
|
/* We can't use im_filename_split() --- it assumes that we have a
|
||||||
* filename with an extension before the ':', and filename here is
|
* filename with an extension before the ':', and filename here is
|
||||||
|
@ -1303,7 +1303,7 @@ im_rot90( IMAGE *in, IMAGE *out )
|
|||||||
{
|
{
|
||||||
VipsImage *t;
|
VipsImage *t;
|
||||||
|
|
||||||
if( vips_rot( in, &t, VIPS_ANGLE_90, NULL ) )
|
if( vips_rot( in, &t, VIPS_ANGLE_D90, NULL ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips_image_write( t, out ) ) {
|
if( vips_image_write( t, out ) ) {
|
||||||
g_object_unref( t );
|
g_object_unref( t );
|
||||||
@ -1319,7 +1319,7 @@ im_rot180( IMAGE *in, IMAGE *out )
|
|||||||
{
|
{
|
||||||
VipsImage *t;
|
VipsImage *t;
|
||||||
|
|
||||||
if( vips_rot( in, &t, VIPS_ANGLE_180, NULL ) )
|
if( vips_rot( in, &t, VIPS_ANGLE_D180, NULL ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips_image_write( t, out ) ) {
|
if( vips_image_write( t, out ) ) {
|
||||||
g_object_unref( t );
|
g_object_unref( t );
|
||||||
@ -1335,7 +1335,7 @@ im_rot270( IMAGE *in, IMAGE *out )
|
|||||||
{
|
{
|
||||||
VipsImage *t;
|
VipsImage *t;
|
||||||
|
|
||||||
if( vips_rot( in, &t, VIPS_ANGLE_270, NULL ) )
|
if( vips_rot( in, &t, VIPS_ANGLE_D270, NULL ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips_image_write( t, out ) ) {
|
if( vips_image_write( t, out ) ) {
|
||||||
g_object_unref( t );
|
g_object_unref( t );
|
||||||
@ -2311,7 +2311,7 @@ im_compass( VipsImage *in, VipsImage *out, INTMASK *mask )
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips_compass( in, &t2, t1,
|
if( vips_compass( in, &t2, t1,
|
||||||
"times", 8,
|
"times", 8,
|
||||||
"angle", VIPS_ANGLE45_45,
|
"angle", VIPS_ANGLE45_D45,
|
||||||
NULL ) ) {
|
NULL ) ) {
|
||||||
g_object_unref( t1 );
|
g_object_unref( t1 );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
@ -2336,7 +2336,7 @@ im_lindetect( IMAGE *in, IMAGE *out, INTMASK *mask )
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips_compass( in, &t2, t1,
|
if( vips_compass( in, &t2, t1,
|
||||||
"times", 4,
|
"times", 4,
|
||||||
"angle", VIPS_ANGLE45_45,
|
"angle", VIPS_ANGLE45_D45,
|
||||||
NULL ) ) {
|
NULL ) ) {
|
||||||
g_object_unref( t1 );
|
g_object_unref( t1 );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
@ -2361,7 +2361,7 @@ im_gradient( IMAGE *in, IMAGE *out, INTMASK *mask )
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips_compass( in, &t2, t1,
|
if( vips_compass( in, &t2, t1,
|
||||||
"times", 2,
|
"times", 2,
|
||||||
"angle", VIPS_ANGLE45_90,
|
"angle", VIPS_ANGLE45_D90,
|
||||||
"combine", VIPS_COMBINE_SUM,
|
"combine", VIPS_COMBINE_SUM,
|
||||||
NULL ) ) {
|
NULL ) ) {
|
||||||
g_object_unref( t1 );
|
g_object_unref( t1 );
|
||||||
|
@ -1961,7 +1961,7 @@ vips_foreign_save_dz_class_init( VipsForeignSaveDzClass *class )
|
|||||||
_( "Rotate image during save" ),
|
_( "Rotate image during save" ),
|
||||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignSaveDz, angle ),
|
G_STRUCT_OFFSET( VipsForeignSaveDz, angle ),
|
||||||
VIPS_TYPE_ANGLE, VIPS_ANGLE_0 );
|
VIPS_TYPE_ANGLE, VIPS_ANGLE_D0 );
|
||||||
|
|
||||||
VIPS_ARG_ENUM( class, "container", 15,
|
VIPS_ARG_ENUM( class, "container", 15,
|
||||||
_( "Container" ),
|
_( "Container" ),
|
||||||
@ -2020,7 +2020,7 @@ vips_foreign_save_dz_init( VipsForeignSaveDz *dz )
|
|||||||
dz->tile_size = 256;
|
dz->tile_size = 256;
|
||||||
dz->tile_count = 0;
|
dz->tile_count = 0;
|
||||||
dz->depth = VIPS_FOREIGN_DZ_DEPTH_1PIXEL;
|
dz->depth = VIPS_FOREIGN_DZ_DEPTH_1PIXEL;
|
||||||
dz->angle = VIPS_ANGLE_0;
|
dz->angle = VIPS_ANGLE_D0;
|
||||||
dz->container = VIPS_FOREIGN_DZ_CONTAINER_FS;
|
dz->container = VIPS_FOREIGN_DZ_CONTAINER_FS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,22 +62,22 @@ typedef enum {
|
|||||||
} VipsAlign;
|
} VipsAlign;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VIPS_ANGLE_0,
|
VIPS_ANGLE_D0,
|
||||||
VIPS_ANGLE_90,
|
VIPS_ANGLE_D90,
|
||||||
VIPS_ANGLE_180,
|
VIPS_ANGLE_D180,
|
||||||
VIPS_ANGLE_270,
|
VIPS_ANGLE_D270,
|
||||||
VIPS_ANGLE_LAST
|
VIPS_ANGLE_LAST
|
||||||
} VipsAngle;
|
} VipsAngle;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VIPS_ANGLE45_0,
|
VIPS_ANGLE45_D0,
|
||||||
VIPS_ANGLE45_45,
|
VIPS_ANGLE45_D45,
|
||||||
VIPS_ANGLE45_90,
|
VIPS_ANGLE45_D90,
|
||||||
VIPS_ANGLE45_135,
|
VIPS_ANGLE45_D135,
|
||||||
VIPS_ANGLE45_180,
|
VIPS_ANGLE45_D180,
|
||||||
VIPS_ANGLE45_225,
|
VIPS_ANGLE45_D225,
|
||||||
VIPS_ANGLE45_270,
|
VIPS_ANGLE45_D270,
|
||||||
VIPS_ANGLE45_315,
|
VIPS_ANGLE45_D315,
|
||||||
VIPS_ANGLE45_LAST
|
VIPS_ANGLE45_LAST
|
||||||
} VipsAngle45;
|
} VipsAngle45;
|
||||||
|
|
||||||
@ -189,7 +189,6 @@ int vips_falsecolour( VipsImage *in, VipsImage **out, ... )
|
|||||||
int vips_gamma( VipsImage *in, VipsImage **out, ... )
|
int vips_gamma( VipsImage *in, VipsImage **out, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /*__cplusplus*/
|
#endif /*__cplusplus*/
|
||||||
|
@ -228,10 +228,10 @@ vips_angle_get_type( void )
|
|||||||
|
|
||||||
if( etype == 0 ) {
|
if( etype == 0 ) {
|
||||||
static const GEnumValue values[] = {
|
static const GEnumValue values[] = {
|
||||||
{VIPS_ANGLE_0, "VIPS_ANGLE_0", "0"},
|
{VIPS_ANGLE_D0, "VIPS_ANGLE_D0", "d0"},
|
||||||
{VIPS_ANGLE_90, "VIPS_ANGLE_90", "90"},
|
{VIPS_ANGLE_D90, "VIPS_ANGLE_D90", "d90"},
|
||||||
{VIPS_ANGLE_180, "VIPS_ANGLE_180", "180"},
|
{VIPS_ANGLE_D180, "VIPS_ANGLE_D180", "d180"},
|
||||||
{VIPS_ANGLE_270, "VIPS_ANGLE_270", "270"},
|
{VIPS_ANGLE_D270, "VIPS_ANGLE_D270", "d270"},
|
||||||
{VIPS_ANGLE_LAST, "VIPS_ANGLE_LAST", "last"},
|
{VIPS_ANGLE_LAST, "VIPS_ANGLE_LAST", "last"},
|
||||||
{0, NULL, NULL}
|
{0, NULL, NULL}
|
||||||
};
|
};
|
||||||
@ -248,14 +248,14 @@ vips_angle45_get_type( void )
|
|||||||
|
|
||||||
if( etype == 0 ) {
|
if( etype == 0 ) {
|
||||||
static const GEnumValue values[] = {
|
static const GEnumValue values[] = {
|
||||||
{VIPS_ANGLE45_0, "VIPS_ANGLE45_0", "0"},
|
{VIPS_ANGLE45_D0, "VIPS_ANGLE45_D0", "d0"},
|
||||||
{VIPS_ANGLE45_45, "VIPS_ANGLE45_45", "45"},
|
{VIPS_ANGLE45_D45, "VIPS_ANGLE45_D45", "d45"},
|
||||||
{VIPS_ANGLE45_90, "VIPS_ANGLE45_90", "90"},
|
{VIPS_ANGLE45_D90, "VIPS_ANGLE45_D90", "d90"},
|
||||||
{VIPS_ANGLE45_135, "VIPS_ANGLE45_135", "135"},
|
{VIPS_ANGLE45_D135, "VIPS_ANGLE45_D135", "d135"},
|
||||||
{VIPS_ANGLE45_180, "VIPS_ANGLE45_180", "180"},
|
{VIPS_ANGLE45_D180, "VIPS_ANGLE45_D180", "d180"},
|
||||||
{VIPS_ANGLE45_225, "VIPS_ANGLE45_225", "225"},
|
{VIPS_ANGLE45_D225, "VIPS_ANGLE45_D225", "d225"},
|
||||||
{VIPS_ANGLE45_270, "VIPS_ANGLE45_270", "270"},
|
{VIPS_ANGLE45_D270, "VIPS_ANGLE45_D270", "d270"},
|
||||||
{VIPS_ANGLE45_315, "VIPS_ANGLE45_315", "315"},
|
{VIPS_ANGLE45_D315, "VIPS_ANGLE45_D315", "d315"},
|
||||||
{VIPS_ANGLE45_LAST, "VIPS_ANGLE45_LAST", "last"},
|
{VIPS_ANGLE45_LAST, "VIPS_ANGLE45_LAST", "last"},
|
||||||
{0, NULL, NULL}
|
{0, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -34,6 +34,26 @@ max_value = {Vips.BandFormat.UCHAR: 0xff,
|
|||||||
Vips.BandFormat.COMPLEX: 1.0,
|
Vips.BandFormat.COMPLEX: 1.0,
|
||||||
Vips.BandFormat.DPCOMPLEX: 1.0}
|
Vips.BandFormat.DPCOMPLEX: 1.0}
|
||||||
|
|
||||||
|
sizeof_format = {Vips.BandFormat.UCHAR: 1,
|
||||||
|
Vips.BandFormat.USHORT: 2,
|
||||||
|
Vips.BandFormat.UINT: 4,
|
||||||
|
Vips.BandFormat.CHAR: 1,
|
||||||
|
Vips.BandFormat.SHORT: 2,
|
||||||
|
Vips.BandFormat.INT: 4,
|
||||||
|
Vips.BandFormat.FLOAT: 4,
|
||||||
|
Vips.BandFormat.DOUBLE: 8,
|
||||||
|
Vips.BandFormat.COMPLEX: 8,
|
||||||
|
Vips.BandFormat.DPCOMPLEX: 16}
|
||||||
|
|
||||||
|
rot45_angles = [Vips.Angle45.D0,
|
||||||
|
Vips.Angle45.D45,
|
||||||
|
Vips.Angle45.D90,
|
||||||
|
Vips.Angle45.D135,
|
||||||
|
Vips.Angle45.D180,
|
||||||
|
Vips.Angle45.D225,
|
||||||
|
Vips.Angle45.D270,
|
||||||
|
Vips.Angle45.D315]
|
||||||
|
|
||||||
# an expanding zip ... if either of the args is not a list, duplicate it down
|
# an expanding zip ... if either of the args is not a list, duplicate it down
|
||||||
# the other
|
# the other
|
||||||
def zip_expand(x, y):
|
def zip_expand(x, y):
|
||||||
@ -476,5 +496,92 @@ class TestConversion(unittest.TestCase):
|
|||||||
a = r.getpoint(r.width - 5, 5)
|
a = r.getpoint(r.width - 5, 5)
|
||||||
self.assertAlmostEqualObjects(a, [128, 128, 128])
|
self.assertAlmostEqualObjects(a, [128, 128, 128])
|
||||||
|
|
||||||
|
def test_msb(self):
|
||||||
|
for fmt in unsigned_formats:
|
||||||
|
mx = max_value[fmt]
|
||||||
|
size = sizeof_format[fmt]
|
||||||
|
test = (self.colour + mx / 8).cast(fmt)
|
||||||
|
im = test.msb()
|
||||||
|
|
||||||
|
before = test.getpoint(10, 10)
|
||||||
|
predict = [int(x) >> ((size - 1) * 8) for x in before]
|
||||||
|
result = im.getpoint(10, 10)
|
||||||
|
self.assertAlmostEqualObjects(result, predict)
|
||||||
|
|
||||||
|
before = test.getpoint(50, 50)
|
||||||
|
predict = [int(x) >> ((size - 1) * 8) for x in before]
|
||||||
|
result = im.getpoint(50, 50)
|
||||||
|
self.assertAlmostEqualObjects(result, predict)
|
||||||
|
|
||||||
|
for fmt in signed_formats:
|
||||||
|
mx = max_value[fmt]
|
||||||
|
size = sizeof_format[fmt]
|
||||||
|
test = (self.colour + mx / 8).cast(fmt)
|
||||||
|
im = test.msb()
|
||||||
|
|
||||||
|
before = test.getpoint(10, 10)
|
||||||
|
predict = [128 + (int(x) >> ((size - 1) * 8)) for x in before]
|
||||||
|
result = im.getpoint(10, 10)
|
||||||
|
self.assertAlmostEqualObjects(result, predict)
|
||||||
|
|
||||||
|
before = test.getpoint(50, 50)
|
||||||
|
predict = [128 + (int(x) >> ((size - 1) * 8)) for x in before]
|
||||||
|
result = im.getpoint(50, 50)
|
||||||
|
self.assertAlmostEqualObjects(result, predict)
|
||||||
|
|
||||||
|
for fmt in unsigned_formats:
|
||||||
|
mx = max_value[fmt]
|
||||||
|
size = sizeof_format[fmt]
|
||||||
|
test = (self.colour + mx / 8).cast(fmt)
|
||||||
|
im = test.msb(band = 1)
|
||||||
|
|
||||||
|
before = [test.getpoint(10, 10)[1]]
|
||||||
|
predict = [int(x) >> ((size - 1) * 8) for x in before]
|
||||||
|
result = im.getpoint(10, 10)
|
||||||
|
self.assertAlmostEqualObjects(result, predict)
|
||||||
|
|
||||||
|
before = [test.getpoint(50, 50)[1]]
|
||||||
|
predict = [int(x) >> ((size - 1) * 8) for x in before]
|
||||||
|
result = im.getpoint(50, 50)
|
||||||
|
self.assertAlmostEqualObjects(result, predict)
|
||||||
|
|
||||||
|
def test_recomb(self):
|
||||||
|
array = [[0.2, 0.5, 0.3]]
|
||||||
|
mask = Vips.Image.new_from_array(array)
|
||||||
|
|
||||||
|
def recomb(x):
|
||||||
|
if isinstance(x, Vips.Image):
|
||||||
|
return x.recomb(mask)
|
||||||
|
else:
|
||||||
|
sum = 0
|
||||||
|
for i, c in zip(array[0], x):
|
||||||
|
sum += i * c
|
||||||
|
return [sum]
|
||||||
|
|
||||||
|
self.run_unary([self.colour], recomb, fmt = noncomplex_formats)
|
||||||
|
|
||||||
|
def test_replicate(self):
|
||||||
|
for fmt in all_formats:
|
||||||
|
im = self.colour.cast(fmt)
|
||||||
|
|
||||||
|
test = im.replicate(10, 10)
|
||||||
|
self.assertEqual(test.width, self.colour.width * 10)
|
||||||
|
self.assertEqual(test.height, self.colour.height * 10)
|
||||||
|
|
||||||
|
before = im.getpoint(10, 10)
|
||||||
|
after = test.getpoint(10 + im.width * 2, 10 + im.width * 2)
|
||||||
|
self.assertAlmostEqualObjects(before, after)
|
||||||
|
|
||||||
|
before = im.getpoint(50, 50)
|
||||||
|
after = test.getpoint(50 + im.width * 2, 50 + im.width * 2)
|
||||||
|
self.assertAlmostEqualObjects(before, after)
|
||||||
|
|
||||||
|
def test_rot45(self):
|
||||||
|
test = self.colour.crop(0, 0, 51, 51)
|
||||||
|
for fmt in all_formats:
|
||||||
|
im = test.cast(fmt)
|
||||||
|
|
||||||
|
im.write_to_file("x.v")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
BIN
python/x.v
Normal file
BIN
python/x.v
Normal file
Binary file not shown.
@ -157,16 +157,16 @@ get_angle( VipsImage *im )
|
|||||||
VipsAngle angle;
|
VipsAngle angle;
|
||||||
const char *orientation;
|
const char *orientation;
|
||||||
|
|
||||||
angle = VIPS_ANGLE_0;
|
angle = VIPS_ANGLE_D0;
|
||||||
|
|
||||||
if( vips_image_get_typeof( im, ORIENTATION ) &&
|
if( vips_image_get_typeof( im, ORIENTATION ) &&
|
||||||
!vips_image_get_string( im, ORIENTATION, &orientation ) ) {
|
!vips_image_get_string( im, ORIENTATION, &orientation ) ) {
|
||||||
if( vips_isprefix( "6", orientation ) )
|
if( vips_isprefix( "6", orientation ) )
|
||||||
angle = VIPS_ANGLE_90;
|
angle = VIPS_ANGLE_D90;
|
||||||
else if( vips_isprefix( "8", orientation ) )
|
else if( vips_isprefix( "8", orientation ) )
|
||||||
angle = VIPS_ANGLE_270;
|
angle = VIPS_ANGLE_D270;
|
||||||
else if( vips_isprefix( "3", orientation ) )
|
else if( vips_isprefix( "3", orientation ) )
|
||||||
angle = VIPS_ANGLE_180;
|
angle = VIPS_ANGLE_D180;
|
||||||
|
|
||||||
/* Other values do rotate + mirror, don't bother handling them
|
/* Other values do rotate + mirror, don't bother handling them
|
||||||
* though, how common can mirroring be.
|
* though, how common can mirroring be.
|
||||||
@ -194,7 +194,7 @@ calculate_shrink( VipsImage *im, double *residual,
|
|||||||
VipsInterpolate *interp )
|
VipsInterpolate *interp )
|
||||||
{
|
{
|
||||||
VipsAngle angle = get_angle( im );
|
VipsAngle angle = get_angle( im );
|
||||||
gboolean rotate = angle == VIPS_ANGLE_90 || angle == VIPS_ANGLE_270;
|
gboolean rotate = angle == VIPS_ANGLE_D90 || angle == VIPS_ANGLE_D270;
|
||||||
int width = rotate_image && rotate ? im->Ysize : im->Xsize;
|
int width = rotate_image && rotate ? im->Ysize : im->Xsize;
|
||||||
int height = rotate_image && rotate ? im->Xsize : im->Ysize;
|
int height = rotate_image && rotate ? im->Xsize : im->Ysize;
|
||||||
const int window_size =
|
const int window_size =
|
||||||
@ -667,7 +667,7 @@ thumbnail_rotate( VipsObject *process, VipsImage *im )
|
|||||||
VipsAngle angle = get_angle( im );
|
VipsAngle angle = get_angle( im );
|
||||||
|
|
||||||
if( rotate_image &&
|
if( rotate_image &&
|
||||||
angle != VIPS_ANGLE_0 ) {
|
angle != VIPS_ANGLE_D0 ) {
|
||||||
/* Need to copy to memory, we have to stay seq.
|
/* Need to copy to memory, we have to stay seq.
|
||||||
*/
|
*/
|
||||||
t[0] = vips_image_new_memory();
|
t[0] = vips_image_new_memory();
|
||||||
|
Loading…
Reference in New Issue
Block a user