我有一個WPF應用程序生成一些報告。我需要從一個WindowService啓動這個應用程序,並且我正在從一個作爲LocalSystem運行的服務執行它。 所有的渲染都正確完成,除了一個Pie 3d,顯示在Viewport3D對象中。 這是表示該行爲代碼提取:Viewport3d從Windows服務呈現
static class VisualSaver
{
public static void Save(Visual v, int width, int height, string file,Brush background)
{
RenderTargetBitmap bmp = new RenderTargetBitmap(
width, height, 96, 96, PixelFormats.Pbgra32);
Rectangle vRect = new Rectangle();
vRect.Width = width;
vRect.Height = height;
vRect.Fill = background;
vRect.Arrange(new Rect(0, 0, vRect.Width, vRect.Height));
bmp.Render(vRect);
bmp.Render(v);
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(bmp));
using (Stream stm = File.Create(file))
{
png.Save(stm);
}
}
}
這是調用代碼:
VisualSaver.Save(viewport,310,340,PathExtension.GetTempFileWithExtension("png"),Brushes.White);
是的視口正確測量/編曲。
從3D對象的非交互式應用程序呈現是否存在一些限制,我在Windows7 - 2008服務器環境中。 ? 有沒有解決方法?