简体   繁体   中英

how can I save a content of a canvas drawn by a user?

I'm having the following problem:

I'm trying to save a content of an application. The content are drawn on a canvas via users. Example:

a user might click on a button to draw an ellipse, etc.

after clicking the button, the drawing will be displayed on a canvas.

I want to save the content drawn by the user on the canvas. Anyone could give me a hint. Is it good if I use the serialization and deserialization?

the code is written in C# using visual studio 2012, windows 8 app

There are several ways of solving this:

  1. Save each action of the user - just like an undo/redo stack. Very flexible but files can get very big. In this case you'd serialize a stack of commands. To load the command would have to be replayed.

  2. Save the logical construction of the drawing - just like Html or SVG. No undo/redo support but smaller files. In this case you'd serialize a document model.

  3. Save each resulting bitmap after an action - easier to implement than 1. and 2. but harder to support editing of elements. No serialization of .NET objects just a lot of bitmaps.

Each approach has its advantages and disadvantages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM