stuff
This commit is contained in:
parent
ed204980b1
commit
64f7f58411
|
@ -568,3 +568,127 @@ im_plotpoint( IMAGE *im, int x, int y, PEL *pel )
|
||||||
{
|
{
|
||||||
return( im_draw_point( im, x, y, pel ) );
|
return( im_draw_point( im, x, y, pel ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Smear a section of an IMAGE. As above, but shift it left a bit.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
im_smear( IMAGE *im, int ix, int iy, Rect *r )
|
||||||
|
{
|
||||||
|
int x, y, a, b, c;
|
||||||
|
int ba = im->Bands;
|
||||||
|
int el = ba * im->Xsize;
|
||||||
|
Rect area, image, clipped;
|
||||||
|
double total[ 256 ];
|
||||||
|
|
||||||
|
if( im_rwcheck( im ) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
/* Don't do the margins.
|
||||||
|
*/
|
||||||
|
area = *r;
|
||||||
|
area.left += ix;
|
||||||
|
area.top += iy;
|
||||||
|
image.left = 0;
|
||||||
|
image.top = 0;
|
||||||
|
image.width = im->Xsize;
|
||||||
|
image.height = im->Ysize;
|
||||||
|
im_rect_marginadjust( &image, -1 );
|
||||||
|
image.left--;
|
||||||
|
im_rect_intersectrect( &area, &image, &clipped );
|
||||||
|
|
||||||
|
/* Any left?
|
||||||
|
*/
|
||||||
|
if( im_rect_isempty( &clipped ) )
|
||||||
|
return( 0 );
|
||||||
|
|
||||||
|
/* What we do for each type.
|
||||||
|
*/
|
||||||
|
#define SMEAR(TYPE) \
|
||||||
|
for( y = clipped.top; y < clipped.top + clipped.height; y++ ) \
|
||||||
|
for( x = clipped.left; \
|
||||||
|
x < clipped.left + clipped.width; x++ ) { \
|
||||||
|
TYPE *to = (TYPE *) im->data + x * ba + y * el; \
|
||||||
|
TYPE *from = to - el; \
|
||||||
|
TYPE *f; \
|
||||||
|
\
|
||||||
|
for( a = 0; a < ba; a++ ) \
|
||||||
|
total[a] = 0.0; \
|
||||||
|
\
|
||||||
|
for( a = 0; a < 3; a++ ) { \
|
||||||
|
f = from; \
|
||||||
|
for( b = 0; b < 3; b++ ) \
|
||||||
|
for( c = 0; c < ba; c++ ) \
|
||||||
|
total[c] += *f++; \
|
||||||
|
from += el; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
for( a = 0; a < ba; a++ ) \
|
||||||
|
to[a] = (40 * (double) to[a+ba] + total[a]) \
|
||||||
|
/ 49.0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loop through the remaining pixels.
|
||||||
|
*/
|
||||||
|
switch( im->BandFmt ) {
|
||||||
|
case IM_BANDFMT_UCHAR:
|
||||||
|
SMEAR(unsigned char);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IM_BANDFMT_CHAR:
|
||||||
|
SMEAR(char);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IM_BANDFMT_USHORT:
|
||||||
|
SMEAR(unsigned short);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IM_BANDFMT_SHORT:
|
||||||
|
SMEAR(short);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IM_BANDFMT_UINT:
|
||||||
|
SMEAR(unsigned int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IM_BANDFMT_INT:
|
||||||
|
SMEAR(int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IM_BANDFMT_FLOAT:
|
||||||
|
SMEAR(float);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IM_BANDFMT_DOUBLE:
|
||||||
|
SMEAR(double);
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Do complex types too. Just treat as float and double, but with
|
||||||
|
* twice the number of bands.
|
||||||
|
*/
|
||||||
|
case IM_BANDFMT_COMPLEX:
|
||||||
|
/* Twice number of bands: double size and bands.
|
||||||
|
*/
|
||||||
|
ba *= 2;
|
||||||
|
el *= 2;
|
||||||
|
|
||||||
|
SMEAR(float);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IM_BANDFMT_DPCOMPLEX:
|
||||||
|
/* Twice number of bands: double size and bands.
|
||||||
|
*/
|
||||||
|
ba *= 2;
|
||||||
|
el *= 2;
|
||||||
|
|
||||||
|
SMEAR(double);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
im_error( "im_smear", "%s", _( "unknown band format" ) );
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
|
@ -3,14 +3,14 @@ noinst_LTLIBRARIES = libinplace.la
|
||||||
libinplace_la_SOURCES = \
|
libinplace_la_SOURCES = \
|
||||||
draw.c \
|
draw.c \
|
||||||
draw.h \
|
draw.h \
|
||||||
|
flood.c \
|
||||||
im_draw_circle.c \
|
im_draw_circle.c \
|
||||||
im_draw_line.c \
|
im_draw_line.c \
|
||||||
im_draw_image.c \
|
im_draw_image.c \
|
||||||
im_draw_rect.c \
|
im_draw_rect.c \
|
||||||
im_draw_mask.c \
|
im_draw_mask.c \
|
||||||
im_draw_point.c \
|
im_draw_point.c \
|
||||||
flood.c \
|
im_smudge_area.c \
|
||||||
inplace_dispatch.c \
|
inplace_dispatch.c
|
||||||
smudge_area.c
|
|
||||||
|
|
||||||
INCLUDES = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@
|
INCLUDES = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@
|
||||||
|
|
|
@ -512,15 +512,15 @@ im_flood_blob( IMAGE *im, int x, int y, PEL *ink, Rect *dout )
|
||||||
* @serial: mark pixels with this number
|
* @serial: mark pixels with this number
|
||||||
* @dout: output the bounding box of the filled area
|
* @dout: output the bounding box of the filled area
|
||||||
*
|
*
|
||||||
* Flood-fill @mark with @serial, starting at position @x, @y. The filled
|
* Flood-fill @image with @serial, starting at position @x, @y. The filled
|
||||||
* area is bounded by pixels in @test that are equal to the start pixel, in
|
* area is bounded by pixels in @test that are equal to the start pixel, in
|
||||||
* other words, it searches @test for a blob of same-coloured pixels, marking
|
* other words, it searches @test for a blob of same-coloured pixels, marking
|
||||||
* those pixels in @mark with @serial.
|
* those pixels in @image with @serial.
|
||||||
*
|
*
|
||||||
* The bounding box of the modified pixels is returned in @dout. @dout may be
|
* The bounding box of the modified pixels is returned in @dout. @dout may be
|
||||||
* NULL.
|
* NULL.
|
||||||
*
|
*
|
||||||
* This an inplace operation, so @mark is changed. It does not thread and will
|
* This an inplace operation, so @image is changed. It does not thread and will
|
||||||
* not work well as part of a pipeline. On 32-bit machines, it will be limited
|
* not work well as part of a pipeline. On 32-bit machines, it will be limited
|
||||||
* to 2GB images.
|
* to 2GB images.
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
* - cast and bandalike sub to main
|
* - cast and bandalike sub to main
|
||||||
* 22/9/10
|
* 22/9/10
|
||||||
* - rename to im_draw_image()
|
* - rename to im_draw_image()
|
||||||
|
* - gtk-doc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -96,11 +97,11 @@ im__inplace_base( const char *domain,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* im_insertplace:
|
* im_draw_image:
|
||||||
* @main: image to draw on
|
* @main: image to draw on
|
||||||
|
* @sub: image to draw
|
||||||
* @x: position to insert
|
* @x: position to insert
|
||||||
* @y: position to insert
|
* @y: position to insert
|
||||||
* @sub: image to draw
|
|
||||||
*
|
*
|
||||||
* Draw @sub on top of @main at position @x, @y. The two images must have the
|
* Draw @sub on top of @main at position @x, @y. The two images must have the
|
||||||
* same
|
* same
|
||||||
|
|
|
@ -1,16 +1,4 @@
|
||||||
/* @(#) Smudge and smear a piece of image. Smudge is a low-pass filter,
|
/* Smudge a piece of image.
|
||||||
* @(#) smear is an early version of smudge which contains a bug: it
|
|
||||||
* @(#) pushes pels to the left a little too. Looks cute though.
|
|
||||||
* @(#)
|
|
||||||
* @(#) r is the area to smudge/smear. Clipped against the image edges
|
|
||||||
* @(#) properly.
|
|
||||||
* @(#)
|
|
||||||
* @(#) int
|
|
||||||
* @(#) im_smudge( IMAGE *im, int ix, int iy, Rect *r )
|
|
||||||
* @(#)
|
|
||||||
* @(#) int
|
|
||||||
* @(#) im_smear( IMAGE *im, int ix, int iy, Rect *r )
|
|
||||||
* @(#)
|
|
||||||
*
|
*
|
||||||
* Copyright: J. Cupitt
|
* Copyright: J. Cupitt
|
||||||
* Written: 15/06/1992
|
* Written: 15/06/1992
|
||||||
|
@ -192,127 +180,3 @@ im_smudge( IMAGE *im, int ix, int iy, Rect *r )
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Smear a section of an IMAGE. As above, but shift it left a bit.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
im_smear( IMAGE *im, int ix, int iy, Rect *r )
|
|
||||||
{
|
|
||||||
int x, y, a, b, c;
|
|
||||||
int ba = im->Bands;
|
|
||||||
int el = ba * im->Xsize;
|
|
||||||
Rect area, image, clipped;
|
|
||||||
double total[ 256 ];
|
|
||||||
|
|
||||||
if( im_rwcheck( im ) )
|
|
||||||
return( -1 );
|
|
||||||
|
|
||||||
/* Don't do the margins.
|
|
||||||
*/
|
|
||||||
area = *r;
|
|
||||||
area.left += ix;
|
|
||||||
area.top += iy;
|
|
||||||
image.left = 0;
|
|
||||||
image.top = 0;
|
|
||||||
image.width = im->Xsize;
|
|
||||||
image.height = im->Ysize;
|
|
||||||
im_rect_marginadjust( &image, -1 );
|
|
||||||
image.left--;
|
|
||||||
im_rect_intersectrect( &area, &image, &clipped );
|
|
||||||
|
|
||||||
/* Any left?
|
|
||||||
*/
|
|
||||||
if( im_rect_isempty( &clipped ) )
|
|
||||||
return( 0 );
|
|
||||||
|
|
||||||
/* What we do for each type.
|
|
||||||
*/
|
|
||||||
#define SMEAR(TYPE) \
|
|
||||||
for( y = clipped.top; y < clipped.top + clipped.height; y++ ) \
|
|
||||||
for( x = clipped.left; \
|
|
||||||
x < clipped.left + clipped.width; x++ ) { \
|
|
||||||
TYPE *to = (TYPE *) im->data + x * ba + y * el; \
|
|
||||||
TYPE *from = to - el; \
|
|
||||||
TYPE *f; \
|
|
||||||
\
|
|
||||||
for( a = 0; a < ba; a++ ) \
|
|
||||||
total[a] = 0.0; \
|
|
||||||
\
|
|
||||||
for( a = 0; a < 3; a++ ) { \
|
|
||||||
f = from; \
|
|
||||||
for( b = 0; b < 3; b++ ) \
|
|
||||||
for( c = 0; c < ba; c++ ) \
|
|
||||||
total[c] += *f++; \
|
|
||||||
from += el; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
for( a = 0; a < ba; a++ ) \
|
|
||||||
to[a] = (40 * (double) to[a+ba] + total[a]) \
|
|
||||||
/ 49.0; \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Loop through the remaining pixels.
|
|
||||||
*/
|
|
||||||
switch( im->BandFmt ) {
|
|
||||||
case IM_BANDFMT_UCHAR:
|
|
||||||
SMEAR(unsigned char);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IM_BANDFMT_CHAR:
|
|
||||||
SMEAR(char);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IM_BANDFMT_USHORT:
|
|
||||||
SMEAR(unsigned short);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IM_BANDFMT_SHORT:
|
|
||||||
SMEAR(short);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IM_BANDFMT_UINT:
|
|
||||||
SMEAR(unsigned int);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IM_BANDFMT_INT:
|
|
||||||
SMEAR(int);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IM_BANDFMT_FLOAT:
|
|
||||||
SMEAR(float);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IM_BANDFMT_DOUBLE:
|
|
||||||
SMEAR(double);
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Do complex types too. Just treat as float and double, but with
|
|
||||||
* twice the number of bands.
|
|
||||||
*/
|
|
||||||
case IM_BANDFMT_COMPLEX:
|
|
||||||
/* Twice number of bands: double size and bands.
|
|
||||||
*/
|
|
||||||
ba *= 2;
|
|
||||||
el *= 2;
|
|
||||||
|
|
||||||
SMEAR(float);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IM_BANDFMT_DPCOMPLEX:
|
|
||||||
/* Twice number of bands: double size and bands.
|
|
||||||
*/
|
|
||||||
ba *= 2;
|
|
||||||
el *= 2;
|
|
||||||
|
|
||||||
SMEAR(double);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
im_error( "im_smear", "%s", _( "unknown band format" ) );
|
|
||||||
return( -1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
Loading…
Reference in New Issue