public static PngBitmapEncoder ScreenshotDeck(DeckListView dlv, double dpiX, double dpiY, string name) { try { var rtb = new RenderTargetBitmap((int)dlv.ActualWidth, (int)dlv.ActualHeight, dpiX, dpiY, PixelFormats.Pbgra32); rtb.Render(dlv); var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(rtb)); return(encoder); } catch (Exception) { return(null); } }
public static string ScreenshotDeck(DeckListView dlv, double dpiX, double dpiY, string name) { try { var rtb = new RenderTargetBitmap((int)dlv.ActualWidth, (int)dlv.ActualHeight, dpiX, dpiY, PixelFormats.Pbgra32); rtb.Render(dlv); var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(rtb)); var path = GetValidFilePath("Screenshots", name, ".png"); using (var stream = new FileStream(path, FileMode.Create, FileAccess.Write)) encoder.Save(stream); return(path); } catch (Exception) { return(null); } }
public static string ScreenshotDeck(DeckListView dlv, double dpiX, double dpiY, string name) { try { var rtb = new RenderTargetBitmap((int)dlv.ActualWidth, (int)dlv.ActualHeight, dpiX, dpiY, PixelFormats.Pbgra32); rtb.Render(dlv); var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(rtb)); var path = GetValidFilePath("Screenshots", name, ".png"); using(var stream = new FileStream(path, FileMode.Create, FileAccess.Write)) encoder.Save(stream); return path; } catch(Exception) { return null; } }