This article shows a real-world usage of Tablet PC InkPicutre control and ink. The attached file is a Visual Studio 2003 project, which allows you to load an image file, write on the image using ink and save the ink. It also allows you to load and view the saved ink on the image.
The Application
The application is a simple Widnows Application with two Button controls, a CheckBox control, and an InkPicture control. ( See Figure 1).
Figure 1. InkPicture test application.
Loading Image
The Load Image button allows you to load in Image using the following code:
As you can see from this code, I simply set the file name selected from the Open File Dialog as Image property of InkPicture control, which views the image. After that I write something on InkPicuture using the pen. See Figure 2.
Figure 2. InkPicture control with an image.
Saving Image
The Save Ink button click saves the image. The following code saves the ink:
private
The Save method also calls Save As dialog where you can specify the name of the ink file (.isf). See Figure 3.
Figure 3. Save Ink dialog.
Loading Ink
The following code is Show Ink Overlay CheckBox click which calls an Open File Dialog where you can select a saved ink and display it. See Figure 4.
As you can see from this code, I create an Ink control and call its Load method, which takes a byte stream, which I create from the ink file. The GetInkImage method takes an Ink object and converts into an Image object. You can set the Image property of InkPicture control to display the image.
Figure 4. Loading an image.
See the attached project for more details.
Summary
In this article, I discussed the usage of Tablet PC ink and InkPicture control in real world applications. You can extend this application by allowing the users to select the color and width of the ink and select and delete the ink from the InkPicture control.