remove old 45 degree mask rotate code
just a wrapper now
This commit is contained in:
parent
4e06d0a2b4
commit
aa107b1bf7
@ -1,6 +1,5 @@
|
||||
19/10/13 started 7.37.0
|
||||
- added vips_rot45()
|
||||
- redone im_gauss_*mask*() as classes
|
||||
- redone im_rotate_*mask45(), im_gauss_*mask*() as classes
|
||||
|
||||
18/10/13 started 7.36.3
|
||||
- fix compiler warnings in ubuntu 13.10
|
||||
|
4
TODO
4
TODO
@ -1,6 +1,4 @@
|
||||
|
||||
Next version
|
||||
============
|
||||
- do log mask generation, common base class with the gauss mask builder?
|
||||
|
||||
- make vips_init() into a macro, check sizes of important structs against size
|
||||
at library compile time
|
||||
|
@ -275,7 +275,7 @@ vips_rot45_class_init( VipsRot45Class *class )
|
||||
VIPS_ARG_ENUM( class, "angle", 6,
|
||||
_( "Angle" ),
|
||||
_( "Angle to rotate image" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsRot45, angle ),
|
||||
VIPS_TYPE_ANGLE45, VIPS_ANGLE45_45 );
|
||||
}
|
||||
@ -290,9 +290,12 @@ vips_rot45_init( VipsRot45 *rot45 )
|
||||
* vips_rot45:
|
||||
* @in: input image
|
||||
* @out: output image
|
||||
* @angle: rotation angle
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Optional arguments:
|
||||
*
|
||||
* @angle: rotation angle
|
||||
*
|
||||
* Rotate @in by a multiple of 45 degrees. Odd-length sides and square images
|
||||
* only.
|
||||
*
|
||||
@ -301,13 +304,13 @@ vips_rot45_init( VipsRot45 *rot45 )
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int
|
||||
vips_rot45( VipsImage *in, VipsImage **out, VipsAngle45 angle, ... )
|
||||
vips_rot45( VipsImage *in, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, angle );
|
||||
result = vips_call_split( "rot45", ap, in, out, angle );
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "rot45", ap, in, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
|
@ -56,166 +56,6 @@
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
/* Creates the offsets to rotate by 45 degrees an odd size square mask
|
||||
*/
|
||||
int *
|
||||
im_offsets45( int size )
|
||||
{
|
||||
int temp;
|
||||
int x, y;
|
||||
int size2 = size * size;
|
||||
int size_2 = size / 2;
|
||||
int *pnt, *cpnt1, *cpnt2;
|
||||
|
||||
if( size%2 == 0 ) {
|
||||
im_error( "im_offsets45", "%s", _( "size not odd" ) );
|
||||
return( NULL );
|
||||
}
|
||||
if( !(pnt = IM_ARRAY( NULL, size2, int )) )
|
||||
return( NULL );
|
||||
|
||||
/* point at the beginning and end of the buffer
|
||||
*/
|
||||
cpnt1 = pnt; cpnt2 = pnt + size2 - 1;
|
||||
|
||||
for( y = 0; y < size_2; y++ ) {
|
||||
temp = (size_2 + y) * size;
|
||||
*cpnt1++ = temp;
|
||||
*cpnt2-- = size2 - 1 - temp;
|
||||
|
||||
for( x = 0; x < y; x++ ) {
|
||||
temp -= (size-1);
|
||||
*cpnt1++ = temp;
|
||||
*cpnt2-- = size2 - 1 - temp;
|
||||
}
|
||||
|
||||
for( x = 0; x < size_2 - y; x++ ) {
|
||||
temp -= size;
|
||||
*cpnt1++ = temp;
|
||||
*cpnt2-- = size2 - 1 - temp;
|
||||
}
|
||||
|
||||
for( x = 0; x < size_2 - y; x++ ) {
|
||||
temp++;
|
||||
*cpnt1++ = temp;
|
||||
*cpnt2-- = size2 - 1 - temp;
|
||||
}
|
||||
|
||||
for( x = 0; x < y; x++ ) {
|
||||
temp -= ( size - 1 );
|
||||
*cpnt1++ = temp;
|
||||
*cpnt2-- = size2 - 1 - temp;
|
||||
}
|
||||
}
|
||||
|
||||
/* the diagonal now
|
||||
*/
|
||||
temp = size * (size - 1);
|
||||
cpnt1 = pnt + size_2 * size;
|
||||
for( x = 0; x < size; x++ ) {
|
||||
*cpnt1++ = temp;
|
||||
temp -= (size-1);
|
||||
}
|
||||
|
||||
#ifdef PIM_RINT
|
||||
temp = 0;
|
||||
for( y = 0; y < size; y++ ) {
|
||||
for( x = 0; x < size; x++ ) {
|
||||
fprintf( stderr, "%4d", *(pnt+temp) );
|
||||
temp++;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
|
||||
return( pnt );
|
||||
}
|
||||
|
||||
/**
|
||||
* im_rotate_dmask45:
|
||||
* @in: input matrix
|
||||
* @filename: name for output matrix
|
||||
*
|
||||
* Returns a mask which is the argument mask rotated by 45 degrees.
|
||||
* Pass the filename to set for the output.
|
||||
*
|
||||
* See also: im_rotate_dmask90().
|
||||
*
|
||||
* Returns: the result matrix on success, or %NULL on error.
|
||||
*/
|
||||
DOUBLEMASK *
|
||||
im_rotate_dmask45( DOUBLEMASK *in, const char *filename )
|
||||
{
|
||||
DOUBLEMASK *out;
|
||||
int size = in->xsize * in->ysize;
|
||||
int *offsets;
|
||||
int i;
|
||||
|
||||
if( in->xsize != in->ysize || (in->xsize % 2) == 0 ) {
|
||||
im_error( "im_rotate_dmask45", "%s",
|
||||
_( "mask should be square of odd size" ) );
|
||||
return( NULL );
|
||||
}
|
||||
if( !(offsets = im_offsets45( in->xsize )) )
|
||||
return( NULL );
|
||||
if( !(out = im_create_dmask( filename, in->xsize, in->ysize )) ) {
|
||||
im_free( offsets );
|
||||
return( NULL );
|
||||
}
|
||||
out->scale = in->scale;
|
||||
out->offset = in->offset;
|
||||
|
||||
for( i = 0; i < size; i++ )
|
||||
out->coeff[i] = in->coeff[offsets[i]];
|
||||
|
||||
im_free( offsets );
|
||||
|
||||
return( out );
|
||||
}
|
||||
|
||||
/**
|
||||
* im_rotate_imask45:
|
||||
* @in: input matrix
|
||||
* @filename: name for output matrix
|
||||
*
|
||||
* Returns a mask which is the argument mask rotated by 45 degrees.
|
||||
* Pass the filename to set for the output.
|
||||
*
|
||||
* See also: im_rotate_imask90().
|
||||
*
|
||||
* Returns: the result matrix on success, or %NULL on error.
|
||||
*/
|
||||
INTMASK *
|
||||
im_rotate_imask45( INTMASK *in, const char *filename )
|
||||
{
|
||||
INTMASK *out;
|
||||
int size = in->xsize * in->ysize;
|
||||
int *offsets;
|
||||
int i;
|
||||
|
||||
if( in->xsize != in->ysize || (in->xsize % 2) == 0 ) {
|
||||
im_error( "im_rotate_imask45", "%s",
|
||||
_( "mask should be square of odd size" ) );
|
||||
return( NULL );
|
||||
}
|
||||
if( !(offsets = im_offsets45( in->xsize )) )
|
||||
return( NULL );
|
||||
if( !(out = im_create_imask( filename, in->xsize, in->ysize )) ) {
|
||||
im_free( offsets );
|
||||
return( NULL );
|
||||
}
|
||||
out->scale = in->scale;
|
||||
out->offset = in->offset;
|
||||
|
||||
for( i = 0; i < size; i++ )
|
||||
out->coeff[i] = in->coeff[offsets[i]];
|
||||
|
||||
im_free( offsets );
|
||||
|
||||
return( out );
|
||||
}
|
||||
|
||||
/* The type of the vips operations we support.
|
||||
*/
|
||||
typedef int (*vips_fn)( IMAGE *in, IMAGE *out );
|
||||
@ -273,38 +113,42 @@ vapplydmask( DOUBLEMASK *in, const char *name, vips_fn fn )
|
||||
return( out );
|
||||
}
|
||||
|
||||
/**
|
||||
* im_rotate_imask90:
|
||||
* @in: input matrix
|
||||
* @filename: name for output matrix
|
||||
*
|
||||
* Returns a mask which is the argument mask rotated by 90 degrees.
|
||||
* Pass the filename to set for the output.
|
||||
*
|
||||
* See also: im_rotate_imask45().
|
||||
*
|
||||
* Returns: the result matrix on success, or %NULL on error.
|
||||
*/
|
||||
INTMASK *
|
||||
im_rotate_imask90( INTMASK *in, const char *filename )
|
||||
{
|
||||
return( vapplyimask( in, filename, im_rot90 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* im_rotate_dmask90:
|
||||
* @in: input matrix
|
||||
* @filename: name for output matrix
|
||||
*
|
||||
* Returns a mask which is the argument mask rotated by 90 degrees.
|
||||
* Pass the filename to set for the output.
|
||||
*
|
||||
* See also: im_rotate_dmask45().
|
||||
*
|
||||
* Returns: the result matrix on success, or %NULL on error.
|
||||
*/
|
||||
DOUBLEMASK *
|
||||
im_rotate_dmask90( DOUBLEMASK *in, const char *filename )
|
||||
{
|
||||
return( vapplydmask( in, filename, im_rot90 ) );
|
||||
}
|
||||
|
||||
static int
|
||||
im_rot45( IMAGE *in, IMAGE *out )
|
||||
{
|
||||
VipsImage *t;
|
||||
|
||||
if( vips_rot45( in, &t, NULL ) )
|
||||
return( -1 );
|
||||
if( vips_image_write( t, out ) ) {
|
||||
g_object_unref( t );
|
||||
return( -1 );
|
||||
}
|
||||
g_object_unref( t );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
INTMASK *
|
||||
im_rotate_imask45( INTMASK *in, const char *filename )
|
||||
{
|
||||
return( vapplyimask( in, filename, im_rot45 ) );
|
||||
}
|
||||
|
||||
DOUBLEMASK *
|
||||
im_rotate_dmask45( DOUBLEMASK *in, const char *filename )
|
||||
{
|
||||
return( vapplydmask( in, filename, im_rot45 ) );
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ int vips_wrap( VipsImage *in, VipsImage **out, ... )
|
||||
__attribute__((sentinel));
|
||||
int vips_rot( VipsImage *in, VipsImage **out, VipsAngle angle, ... )
|
||||
__attribute__((sentinel));
|
||||
int vips_rot45( VipsImage *in, VipsImage **out, VipsAngle45 angle, ... )
|
||||
int vips_rot45( VipsImage *in, VipsImage **out, ... )
|
||||
__attribute__((sentinel));
|
||||
int vips_zoom( VipsImage *in, VipsImage **out, int xfac, int yfac, ... )
|
||||
__attribute__((sentinel));
|
||||
|
Loading…
Reference in New Issue
Block a user