austen.bernstein#29652
I'm trying to draw text onto a transparent png but not having success.
Its always black text on a white background-- how to make it transparent?
Its always black text on a white background-- how to make it transparent?
using (var bitmap = new Bitmap(Convert.ToInt32(Width.Value), Convert.ToInt32(Height.Value), PixelFormat.Format32bppArgb, new RgbColor(255, 255, 255, 255)))
{
using (var graphics = bitmap.GetAdvancedGraphics())
{
using (var fontRegistry = new CustomFontRegistry())
{
var brush = new SolidBrush(color);
var customFont = CustomFontCollection.TryGetAurigmaFont(Font);
float dpi = 300;
BoundedText text = null;
Aurigma.GraphicsMill.AdvancedDrawing.Font font = null;
if (!string.IsNullOrEmpty(customFont))
{
var psName = fontRegistry.Add(customFont);
font = fontRegistry.CreateFont(psName, (float)FontSize, 72, 72);
dpi = font.DpiX;
}
else
{
font = graphics.CreateFont(Font, (float)FontSize);
}
text = new BoundedText(Text, font, new System.Drawing.RectangleF(0, 0, (float)Width.Value, (float)Height.Value));
text.Pen = new Pen(color);
graphics.DrawText(text);
_RenderedFontGraphicsFile = ctx.GetPathToNewTempFile("hi.png");
bitmap.Save(_RenderedFontGraphicsFile);
}
}
}