Silverlight: Create image from silverlight controls

送分小仙女□ 提交于 2019-12-20 03:25:11

问题


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?


回答1:


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




回答2:


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.

  • http://silverlight.net/forums/p/12240/39427.aspx
  • http://silverlight.net/forums/t/17109.aspx
  • http://silverlight.net/forums/p/18438/62854.aspx


来源:https://stackoverflow.com/questions/668090/silverlight-create-image-from-silverlight-controls

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!