Skip to content

Commit

Permalink
cast to unsigned int did not remove <0
Browse files Browse the repository at this point in the history
previously cast to uint did nothing (since the positive range of uint is
greater than int), now it changes <0 values to 0
  • Loading branch information
jcupitt committed Apr 10, 2012
1 parent 57cf901 commit 7af1fb3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion libvips/conversion/cast.c
Expand Up @@ -45,6 +45,8 @@
* - gtk-doc
* 27/10/11
* - redone as a class
* 10/4/12
* - cast to uint now removes <0 values
*/

/*
Expand Down Expand Up @@ -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: \
Expand Down
8 changes: 8 additions & 0 deletions libvips/include/vips/util.h
Expand Up @@ -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 );
Expand Down

0 comments on commit 7af1fb3

Please sign in to comment.