Stemmer.Cvb.ImageDrawer.DrawCircle

Hi @Jesse,

yes, there is a bug in the DrawCircle function. Until we fix this you can use this workaround:

using System;
using System.Runtime.InteropServices;

using Stemmer.Cvb;

namespace CvbExtensions
{
  public static class ImageDrawer
  {
    private const int AntiAliasOff = 0;
    private const int NormalDrawMode = 0;

    public static void DrawCircle(Image image, RgbColor color, int thickness, int centerX, int centerY, int radius)
    {
      DrawCircle(image, new double[] { color.R, color.G, color.B }, thickness, centerX, centerY, radius);
    }

    public static void DrawCircle(Image image, double[] intensity, int thickness, int centerX, int centerY, int radius)
    {
      if (image == null)
        throw new ArgumentNullException(nameof(image));
      if (image.Planes.Count != intensity.Length)
        throw new ArgumentException("Intensity array length differs in regard to the number of planes", nameof(intensity));
      for (int i = 0; i < intensity.Length; ++i)
        DrawCircle(image.Planes[i], intensity[i], thickness, centerX, centerY, radius);
    }

    public static void DrawCircle(ImagePlane plane, double intensity, int thickness, int centerX, int centerY, int radius)
    {
      int result = DrawCircleInImage(plane.Parent.Handle, plane.Plane, centerX, centerY, radius, intensity, thickness, NormalDrawMode, AntiAliasOff);
      if (result < 0)
        throw CvbException.FromCvbResult(result);
    }
    
    [DllImport("CVCImg")]
    private static extern int DrawCircleInImage(IntPtr image, int index, int centerX, int centerY, int radius, double intensity, int thickness, int drawMode, int antiAliasMode);
  }
}