Win10的鎖屏壁紙質量頗高,不少用戶都希望把它們保存下來。如何保存Win10鎖屏壁紙呢?本文從多個方面進行詳細介紹。
一、鎖屏壁紙怎麼保存到相冊
如果您想把鎖屏壁紙保存到Win10相冊中,可以按照以下操作:
步驟1:右鍵點擊桌面空白處,選擇“個性化”。
步驟2:在“個性化設置”中點擊“鎖屏”。
步驟3:在“選擇您的鎖屏設置”中選中要保存的圖片,然後點擊“瀏覽”。
步驟4:選擇“本地磁盤”,在彈出的“保存為”窗口中,選擇保存的路徑和文件名,最後點擊“保存”即可。
代碼示例:
// C#代碼示例 // 獲取當前鎖屏壁紙 string wallpaperPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets"); string destinationPath = "D:\Pictures\"; Directory.CreateDirectory(destinationPath); var fileNames = Directory.GetFiles(wallpaperPath); foreach (string fileName in fileNames) { try { File.Copy(fileName, Path.Combine(destinationPath, Path.GetFileName(fileName) + ".jpg")); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
二、Win10鎖屏壁紙怎麼保存
如果你想保存Win10系統當前使用的鎖屏壁紙,可以使用Windows自帶的截圖工具或者第三方軟件進行截圖。
方式1:使用Windows自帶截圖工具
步驟1:按下Win+PrntScrn鍵,會自動將截圖保存到系統的默認圖片文件夾中。
方式2:使用第三方截圖軟件
推薦使用免費的截圖軟件Snipaste進行截圖,下載網址:https://www.snipaste.com/
代碼示例:
// C#代碼示例 private async void SaveWallpaperButton_Click(object sender, RoutedEventArgs e) { var savePicker = new FileSavePicker(); savePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; savePicker.FileTypeChoices.Add("JPEG file", new List() { ".jpg" }); savePicker.SuggestedFileName = "LockScreen"; var file = await savePicker.PickSaveFileAsync(); if (file != null) { var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite); RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(); await renderTargetBitmap.RenderAsync(LockScreenContainer); var pixelBuffer = await renderTargetBitmap.GetPixelsAsync(); var logicalDpi = DisplayInformation.GetForCurrentView().LogicalDpi; var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, fileStream); encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore, (uint)renderTargetBitmap.PixelWidth, (uint)renderTargetBitmap.PixelHeight, logicalDpi, logicalDpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); fileStream.Dispose(); } }
三、鎖屏壁紙圖片怎麼保存
如果你想保存從鎖屏圖片文件夾中選擇的特定圖片,可以按照以下步驟操作:
步驟1:打開文件夾,找到鎖屏壁紙所在的文件夾,默認路徑為:%localappdata%\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets。
步驟2:在文件夾中選中要保存的圖片,複製到想要存儲的文件夾中。
代碼示例:
// C#代碼示例 private void SaveSelectedWallpaperButton_Click(object sender, RoutedEventArgs e) { var folderPicker = new FolderPicker(); folderPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; folderPicker.FileTypeFilter.Add("*"); var folder = folderPicker.PickSingleFolderAsync(); if (folder != null) { var fileNames = SelectedWallpaperList.SelectedItems.Cast().ToList(); foreach (string fileName in fileNames) { var wallpaperPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets", fileName); var destinationPath = Path.Combine(folder.Path, fileName + ".jpg"); File.Copy(wallpaperPath, destinationPath); } } }
四、鎖屏壁紙如何保存
如果你想將鎖屏壁紙設置為桌面壁紙,也可以進行保存,具體操作步驟如下:
步驟1:在“選擇您的鎖屏設置”中選擇要設置為桌面壁紙的鎖屏壁紙。
步驟2:點擊“更改為桌面壁紙”按鈕,就可以將其設置為桌面壁紙了。
代碼示例:
// C#代碼示例 private async void SetWallpaperButton_Click(object sender, RoutedEventArgs e) { if (SelectedWallpaperList.SelectedItems.Count == 0) { return; } var fileNames = SelectedWallpaperList.SelectedItems.Cast().ToList(); var wallpaperPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets", fileNames.ElementAt(0)); if (!File.Exists(wallpaperPath)) { return; } var wallpaperFile = await DownloadFile(wallpaperPath); if (wallpaperFile != null) { var profile = UserProfilePersonalizationSettings.Current; var result = await profile.TrySetWallpaperImageAsync(wallpaperFile); if (result) { await new MessageDialog("桌面壁紙已設置成功").ShowAsync(); } } if (wallpaperFile != null) { await wallpaperFile.DeleteAsync(); } } private async Task DownloadFile(string imageUrl) { try { var fileUri = new Uri("ms-appdata:///local/" + Guid.NewGuid() + ".jpg"); StorageFile destinationFile = await StorageFile.GetFileFromApplicationUriAsync(fileUri); StorageFile downloadedFile = await StorageFile.GetFileFromPathAsync(imageUrl); await downloadedFile.CopyAndReplaceAsync(destinationFile); return destinationFile; } catch (Exception ex) { Debug.WriteLine(ex.Message); return null; } }
五、鎖屏屏保壁紙選取
如果你想選擇特定的圖片作為鎖屏壁紙,可以參照以下步驟選取:
步驟1:右鍵點擊桌面空白處,選擇“個性化”。
步驟2:在“個性化設置”中點擊“鎖屏”。
步驟3:在“選擇您的鎖屏設置”下方,點擊“瀏覽”按鈕,並選擇要設置為鎖屏壁紙的圖片即可。
代碼示例:
// C#代碼示例 private async void PickWallpaperButton_Click(object sender, RoutedEventArgs e) { var picker = new FileOpenPicker(); picker.ViewMode = PickerViewMode.Thumbnail; picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".png"); var file = await picker.PickSingleFileAsync(); if (file != null) { var profile = UserProfilePersonalizationSettings.Current; var result = await profile.TrySetLockScreenImageAsync(file); if (result) { await new MessageDialog("鎖屏壁紙已設置成功").ShowAsync(); } } }
本文介紹了多種保存Win10鎖屏壁紙的方法,希望對你有所幫助。
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/237518.html