Create dynamic images from WPF User Control inside an HTTP Handler
I'm using Microsoft's PivotView开发者_运维百科er control in one of my Silverlight projects. I'm creating a JIT collection and was hoping to dynamically generate the images based on the rendered result of a WPF UserControl. In order to generate the images I'm using an HTTP Handler to serve the images up dynamically.
Can anyone point me in the right direction on how I might best go about this. It's all quite a mashup of technologies and a bit difficult to know where best to begin.
Thanks in advance.
EDIT: I have found a guy that's done this in ASP.Net MVC here -
If you want to stream on the HTTP stream a WPF visual, the pseudo code would be something like this:
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]);
精彩评论