Take Screenshot of current user control or any GUI in Silverlight 3
Asked Answered
P

2

5

I would like to ask if it is possible to take screenshot of current user control programmatically and save as a file in silverlight 3.

I found some ways to save as an image file for a Canvas in silverlight 3, but how about user control or childwindow ?

Thanks,

Pinkham answered 1/6, 2010 at 16:7 Comment(0)
A
5

Writable Bitmap will let you do it. See the samples and examples.

Albin answered 1/6, 2010 at 16:11 Comment(0)
P
2

Not sure about silverlight 3, but in 4 it's done like this:

public static byte[] CreatePngImage(this UIElement element)
{
    WriteableBitmap screenshot = new WriteableBitmap(element, new TranslateTransform());
    var image =  screenshot.ToImage();
    ImageTools.IO.Png.PngEncoder png = new ImageTools.IO.Png.PngEncoder();

    using (var mem = new System.IO.MemoryStream())
    {
        png.Encode(image, mem);
        var bytes = mem.GetBuffer();
        return bytes;
    }
}

where ImageTools.IO.Png.dll could be found here

Pubescent answered 13/11, 2012 at 12:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.