共用方式為


Ink Data

Ink Data

Description of ink data for the Tablet PC.

After the ink is collected, applications can manage, manipulate, and transfer that data to other media. The actions of selecting, copying, moving, saving, viewing, and altering of the ink take place on the Ink object and its contained members, such as the Strokes collection and Stroke object.

Ink, Strokes, and Packets

An Ink object is the fundamental data type that manages, manipulates, and stores the input collected from the InkCollector object. An Ink object contains one or more Stroke objects and common methods and properties to manage and manipulate those strokes. A stroke is defined as the set of data that is captured in a single pen-down, pen-move, and pen-up sequence. The stroke data contains a collection of packets. A packet is the set of data that the tablet device sends at each sample point. This data contains information such as coordinates, pen pressure, pen angle, and anything else that the hardware can transmit. The PacketDescription property described the packets that a Tablet generates.

Strokes

You can obtain a snapshot of the strokes in an Ink object by getting the Ink object's Strokes property. The Strokes property is a collection of references to the strokes in the Ink object at the time the Strokes property is read. If strokes are subsequently added to or deleted from the Ink object, a previously obtained Strokes collection is not updated. Furthermore, the Strokes property is a value and, like any value, goes out of scope unless it is assigned to a variable.

To keep a Strokes property synchronized with an Ink object, wrap it in an event handler for the StrokesAdded and StrokesAdded events. The handler should obtain a new copy of the Strokes property when either event is fired. Be careful not to add the event handler to a Strokes collection that is out of scope before the event is fired.

A Stroke object can contain a single point. Therefore, the GetPoints method of the Stroke object can return an array with a single element.

PacketDescription Property

The PacketDescription property defines the set of information that the application gets from a Tablet PC device. The information typically includes coordinates, but it can include much more detailed information (depending on what the Tablet PC digitizer can produce) such as pen pressure or pen angle. By setting packet descriptions on the ink collector object before any ink is collected, you have full control over which of the Tablet PC devices properties you want to use.

Extended Properties

Extended properties provide a mechanism for attaching application-defined data to Ink and other objects. For more information about extended properties, see the ExtendedProperties collection.

Ink Rendering

The Renderer object is responsible for rendering Ink. Given an appropriate drawing context, the Renderer object can map ink space coordinates to pixels, apply viewing transforms, and display Ink on screens and printers. Draw and DrawStroke are the primary methods for rendering ink. For more information about displaying ink in a window, see Renderer object.

Cusps

A stroke normally begins when the pen is lowered to the drawing surface and ends when the pen is raised. Within a stroke, the peaks, angles, and radical changes of directions are called cusps. The endpoints of a stroke are also considered cusps. For example, the capital letter "L" has three cusps, one in the middle and one at each end.

As a stroke is entered, it is normally smoothed and rendered using a Bezier (or polyline) curve. Bezier curves may turn cusps into small loops. For example, the peak of the cursive letter "i" might be smoothed to resemble the cursive "e". To prevent this, Microsoft® renderers have a "pre-Bezier" phase that handles the cusps differently.

Cusps can also be used to subdivide Stroke objects into erasable units. For example, selecting the vertical side of a capital "L" could indicate erasing just that side. The part of the stroke to be erased would be the part between two cusps.