stuff
This commit is contained in:
parent
8b0fd7dd9f
commit
3c18b0f0c1
22
TODO
22
TODO
@ -1,3 +1,5 @@
|
||||
- im_fastcor() could use a rewrite
|
||||
|
||||
- im_spcor a.value a.value fails, argh
|
||||
|
||||
nip2: im_prepare.c:324: im_prepare_to:
|
||||
@ -8,6 +10,26 @@
|
||||
|
||||
suspicious!
|
||||
|
||||
looks like it's a problem with im_embed()
|
||||
|
||||
$ header t1.v
|
||||
Xsize: 183
|
||||
Ysize: 119
|
||||
Bands: 1
|
||||
Bbits: 8
|
||||
|
||||
then
|
||||
|
||||
$ vips im_embed t1.v out2.v 1 100 74 364 240
|
||||
$ vips im_embed t1.v out2.v 1 100 73 364 240
|
||||
vips: error calling function
|
||||
im_prepare_to: valid clipped to nothing
|
||||
im__write_extension_block: file has been truncated
|
||||
|
||||
though 74 fails too, tiles are in the wrong place
|
||||
|
||||
seems fixed, test this
|
||||
|
||||
- doing im_create_fmask() and friends
|
||||
|
||||
- how about im_invalidate_area()? we currently repaint the whole window on
|
||||
|
@ -20,6 +20,7 @@
|
||||
* - gtkdoc
|
||||
* 27/1/10
|
||||
* - use im_region_paint()
|
||||
* - cleanups
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -69,8 +70,8 @@ typedef struct _Embed {
|
||||
IMAGE *in;
|
||||
IMAGE *out;
|
||||
int type;
|
||||
int left;
|
||||
int top;
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
@ -209,8 +210,8 @@ embed_gen( REGION *or, void *seq, void *a, void *b )
|
||||
Rect need;
|
||||
|
||||
need = *r;
|
||||
need.left -= embed->left;
|
||||
need.top -= embed->top;
|
||||
need.left -= embed->x;
|
||||
need.top -= embed->y;
|
||||
if( im_prepare( ir, &need ) ||
|
||||
im_region_region( or, ir, r, need.left, need.top ) )
|
||||
return( -1 );
|
||||
@ -225,13 +226,13 @@ embed_gen( REGION *or, void *seq, void *a, void *b )
|
||||
if( !im_rect_isempty( &ovl ) ) {
|
||||
/* Paint the bits coming from the input image.
|
||||
*/
|
||||
ovl.left -= embed->top;
|
||||
ovl.top -= embed->top;
|
||||
ovl.left -= embed->x;
|
||||
ovl.top -= embed->y;
|
||||
if( im_prepare_to( ir, or, &ovl,
|
||||
ovl.left + embed->top, ovl.top + embed->top ) )
|
||||
ovl.left + embed->x, ovl.top + embed->y ) )
|
||||
return( -1 );
|
||||
ovl.left += embed->top;
|
||||
ovl.top += embed->top;
|
||||
ovl.left += embed->x;
|
||||
ovl.top += embed->y;
|
||||
}
|
||||
|
||||
switch( embed->type ) {
|
||||
@ -268,8 +269,8 @@ embed_gen( REGION *or, void *seq, void *a, void *b )
|
||||
/* No pixels painted ... fetch
|
||||
* directly from the input image.
|
||||
*/
|
||||
edge.left -= embed->left;
|
||||
edge.top -= embed->top;
|
||||
edge.left -= embed->x;
|
||||
edge.top -= embed->y;
|
||||
if( im_prepare( ir, &edge ) )
|
||||
return( -1 );
|
||||
p = (PEL *) IM_REGION_ADDR( ir,
|
||||
@ -293,7 +294,7 @@ embed_gen( REGION *or, void *seq, void *a, void *b )
|
||||
|
||||
static Embed *
|
||||
embed_new( IMAGE *in, IMAGE *out,
|
||||
int type, int left, int top, int width, int height )
|
||||
int type, int x, int y, int width, int height )
|
||||
{
|
||||
Embed *embed = IM_NEW( out, Embed );
|
||||
Rect want;
|
||||
@ -303,8 +304,8 @@ embed_new( IMAGE *in, IMAGE *out,
|
||||
embed->in = in;
|
||||
embed->out = out;
|
||||
embed->type = type;
|
||||
embed->left = left;
|
||||
embed->top = top;
|
||||
embed->x = x;
|
||||
embed->y = y;
|
||||
embed->width = width;
|
||||
embed->height = height;
|
||||
|
||||
@ -317,8 +318,8 @@ embed_new( IMAGE *in, IMAGE *out,
|
||||
|
||||
/* Rect occupied by image (can be clipped to nothing).
|
||||
*/
|
||||
want.left = left;
|
||||
want.top = top;
|
||||
want.left = x;
|
||||
want.top = y;
|
||||
want.width = in->Xsize;
|
||||
want.height = in->Ysize;
|
||||
im_rect_intersectrect( &want, &embed->rout, &embed->rsub );
|
||||
@ -384,8 +385,7 @@ embed_new( IMAGE *in, IMAGE *out,
|
||||
/* Do type 0/4 (black/white) and 1 (extend).
|
||||
*/
|
||||
static int
|
||||
embed( IMAGE *in, IMAGE *out,
|
||||
int type, int left, int top, int width, int height )
|
||||
embed( IMAGE *in, IMAGE *out, int type, int x, int y, int width, int height )
|
||||
{
|
||||
Embed *embed;
|
||||
|
||||
@ -394,7 +394,7 @@ embed( IMAGE *in, IMAGE *out,
|
||||
out->Xsize = width;
|
||||
out->Ysize = height;
|
||||
|
||||
if( !(embed = embed_new( in, out, type, left, top, width, height )) ||
|
||||
if( !(embed = embed_new( in, out, type, x, y, width, height )) ||
|
||||
im_demand_hint( out, IM_SMALLTILE, in, NULL ) ||
|
||||
im_generate( out,
|
||||
im_start_one, embed_gen, im_stop_one,
|
||||
@ -409,12 +409,12 @@ embed( IMAGE *in, IMAGE *out,
|
||||
* @in: input image
|
||||
* @out: output image
|
||||
* @type: how to generate the edge pixels
|
||||
* @left: left edge of image in output
|
||||
* @top: top edge of image in output
|
||||
* @width: width of output
|
||||
* @height: height of output
|
||||
* @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_area(): embed @in within a larger image. @type
|
||||
* The opposite of im_extract(): embed an image within a larger image. @type
|
||||
* controls what appears in the new pels:
|
||||
*
|
||||
* <tgroup cols='2' align='left' colsep='1' rowsep='1'>
|
||||
@ -447,8 +447,7 @@ embed( IMAGE *in, IMAGE *out,
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
im_embed( IMAGE *in, IMAGE *out,
|
||||
int type, int left, int top, int width, int height )
|
||||
im_embed( IMAGE *in, IMAGE *out, int type, int x, int y, int width, int height )
|
||||
{
|
||||
if( im_piocheck( in, out ) ||
|
||||
im_check_coding_known( "im_embed", in ) )
|
||||
@ -464,15 +463,14 @@ im_embed( IMAGE *in, IMAGE *out,
|
||||
|
||||
/* nip can generate this quite often ... just copy.
|
||||
*/
|
||||
if( left == 0 && top == 0 &&
|
||||
width == in->Xsize && height == in->Ysize )
|
||||
if( x == 0 && y == 0 && width == in->Xsize && height == in->Ysize )
|
||||
return( im_copy( in, out ) );
|
||||
|
||||
switch( type ) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 4:
|
||||
if( embed( in, out, type, left, top, width, height ) )
|
||||
if( embed( in, out, type, x, y, width, height ) )
|
||||
return( -1 );
|
||||
break;
|
||||
|
||||
@ -481,19 +479,18 @@ im_embed( IMAGE *in, IMAGE *out,
|
||||
/* Clock arithmetic: we want negative x/y to wrap around
|
||||
* nicely.
|
||||
*/
|
||||
const int nleft = left < 0 ?
|
||||
-left % in->Xsize : in->Xsize - left % in->Xsize;
|
||||
const int ntop = top < 0 ?
|
||||
-top % in->Ysize : in->Ysize - top % in->Ysize;
|
||||
const int nx = x < 0 ?
|
||||
-x % in->Xsize : in->Xsize - x % in->Xsize;
|
||||
const int ny = y < 0 ?
|
||||
-y % in->Ysize : in->Ysize - y % in->Ysize;
|
||||
|
||||
IMAGE *t[1];
|
||||
|
||||
if( im_open_local_array( out, t, 1, "embed-type", "p" ) ||
|
||||
if( im_open_local_array( out, t, 1, "embed-type2", "p" ) ||
|
||||
im_replicate( in, t[0],
|
||||
width / in->Xsize + 2,
|
||||
height / in->Ysize + 2 ) ||
|
||||
im_extract_area( t[0], out,
|
||||
nleft, ntop, width, height ) )
|
||||
im_extract_area( t[0], out, nx, ny, width, height ) )
|
||||
return( -1 );
|
||||
}
|
||||
break;
|
||||
@ -503,17 +500,15 @@ im_embed( IMAGE *in, IMAGE *out,
|
||||
/* As case 2, but the tiles are twice the size because of
|
||||
* mirroring.
|
||||
*/
|
||||
const int width2 = in->Xsize * 2;
|
||||
const int height2 = in->Ysize * 2;
|
||||
const int w2 = in->Xsize * 2;
|
||||
const int h2 = in->Ysize * 2;
|
||||
|
||||
const int nleft = left < 0 ?
|
||||
-left % width2 : width2 - left % width2;
|
||||
const int ntop = top < 0 ?
|
||||
-top % height2 : height2 - top % height2;
|
||||
const int nx = x < 0 ? -x % w2 : w2 - x % w2;
|
||||
const int ny = y < 0 ? -y % h2 : h2 - y % h2;
|
||||
|
||||
IMAGE *t[7];
|
||||
|
||||
if( im_open_local_array( out, t, 7, "embed-type", "p" ) ||
|
||||
if( im_open_local_array( out, t, 7, "embed-type3", "p" ) ||
|
||||
/* Cache the edges of in, since we may well be reusing
|
||||
* them repeatedly. Will only help for tiny borders
|
||||
* (up to 20 pixels?), but that's our typical case
|
||||
@ -543,13 +538,12 @@ im_embed( IMAGE *in, IMAGE *out,
|
||||
im_replicate( t[4], t[5],
|
||||
width / t[4]->Xsize + 2,
|
||||
height / t[4]->Ysize + 2 ) ||
|
||||
im_extract_area( t[5], t[6],
|
||||
nleft, ntop, width, height ) ||
|
||||
im_extract_area( t[5], t[6], nx, ny, width, height ) ||
|
||||
|
||||
/* Overwrite the centre with the input, much faster
|
||||
* for centre pixels.
|
||||
*/
|
||||
im_insert_noexpand( t[6], in, out, left, top ) )
|
||||
im_insert_noexpand( t[6], in, out, x, y ) )
|
||||
return( -1 );
|
||||
}
|
||||
break;
|
||||
@ -558,8 +552,8 @@ im_embed( IMAGE *in, IMAGE *out,
|
||||
g_assert( 0 );
|
||||
}
|
||||
|
||||
out->Xoffset = left;
|
||||
out->Yoffset = top;
|
||||
out->Xoffset = x;
|
||||
out->Yoffset = y;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -144,11 +144,11 @@ im_fastcor_raw( IMAGE *in, IMAGE *ref, IMAGE *out )
|
||||
/* Check types.
|
||||
*/
|
||||
if( im_check_uncoded( "im_fastcor", in ) ||
|
||||
im_check_format( "im_fastcor", in, IM_BANDFMT_UCHAR ) ||
|
||||
im_check_mono( "im_fastcor", in ) ||
|
||||
im_check_uncoded( "im_fastcor", ref ) ||
|
||||
im_check_format( "im_fastcor", ref, IM_BANDFMT_UCHAR ) ||
|
||||
im_check_mono( "im_fastcor", ref ) )
|
||||
im_check_format( "im_fastcor", in, IM_BANDFMT_UCHAR ) ||
|
||||
im_check_coding_same( "im_fastcor", in, ref ) ||
|
||||
im_check_bands_same( "im_fastcor", in, ref ) ||
|
||||
im_check_format_same( "im_fastcor", in, ref ) )
|
||||
return( -1 );
|
||||
|
||||
/* Prepare the output image.
|
||||
|
@ -75,8 +75,8 @@ int im_extract_area( IMAGE *in, IMAGE *out,
|
||||
int left, int top, int width, int height );
|
||||
int im_extract_areabands( IMAGE *in, IMAGE *out,
|
||||
int left, int top, int width, int height, int band, int nbands );
|
||||
int im_embed( IMAGE *in, IMAGE *out, int type,
|
||||
int left, int top, int width, int height );
|
||||
int im_embed( IMAGE *in, IMAGE *out,
|
||||
int type, int x, int y, int width, int height );
|
||||
int im_bandjoin( IMAGE *in1, IMAGE *in2, IMAGE *out );
|
||||
int im_gbandjoin( IMAGE **in, IMAGE *out, int n );
|
||||
int im_insert( IMAGE *main, IMAGE *sub, IMAGE *out, int x, int y );
|
||||
|
@ -63,7 +63,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/debug.h>
|
||||
@ -188,7 +187,7 @@ im_prepare( REGION *reg, Rect *r )
|
||||
|
||||
/* valid should now include all the pixels that were asked for.
|
||||
*/
|
||||
assert( im_rect_includesrect( ®->valid, &save ) );
|
||||
g_assert( im_rect_includesrect( ®->valid, &save ) );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
@ -220,11 +219,11 @@ im__copy_region( REGION *reg, REGION *dest, Rect *r, int x, int y )
|
||||
|
||||
/* Must be inside dest->valid.
|
||||
*/
|
||||
assert( im_rect_includesrect( &dest->valid, &output ) );
|
||||
g_assert( im_rect_includesrect( &dest->valid, &output ) );
|
||||
|
||||
/* Check the area we are reading from in reg.
|
||||
*/
|
||||
assert( im_rect_includesrect( ®->valid, r ) );
|
||||
g_assert( im_rect_includesrect( ®->valid, r ) );
|
||||
#endif /*DEBUG*/
|
||||
|
||||
for( z = 0; z < r->height; z++ ) {
|
||||
@ -321,8 +320,8 @@ im_prepare_to( REGION *reg, REGION *dest, Rect *r, int x, int y )
|
||||
image.height = reg->im->Ysize;
|
||||
im_rect_intersectrect( r, &image, &clipped );
|
||||
|
||||
assert( clipped.left == r->left );
|
||||
assert( clipped.top == r->top );
|
||||
g_assert( clipped.left == r->left );
|
||||
g_assert( clipped.top == r->top );
|
||||
|
||||
wanted.left = x + (clipped.left - r->left);
|
||||
wanted.top = y + (clipped.top - r->top);
|
||||
|
@ -83,7 +83,7 @@
|
||||
#define DEBUGM
|
||||
*/
|
||||
|
||||
/* abort() on memory errors.
|
||||
/* g_assert( 0 ) on memory errors.
|
||||
#define DEBUG
|
||||
*/
|
||||
|
||||
@ -170,7 +170,7 @@ im_free( void *s )
|
||||
|
||||
#ifdef DEBUG
|
||||
if( !s )
|
||||
abort();
|
||||
g_assert( 0 );
|
||||
#endif /*DEBUG*/
|
||||
|
||||
g_free( s );
|
||||
@ -216,7 +216,7 @@ im_malloc( IMAGE *im, size_t size )
|
||||
|
||||
if( !(buf = g_try_malloc( size )) ) {
|
||||
#ifdef DEBUG
|
||||
abort();
|
||||
g_assert( 0 );
|
||||
#endif /*DEBUG*/
|
||||
|
||||
im_error( "im_malloc",
|
||||
|
Loading…
Reference in New Issue
Block a user