【问题标题】:How to save SoftwareBitmap object to bmp file C#, UWP如何将 SoftwareBitmap 对象保存到 bmp 文件 C#,UWP
【发布时间】:2020-12-23 21:14:12
【问题描述】:

我将 jpg 图像转换为 SoftwareBitmap 对象,我希望它能工作。代码如下。

SoftwareBitmap softwareBitmap;

            using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read))
            {
                // Create the decoder from the stream
                BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);

                // Get the SoftwareBitmap representation of the file
                softwareBitmap = await decoder.GetSoftwareBitmapAsync();


            }

所以我现在不知道如何使用这个softwareBitmap制作.bmp文件。提前谢谢。

【问题讨论】:

标签: c# uwp bitmap bmp


【解决方案1】:

改用Bitmap


using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read))
{
    Bitmap bmp = new Bitmap(stream);
    bmp.Save(filePath, System.Drawing.Imaging.ImageFormat.Bmp);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-30
    • 1970-01-01
    • 1970-01-01
    • 2016-08-15
    • 1970-01-01
    • 2014-10-16
    相关资源
    最近更新 更多