diff --git a/ChangeLog b/ChangeLog index f0cb18ae..167e0449 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ - fix warning for unused vips7 gvalue argument - fix openslide read: always return png-style rgba, im_argb2rgba() becomes a NOP +- cast to unsigned int now removes <0 values 13/3/12 started 7.28.2 - xres/yres tiffsave args were broken diff --git a/libvips/conversion/cast.c b/libvips/conversion/cast.c index 9e5d05f7..a18c2357 100644 --- a/libvips/conversion/cast.c +++ b/libvips/conversion/cast.c @@ -45,6 +45,8 @@ * - gtk-doc * 27/10/11 * - redone as a class + * 10/4/12 + * - cast to uint now removes <0 values */ /* @@ -288,7 +290,7 @@ vips_cast_start( VipsImage *out, void *a, void *b ) break; \ \ case VIPS_FORMAT_UINT: \ - INT( ITYPE, unsigned int, VIPS_CLIP_NONE ); \ + INT( ITYPE, unsigned int, VIPS_CLIP_UINT ); \ break; \ \ case VIPS_FORMAT_INT: \ diff --git a/libvips/include/vips/util.h b/libvips/include/vips/util.h index 4d235fd0..cf508778 100644 --- a/libvips/include/vips/util.h +++ b/libvips/include/vips/util.h @@ -146,6 +146,14 @@ G_STMT_START { \ } \ } G_STMT_END +#define VIPS_CLIP_UINT( V, SEQ ) \ +G_STMT_START { \ + if( (V) < 0 ) { \ + (SEQ)->underflow++; \ + (V) = 0; \ + } \ +} G_STMT_END + #define VIPS_CLIP_NONE( V, SEQ ) {} const char *vips_enum_string( GType enm, int value );