I have several UIElement
s, including an Image
(with an External URL image), and then I want to catch a thumbnail of these elements, so I use WriteableBitmap
to catch the pixels for each UIElement.
However, when I try to catch the pixel for the Image
using:
WriteableBitmap wb = new WriteableBitmap(image, new ScaleTransform()
{
ScaleX = 0.5,
ScaleY = 0.5,
});
...
wb.GetPixeli(x, y); // Throws exception
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap(v=vs.95).aspx
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.
So in order to catch the thumbnail of these several UIElement
s (including an Image
element) do I have to download the image to a temp directory and then render it?