2010-12-01 91 views
2

我在我的一个Silverlight项目中使用Microsoft的PivotViewer控件。我正在创建一个JIT集合,并希望根据WPF UserControl的渲染结果动态生成图像。为了生成图像,我使用HTTP处理程序动态提供图像。从HTTP处理程序中的WPF用户控件创建动态图像

任何人都可以指出我在正确的方向,我如何最好的去做这件事。这些都是相当混杂的技术,并且难以了解哪里最适合开始。

在此先感谢。

编辑:我发现这样做了这个在ASP.Net MVC here一个人 - 如果要传输的HTTP流式WPF视觉

回答

2

,伪代码将是这样的:

 RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32); 
     bmp.Render([your WPF visual or control instance]); 

     // choose the format if you want something other than png 
     PngBitmapEncoder png = new PngBitmapEncoder(); 
     png.Frames.Add(BitmapFrame.Create(bmp)); 

     // stream this on the web 
     png.Save([the web stream, like Response.OutputStream]); 
+0

做到这一点,但我什么也得不到,但一个黑色的矩形,..不管我给它什么xaml。任何想法? – Stimul8d 2010-12-01 15:00:59