From 36cb8b4eb725a16f31f860db5e78b0cbf95a8a21 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 17 Nov 2010 13:29:52 +0000 Subject: [PATCH] ooops draw_scanline clipping --- libvips/inplace/draw.c | 6 ++++-- libvips/inplace/im_draw_circle.c | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libvips/inplace/draw.c b/libvips/inplace/draw.c index c92403b6..fa49e09f 100644 --- a/libvips/inplace/draw.c +++ b/libvips/inplace/draw.c @@ -2,6 +2,8 @@ * * 27/9/10 * - from im_draw_circle() + * 17/11/10 + * - oops, scanline clipping was off by 1 */ /* @@ -56,11 +58,11 @@ im__draw_scanline( Draw *draw, int y, int x1, int x2 ) g_assert( x1 <= x2 ); - if( y < 0 || y > draw->im->Ysize ) + if( y < 0 || y >= draw->im->Ysize ) return; if( x1 < 0 && x2 < 0 ) return; - if( x1 > draw->im->Xsize && x2 > draw->im->Xsize ) + if( x1 >= draw->im->Xsize && x2 >= draw->im->Xsize ) return; x1 = IM_CLIP( 0, x1, draw->im->Xsize - 1 ); x2 = IM_CLIP( 0, x2, draw->im->Xsize - 1 ); diff --git a/libvips/inplace/im_draw_circle.c b/libvips/inplace/im_draw_circle.c index ace6d429..76b35444 100644 --- a/libvips/inplace/im_draw_circle.c +++ b/libvips/inplace/im_draw_circle.c @@ -131,6 +131,8 @@ circle_new( IMAGE *im, int cx, int cy, int radius, gboolean fill, PEL *ink ) { Circle *circle; + if( im_check_coding_known( "im_draw_circle", im ) ) + return( NULL ); if( !(circle = IM_NEW( NULL, Circle )) ) return( NULL ); if( !im__draw_init( DRAW( circle ), im, ink ) ) { @@ -201,9 +203,7 @@ im_draw_circle( VipsImage *image, y + radius >= 0 && y - radius < image->Ysize ) { Circle *circle; - if( im_check_coding_known( "im_draw_circle", image ) || - !(circle = circle_new( image, - x, y, radius, fill, ink )) ) + if( !(circle = circle_new( image, x, y, radius, fill, ink )) ) return( -1 ); circle_draw( circle );