# Create a all black image and Cvb.ImageDrawer.FillCircle

**URL:** <https://forum.commonvisionblox.com/t/create-a-all-black-image-and-cvb-imagedrawer-fillcircle/1056>\
**Category:** .Net API\
**Tags:** drawing\
**Created:** [February 18, 2020, 12:50am UTC](https://forum.commonvisionblox.com/t/create-a-all-black-image-and-cvb-imagedrawer-fillcircle/1056 "2020-02-18T00:50:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesse](https://avatars.discourse-cdn.com/v4/letter/j/c77e96/32.png) [@Jesse](https://forum.commonvisionblox.com/u/Jesse)\
**Post date:** [February 18, 2020, 12:50am UTC](https://forum.commonvisionblox.com/t/create-a-all-black-image-and-cvb-imagedrawer-fillcircle/1056/1 "2020-02-18T00:50:37Z")

</div>

Hi Sir:

I want to create a mask image like this. ![mask](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/c0c72f5ca9686837e59cbb5d5cb11ad1709370d5.png)

Could you give me some example ? and help me to check my code below, thank you.

I have two questions:  
1.How to use Stemmer cvb dll to create a black image?  
2.I try to use Stemmer.Cvb.ImageDrawer.FillCircle function to draw fill circle on my image, but it also show this exception.

I try to use Stemmer.Cvb.ImageDrawer.FillCircle function to draw fill circle on my image, but it also show this exception.  
 ![draw circle exception](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/56727ae209811c184200e2ef0e26fdd7b1a8a9c4.png)

My C# Code:

private void CreateMask()  
{  
try  
{  
string filepath = “bb.bmp”;  
Stemmer.Cvb.Image mask\_image = Stemmer.Cvb.Image.FromFile(filepath);  
mask\_image.Initialize(0);

```
	Stemmer.Cvb.ImageDrawer.FillCircle(mask_image.Planes[0], 255, 50, 50, 10);

	mask_image.Save("mask with circle.bmp");
}
catch (Exception ee)
{
	MessageBox.Show(ee.ToString());
}

```

}

---

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [February 26, 2020, 8:09am UTC](https://forum.commonvisionblox.com/t/create-a-all-black-image-and-cvb-imagedrawer-fillcircle/1056/2 "2020-02-26T08:09:37Z")

</div>

This is basically the same issue as with the `DrawCircle` method you had:

[https://forum.commonvisionblox.com/t/stemmer-cvb-imagedrawer-drawcircle/1032/2?u=parsd](https://forum.commonvisionblox.com/t/stemmer-cvb-imagedrawer-drawcircle/1032/2)

Here is the workaround for the `FillCircle` method:

```auto
public static class ImageDrawer
  {
    private const int AntiAliasOff = 0;
    private const int NormalDrawMode = 0;

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

    public static void FillCircle(Image image, double[] intensity, 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)
        FillCircle(image.Planes[i], intensity[i], centerX, centerY, radius);
    }

    public static void FillCircle(ImagePlane plane, double intensity, int centerX, int centerY, int radius)
    {
      int result = FillCircleInImage(plane.Parent.Handle, plane.Plane, centerX, centerY, radius, intensity, NormalDrawMode, AntiAliasOff);
      if (result < 0)
        throw CvbException.FromCvbResult(result);
    }

    [DllImport("CVCImg")]
    private static extern int FillCircleInImage(IntPtr image, int index, int centerX, int centerY, int radius, double intensity, int drawMode, int antiAliasMode);
  }

```
