保存 inkcanvas

发布于 2024-09-10 02:01:41 字数 336 浏览 1 评论 0原文

在我的应用程序中,用户可以创建多个对象(所谓的绘图),每个对象都有一个 SurfaceInkCanvas,与 SDKSamples(由 MS Surface SP1 SDK 提供)中的 Photopad(Photo Paint 应用程序)非常相似。 鉴于可能创建了数十甚至数百个 inkCanvas(绘图对象)的内容,保存 inkCanvas(绘图对象)内容的最佳方法是什么。

经过一番研究,出现了一个选项:将其转换为图像、jpg 或 png,但在我看来,这种方法似乎不太可扩展。

是否可以将点存储在数据库(最好是sqlite)中?

目标是能够恢复绘图(inkCanvas 的内容),以便在加载时进一步编辑。

In my application the user can create multiple objects (so called drawings) each of which has a SurfaceInkCanvas, very similar with the Photopad (the Photo Paint app)in the SDKSamples(provided by MS Surface SP1 SDK).
What would be the best way to save the content of the inkCanvas(the drawing object) given the fact that there may be tens or even hundreds of them created.

After some research, one option popped-out: converting it to an image, jpg or png, but this method doesn't seem that scalable IMO.

Would it be possible to store the points in a database(preferably sqlite)?

The goal is to be able to restore the drawings(contents of the inkCanvas) for further editing upon loading.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天涯离梦残月幽梦 2024-09-17 02:01:41

保存到图像对于您想要做的事情来说并不是真正可行,因为从位图恢复矢量线比矢量到位图转换要困难得多,并且可能有损耗,而且从数据密度的角度来看效率不高。

您可以编写一些代码来保存和恢复存储在 Strokes 属性中的线条集合。这将使您能够将数据大小减少到最小并轻松存储在数据库中。每个笔划都有一些有关线条外观的数据以及组成线条的一组点。重新加载时提取数据并将其恢复到另一个 InkCanvas 非常简单。

您也许还可以使用 XamlWriter/XamlReader 将整个 InkCanvas 序列化为 xml,但您需要能够将新的反序列化实例放入 UI 中,并确保 XAML 中不存在任何命名或资源复杂性。使用此方法往往会导致错误。

Saving to an image isn't really viable for what it sounds like you want to do because restoring vector lines from a bitmap is much harder and potentially lossy than the vector to bitmap conversion, in addition to not being very efficient from a data density perspective.

You could write some code to save and restore the collection of lines that's stored in the Strokes property. This would allow you to reduce the size of your data down to a minimum and easily store in a database. Each Stroke has some data about what the line looks like and a set of points that make up the line. It's fairly simple to extract and restore that data to another InkCanvas when reloading.

You might also be able to use XamlWriter/XamlReader to just serialize the entire InkCanvas to xml but you would need to be able to put the new deserialized instance into your UI and make sure there aren't any naming or resource complications in your XAML that tend to cause errors with this method.

臻嫒无言 2024-09-17 02:01:41

微软已经有一种保存笔画的格式,即 ISF - 代表墨水序列化格式,它将笔画集合保存在 .isf 文件中。

然而,在这个示例中,每个绘图都保存在单独的(但很小的)中-size) .isf 文件,可以轻松加载回来以进行进一步编辑,甚至将其转换(导出)为位图。

因此,一个好的方法是将每个图形保存在文件中(尽管这比简单地将其存储在 sqlite 数据库中更昂贵,更耗时),并将每个图形的路径以及数据库中的 id 保存起来以进行识别每次会议。
从可扩展性的角度来看,有什么进一步优化此方法的建议吗?

there's already a format that microsoft uses to save the strokes in, which is ISF - standing for Ink Serialized format that saves the Strokes collection in an .isf file.

However in this example each drawing is saved in a separate (but small-size) .isf file that can be easily loaded back for further editing or even converting (exporting) it to bitmap.

So a good method would be to save each drawing in files(even though this is a bit more expensive, time-wise, than simply storing it in a sqlite db)and save the path of each along with an id in the database to identify each session.
Any suggestion for further optimising this method from a scalability point of view?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文