diff options
Diffstat (limited to 'Build/source/libs/gd/libgd-2.1.0/src/gd_color.c')
-rw-r--r-- | Build/source/libs/gd/libgd-2.1.0/src/gd_color.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Build/source/libs/gd/libgd-2.1.0/src/gd_color.c b/Build/source/libs/gd/libgd-2.1.0/src/gd_color.c new file mode 100644 index 00000000000..6d8a8466b8a --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/src/gd_color.c @@ -0,0 +1,30 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gd.h" +#include "gd_color.h" + +int gdColorMatch(gdImagePtr im, int col1, int col2, float threshold) +{ + const int dr = gdImageRed(im, col1) - gdImageRed(im, col2); + const int dg = gdImageGreen(im, col1) - gdImageGreen(im, col2); + const int db = gdImageBlue(im, col1) - gdImageBlue(im, col2); + const int da = gdImageAlpha(im, col1) - gdImageAlpha(im, col2); + const int dist = dr * dr + dg * dg + db * db + da * da; + + return (100.0 * dist / 195075) < threshold; +} + +/* + * To be implemented when we have more image formats. + * Buffer like gray8 gray16 or rgb8 will require some tweak + * and can be done in this function (called from the autocrop + * function. (Pierre) + */ +#if 0 +static int colors_equal (const int col1, const in col2) +{ + +} +#endif |