#include <stdlib.h>
#include <math.h>
+static inline int clamp( int v, int l, int u )
+{
+ return v < l ? l : ( v > u ? u : v );
+}
+
/** Do it :-).
*/
while ( p != q )
{
- *p ++ = 251 - *r ++;
- *p ++ = 251 - *r ++;
+ *p ++ = clamp( 251 - *r ++, 16, 235 );
+ *p ++ = clamp( 256 - *r ++, 16, 240 );
}
}