【问题标题】:saving canvas image to local storage将画布图像保存到本地存储
【发布时间】:2014-06-29 17:33:00
【问题描述】:

我正在使用画布对象在 Visual Studio 2013 中制作一个 Windows Phone 应用程序,并将我绘制的内容作为 jpeg 保存在本地内部存储中。保存的图像是黑色的。我在 Android 中发现了很多处理这个问题的线程,但对于 Windows Phone / C# 却没有。我目前的代码如下:

public static void SaveImage(Canvas c, string filename)
    {
        var bmp = new WriteableBitmap(421, 627);
        bmp.Render(c, null);

        using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
        {
            using (IsolatedStorageFileStream stream = storage.CreateFile(filename))
            {
                bmp.SaveJpeg(stream, 200, 100, 0, 95);
                stream.Close();
            }
        }
    }

必须有大量将位图保存到本地存储的示例。欢迎任何指导。

【问题讨论】:

    标签: c# canvas


    【解决方案1】:

    【讨论】:

    • 感谢您的链接,但我发现上面的代码缺少什么。我只需要插入“bmp.Invalidate();”行在 bmp.Render 之后。
    猜你喜欢
    • 1970-01-01
    • 2023-04-04
    • 2011-09-19
    • 1970-01-01
    • 2013-11-23
    • 2018-06-13
    • 2013-06-04
    • 1970-01-01
    • 2013-08-20
    相关资源
    最近更新 更多