T
Tem
I'm still trying to figure out how to do this simple task with WPF.
I need to draw a black circle using WPF and generate an image file. (gif or
png)
Any help is greatly appreciated.
Tem
I used the following but it resulted in a blank file. I cannot figure out
what is wrong with it.
RenderTargetBitmap rtb = new RenderTargetBitmap(200, 200, 96, 96,
PixelFormats.Pbgra32);
Ellipse cir = new Ellipse();
cir.Height = 50;
cir.Width = 50;
cir.Stroke = Brushes.Black;
cir.StrokeThickness = 1.0;
rtb.Render(cir);
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(rtb));
using (Stream fs= File.Create("test.png"))
{
png.Save(fs);
}
I need to draw a black circle using WPF and generate an image file. (gif or
png)
Any help is greatly appreciated.
Tem
I used the following but it resulted in a blank file. I cannot figure out
what is wrong with it.
RenderTargetBitmap rtb = new RenderTargetBitmap(200, 200, 96, 96,
PixelFormats.Pbgra32);
Ellipse cir = new Ellipse();
cir.Height = 50;
cir.Width = 50;
cir.Stroke = Brushes.Black;
cir.StrokeThickness = 1.0;
rtb.Render(cir);
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(rtb));
using (Stream fs= File.Create("test.png"))
{
png.Save(fs);
}