fix clipping with new mapim cods
we had the clip in the wrong place see https://github.com/libvips/libvips/issues/1180
This commit is contained in:
parent
582b224125
commit
6ba4b3bfdb
@ -231,8 +231,8 @@ vips_mapim_region_minmax( VipsRegion *region, VipsRect *r, VipsRect *bounds )
|
|||||||
TYPE * restrict p1 = (TYPE *) p; \
|
TYPE * restrict p1 = (TYPE *) p; \
|
||||||
\
|
\
|
||||||
for( x = 0; x < r->width; x++ ) { \
|
for( x = 0; x < r->width; x++ ) { \
|
||||||
TYPE px = p1[0] + window_offset; \
|
TYPE px = p1[0]; \
|
||||||
TYPE py = p1[1] + window_offset; \
|
TYPE py = p1[1]; \
|
||||||
\
|
\
|
||||||
if( px >= clip_width || \
|
if( px >= clip_width || \
|
||||||
py >= clip_height ) { \
|
py >= clip_height ) { \
|
||||||
@ -240,7 +240,8 @@ vips_mapim_region_minmax( VipsRegion *region, VipsRect *r, VipsRect *bounds )
|
|||||||
q[z] = 0; \
|
q[z] = 0; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
interpolate( mapim->interpolate, q, ir[0], px, py ); \
|
interpolate( mapim->interpolate, q, ir[0], \
|
||||||
|
px + window_offset, py + window_offset ); \
|
||||||
\
|
\
|
||||||
p1 += 2; \
|
p1 += 2; \
|
||||||
q += ps; \
|
q += ps; \
|
||||||
@ -251,8 +252,8 @@ vips_mapim_region_minmax( VipsRegion *region, VipsRect *r, VipsRect *bounds )
|
|||||||
TYPE * restrict p1 = (TYPE *) p; \
|
TYPE * restrict p1 = (TYPE *) p; \
|
||||||
\
|
\
|
||||||
for( x = 0; x < r->width; x++ ) { \
|
for( x = 0; x < r->width; x++ ) { \
|
||||||
TYPE px = p1[0] + window_offset; \
|
TYPE px = p1[0]; \
|
||||||
TYPE py = p1[1] + window_offset; \
|
TYPE py = p1[1]; \
|
||||||
\
|
\
|
||||||
if( px < 0 || \
|
if( px < 0 || \
|
||||||
px >= clip_width || \
|
px >= clip_width || \
|
||||||
@ -262,7 +263,8 @@ vips_mapim_region_minmax( VipsRegion *region, VipsRect *r, VipsRect *bounds )
|
|||||||
q[z] = 0; \
|
q[z] = 0; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
interpolate( mapim->interpolate, q, ir[0], px, py ); \
|
interpolate( mapim->interpolate, q, ir[0], \
|
||||||
|
px + window_offset, py + window_offset ); \
|
||||||
\
|
\
|
||||||
p1 += 2; \
|
p1 += 2; \
|
||||||
q += ps; \
|
q += ps; \
|
||||||
|
@ -200,11 +200,9 @@ class TestResample:
|
|||||||
|
|
||||||
# this was a bug at one point, strangely, if executed with debug
|
# this was a bug at one point, strangely, if executed with debug
|
||||||
# enabled
|
# enabled
|
||||||
mp = pyvips.Image.xyz(100, 100)
|
mp = pyvips.Image.xyz(im.width, im.height)
|
||||||
interp = pyvips.Interpolate.new('bicubic')
|
interp = pyvips.Interpolate.new('bicubic')
|
||||||
assert im.mapim(mp, interpolate=interp).avg() == \
|
assert im.mapim(mp, interpolate=interp).avg() == im.avg()
|
||||||
im.crop(0, 0, 100, 100).avg()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user