Silverlight: Create image from silverlight control

2020-04-14 08:23发布

Is it possible to generate an image from a silverlight control so that the control would render itself and its contents to an image so that I can do sime pixel manipulation on the image?

2条回答
Animai°情兽
2楼-- · 2020-04-14 08:49

After searching the Silverlight forums, it seems that this feature isn't available yet, despite many requests. Although, Silverlight 3 beta was just released this week and I'm not sure what the status is on this issue in regards to that release.

查看更多
家丑人穷心不美
3楼-- · 2020-04-14 08:59

There is no way to achieve this in Silverlight 2. I have seen people work around this limitation by posting XAML to a server which would use WPF to render it to a bitmap (using RenderTargetBitmap) and return an image.

However, the just released Silverlight 3 Beta includes a WritableBitmap class which can be used to render a Silverlight UIElement into pixels. In the beta there is however a limitation; once you render an element into the bitmap you cannot access its pixels. This restriction should be eased somewhat in the final release.

Silverlight 3 Beta also includes pixel shaders, so you can write a custom shader in HLSL and apply it to any UIElement - this might be the best solution for you. This tutorial video should get you started on writing and using pixel shaders in Silverlight 3 Beta. http://silverlight.net/learn/learnvideo.aspx?video=187303

查看更多
登录 后发表回答