您的位置:

Win10锁屏壁纸怎么保存下来

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锁屏壁纸的方法,希望对你有所帮助。