Silverlight - WriteableBitmap的跨域调用限制

来源:互联网 发布:神舟z7编程 编辑:程序博客网 时间:2024/06/11 03:52

Silverlight 3中增加的WriteableBitmap 大大方便了图片编辑。最近使用了.NET Image Tools,其中很多编辑功能都是基于对WritableBitmap的操作。项目中有一个Image的Source是来自不同域下的Uri,使用.NET Image Tools是遇到了一个异常"Cannnot acess Bitmap" , 搜索到一个讨论,才发现WriteableBitmap也有跨域调用下的限制:

 

The WriteableBitmap class has a security model that restricts access to the Pixels array, if the WriteableBitmap is constructed using cross-domain content. For example, a WriteableBitmap that is constructed using a BitmapImage referencing a URL that comes from another domain does not permit access to its Pixels array. The restriction extends to any UI element that uses a URL-derived property for setting some or all of its content. In particular, this restriction applies to the "Grab a frame of a running video from MediaElement" scenario. If the MediaElement.Source references a video file from another domain, the WriteableBitmap created by referencing the MediaElement as the element source restricts access to the Pixels array.