How can I generate images of circles, of varying sizes?
-
20-09-2019 - |
Question
For the task I'm trying to accomplish, I need to generate many images, all consisting of a black circle border on a transparent background, but each a different size (going up in size from 3x3 to, say, 20x20).
Preferably they would be GIFs or PNGs, as these support transparency.
I started building a simple C# Console project for this, but I'm wondering if there's already a tool out there that does this, so I can avoid wasting time.
Solution
Draw one 256x256 image of a circle, and scale it down with a batch tool like imagemagick, graphicsmagick, irfan-view, or some-such to all the sizes you need. Little code needed. This assumes you don't need a constantly sized width to the circle outline.
OTHER TIPS
Your strategy sounds good.
Simply create a Bitmap
of the correct size, create a Graphics
object using Graphics.FromImage()
.
Clear the Graphics
using Color.Transparent
and draw a black circle with FillCircle()
.
If you need antialiasing, set smoothing mode to high quality.
I think it would be faster to just make your 18 PNGs in GIMP or some other comparable paint program.