2014-07-07 151 views
0

任何人都可以請告訴我如何截圖並將其保存到Windows Phone 7中的編程文件夾中。我不想將圖像保存在MediaLibrary()中,但是我想將它保存到該應用程序的根目錄中的文件夾windows phone 7中的屏幕截圖

回答

0

此代碼將幫助您對AppBar按鈕單擊操作採取屏幕截圖。但是,您必須修改代碼以將屏幕截圖保存到應用程序的根文件夾中。以下鏈接將幫助你。

Save into local storage Data for Windows Phone

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); 

       // Use Above link to store file into Root folder. 
       //new MediaLibrary().SavePicture(name, stream); 
      } 
     }