Subtract the inner shape before filling the outer one, so the hole stays transparent.
dotnet add package RecursiveAI.OneImageRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using OneImage; using OneImage.Drawing; using Path = OneImage.Drawing.Path; var outer = Path.Circle(80, 80, 64); var inner = Path.Circle(80, 80, 32); var blank = Image.FromPixels<Rgba32>( new Rgba32[160 * 160], 160, 160); blank.Fill(new Rgba32(30, 110, 220, 255), outer.Subtract(inner)).Save("ring.png");
The example is the full program below: unzip it and dotnet run. To run only the code above, paste it into Program.cs of a new dotnet new console project and dotnet run.
Writes ring.png, a blue ring on a transparent 160 × 160 image. No input files are needed.
The full program
using OneImage; using OneImage.Drawing; using Path = OneImage.Drawing.Path; var outer = Path.Circle(80, 80, 64); var inner = Path.Circle(80, 80, 32); var ring = outer.Subtract(inner); var ink = new Rgba32(30, 110, 220, 255); var blank = Image.FromPixels<Rgba32>( new Rgba32[160 * 160], 160, 160); blank.Fill(ink, ring).Save("ring.png"); Image saved = Image.Load("ring.png"); var pixels = saved.ToArray<Rgba32>(); Console.WriteLine($"ring.png: {saved.Width}x{saved.Height}"); Console.WriteLine($"Hole alpha: {pixels[80 * 160 + 80].A}"); Console.WriteLine($"Ring alpha: {pixels[80 * 160 + 32].A}");
ring.png: 160x160 Hole alpha: 0 Ring alpha: 255

The program reloads the PNG and reads two pixels away from the edges: the center is fully transparent (0) and the left side of the ring is opaque (255). If the inner shape covers the whole outer shape, Subtract returns Path.Empty and there’s nothing to paint.
Variations
Cut a notch instead of a hole. With outer and blank from the snippet at the top, put the opening over the right edge. Only the part that overlaps the outer circle is removed:
var notch = outer.Subtract(Path.Circle(140, 80, 32)); blank.Fill(new Rgba32(30, 110, 220, 255), notch).Save("notch.png");
Related recipes
The short answer
Use outer.Subtract(inner) to subtract one closed vector path from another in C#. It returns the part of outer that isn’t covered by inner. Fill that path on a transparent RGBA image and save it as PNG to leave the opening transparent in the output.
How do you cut a hole in a vector shape?
Make two closed paths in the same coordinate system, then subtract the shape of the opening from the one you want to keep. In the example both paths are circles centered at (80, 80). The opening has radius 32 and the outer boundary has radius 64, so a band 32 pixels thick remains between them. You can use a different shape for the opening; the inside path doesn’t need to match the outside. What matters is that the opening lies wholly inside the boundary if you want a closed hole rather than a notch.
This operation is called a Boolean difference. Order matters: inner.Subtract(outer) in this example is empty because all of the smaller circle is covered by the larger one. If the two paths don’t overlap, the filled region of the first path is unchanged.
The drawing guide describes the result as “a Path of straight-edged, closed polygons.” Curves are flattened to short line segments using the path operation’s tolerance (0.1 pixel by default). The resulting outer contours and holes run in opposite directions, so the result fills the same under the non-zero and even-odd fill rules. You don’t have to reverse the inner circle yourself.
How do you make the cutout transparent in a PNG?
Start with a transparent background, not a white one. In the example the new Rgba32 array has zero in every channel, including alpha. Filling the difference paints the band but doesn’t paint the opening. Where the path crosses a pixel, anti-aliasing can leave it partly transparent, so use pixels well away from an edge if you want to check that the hole is completely clear.
Subtracting paths changes geometry, not pixels that are already on a canvas. If you fill the ring on top of a photo, you’ll see the photo through the hole; you won’t erase the photo. To cut a hole in existing pixels, use an alpha mask instead. To keep an editable outline, keep the resulting Path; saving to PNG turns it into pixels at the chosen size.