fix insert

We were not detecting the shortcut cases for insert correctly, thanks
chreru.

See https://github.com/libvips/libvips/issues/2548
This commit is contained in:
John Cupitt 2021-11-21 14:50:55 +00:00
parent f352bcd191
commit edf63dfeeb
3 changed files with 30 additions and 21 deletions

View File

@ -1,3 +1,6 @@
21/11/21 started 8.12.1
- fix insert [chregu]
14/6/21 started 8.12
- all tools support `--version`
- add vips_svgload_string() convenience function

View File

@ -2,7 +2,7 @@
# also update the version number in the m4 macros below
AC_INIT([vips], [8.12.0], [vipsip@jiscmail.ac.uk])
AC_INIT([vips], [8.12.1], [vipsip@jiscmail.ac.uk])
# required for gobject-introspection
AC_PREREQ([2.69])
@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4])
# user-visible library versioning
m4_define([vips_major_version], [8])
m4_define([vips_minor_version], [12])
m4_define([vips_micro_version], [0])
m4_define([vips_micro_version], [1])
m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version])
@ -41,7 +41,7 @@ VIPS_LIBS=""
# binary interface changed: increment current, reset revision to 0
# binary interface changes backwards compatible?: increment age
# binary interface changes not backwards compatible?: reset age to 0
LIBRARY_REVISION=0
LIBRARY_REVISION=1
LIBRARY_CURRENT=56
LIBRARY_AGE=14

View File

@ -95,14 +95,15 @@ typedef struct _VipsInsert {
*/
VipsPel *ink;
/* Inputs cast and banded up, plus a NULL at the end.
/* Inputs cast and banded up, plus a NULL at the end. main is 0, sub
* is 1.
*/
VipsImage *processed[3];
/* Geometry.
*/
VipsRect rout; /* Output space */
VipsRect rimage[2]; /* Position of main in output */
VipsRect rimage[2]; /* Position of input in output */
/* TRUE if we've minimised an input.
*/
@ -179,24 +180,29 @@ vips_insert_gen( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop )
int i;
/* First, does this request fall entirely inside one of our inputs? If
* it does, we can just redirect the request there. Test sub first.
/* Three cases:
*
* 1. If r is entirely within sub, we can just paint from sub.
* 2. If r is entirely within main and does not touch sub, we can
* paint from main.
* 3. We must paint from both, and the background.
*/
for( i = 1; i >= 0; i-- ) {
VipsRect *rimage = &insert->rimage[i];
if( vips_rect_includesrect( rimage, r ) ) {
if( vips__insert_just_one( or, ir[i],
rimage->left, rimage->top ) )
return( -1 );
break;
}
if( vips_rect_includesrect( &insert->rimage[1], r ) ) {
/* Just the subimage.
*/
if( vips__insert_just_one( or, ir[1],
insert->rimage[1].left, insert->rimage[1].top ) )
return( -1 );
}
/* Otherwise, it requires both (or neither) input.
*/
if( i < 0 ) {
else if( vips_rect_includesrect( &insert->rimage[0], r ) &&
!vips_rect_overlapsrect( &insert->rimage[1], r ) ) {
/* Just the main image.
*/
if( vips__insert_just_one( or, ir[0],
insert->rimage[0].left, insert->rimage[0].top ) )
return( -1 );
}
else {
/* Output requires both (or neither) input. If it is not
* entirely inside both the main and the sub, then there is
* going to be some background.