如何以编程方式需要在Windows Phone屏幕截图? [英] How to programmatically take a screenshot on windows phone?
本文介绍了如何以编程方式需要在Windows Phone屏幕截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要采用Windows Phone采取截图。我不想把使用仿真器和电源+手动启动按钮截图。有没有什么可以通过编程来实现?
I need to take screenshots using Windows Phone. I don't want to take screenshots using the emulator and power+start button manually. Is there anything that can be done programmatically ?
推荐答案
下面是code:
private void ApplicationBarScreenshotButton_Click(object sender, EventArgs e)
{
var fileName = String.Format("MyImage_{0:}.jpg", DateTime.Now.Ticks);
WriteableBitmap bmpCurrentScreenImage = new WriteableBitmap((int)this.ActualWidth, (int)this.ActualHeight);
bmpCurrentScreenImage.Render(LayoutRoot, new MatrixTransform());
bmpCurrentScreenImage.Invalidate();
SaveToMediaLibrary(bmpCurrentScreenImage, fileName, 100);
MessageBox.Show("Captured image " + fileName + " Saved Sucessfully", "WP Capture Screen", MessageBoxButton.OK);
currentFileName = fileName;
}
public void SaveToMediaLibrary(WriteableBitmap bitmap, string name, int quality)
{
using (var stream = new MemoryStream())
{
// Save the picture to the Windows Phone media library.
bitmap.SaveJpeg(stream, bitmap.PixelWidth, bitmap.PixelHeight, 0, quality);
stream.Seek(0, SeekOrigin.Begin);
new MediaLibrary().SavePicture(name, stream);
}
}
当你点击按钮AppBar将采取的截图并保存图片到Windows Phone媒体库
When you click on the AppBar button it will take the screenshot and Save the picture to the Windows Phone media library
这篇关于如何以编程方式需要在Windows Phone屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文