diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2019-06-23 18:15:44 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2019-06-23 18:50:56 (GMT) |
commit | 6fb61b2c6561149c1a318df26fd1acac619b3519 (patch) | |
tree | ad73d56e94aebbd888db4077bc367895fbb8ad83 /libmscgen/gd_color.c | |
parent | 15678e7ccb524af8c90a4018f3b882ba184e6a39 (diff) | |
download | Doxygen-6fb61b2c6561149c1a318df26fd1acac619b3519.zip Doxygen-6fb61b2c6561149c1a318df26fd1acac619b3519.tar.gz Doxygen-6fb61b2c6561149c1a318df26fd1acac619b3519.tar.bz2 |
issue #6880 mscgen links placed in the wrong place when using SVG output
Diffstat (limited to 'libmscgen/gd_color.c')
-rw-r--r-- | libmscgen/gd_color.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libmscgen/gd_color.c b/libmscgen/gd_color.c new file mode 100644 index 0000000..ba0efd8 --- /dev/null +++ b/libmscgen/gd_color.c @@ -0,0 +1,35 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gd.h" +#include "gd_color.h" + +/** + * The threshold method works relatively well but it can be improved. + * Maybe L*a*b* and Delta-E will give better results (and a better + * granularity). + */ +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 |