tags:

views:

955

answers:

2

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?

A: 

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.

bendewey
+1  A: 

Hi Jeremy, 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

KeithMahoney