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