Skip to content

Commit

Permalink
implement platform-agnostic comparison without abs()
Browse files Browse the repository at this point in the history
  • Loading branch information
abishai committed Jan 31, 2017
1 parent 9e9b1a3 commit 97380f0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/zm_image.cpp
Expand Up @@ -1658,11 +1658,9 @@ Image *Image::Highlight( unsigned int n_images, Image *images[], const Rgb thres
{
uint8_t *psrc = images[j]->buffer+c;

#ifndef SOLARIS
if ( (unsigned)abs((*psrc)-RGB_VAL(ref_colour,c)) >= RGB_VAL(threshold,c) )
#else
if ( (unsigned)std::abs((*psrc)-RGB_VAL(ref_colour,c)) >= RGB_VAL(threshold,c) )
#endif
unsigned int diff = ((*psrc)-RGB_VAL(ref_colour,c)) > 0 ? (*psrc)-RGB_VAL(ref_colour,c) : RGB_VAL(ref_colour,c) - (*psrc);

if (diff >= RGB_VAL(threshold,c))
{
count++;
}
Expand Down

0 comments on commit 97380f0

Please sign in to comment.