Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET 4.5
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Amazon Web Services
Analysis Services
Android
Architecture
Arduino
ASP .NET Web API
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
BDD
Big Data
Bing
BizTalk
Book Excerpts
Build and Deploy
Business Intelligence
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE Framework Info - non Technical
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Debugger
Design Patterns
Development Process
Display Technologies
Distributed Computing
Document Database
DotNetNuke
DSL
Dynamic Languages
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
HTML 5
Internet Explorer 8.0
Interviews
IOS
iPhone
Iron Ruby
Java
Java Script
JavaScript
jQuery
JSON
Lightswitch
LINQ
Linux
LUA
Mac OS X
MDX
Messaging
Metro
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
MVVM
MySQL
Network
NHibernate
node.js
NOSQL
Nuget
Object Oriented Development
Objective C
Odata
OLAP
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
PHP
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Prolog
Python
Q&A
Rails
Rake
Razor
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Scheme
Search
Security
Services
SharePoint
SignalR
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server 2012
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
TFS
Tips
TypeScript
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 11
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio 2011
Visual Studio 2012
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WebMatrix
WF
Whitepapers
Windows 7
Windows 8
Windows Azure
Windows Live
Windows Phone 7
Windows Phone SDK
Windows Server
Windows Vista
WinForms
WinRT
Workflow
WPF
XAML
Xiine Documentation
XML
XNA
XSLT



SSWUG


XAMALOT
 


CODE Training

Reader rating:
Click here to read 1 comment about this article.
Article source: CoDe (2005 - Vol. 3 - Issue 1 - Tablet PC and Mobile PC)


Article Pages:  1  2 3 - Next >


Scaling and Hit-Testing in Ink Applications

In addition to recognition of text and similar capabilities, Ink can also be used for annotation and markup of images. Medical and insurance applications are typical examples in which allowing users to mark up images can be a valuable form of input.

Ink is a versatile input medium.

It’s common in imaging applications for images to be displayed at different sizes. If such images are annotated with Ink, it’s necessary for the Ink to be scaled to the current size of the image. Developers just starting with the Tablet PC often find that this is trickier than they thought. This article covers the basics of scaling Ink, including a quick introduction to the concept of transforms, which are one of the underlying mechanisms for scaling Ink, and one about which most developers have never had to worry.

"
Annotation applications also need to know whether Ink has been entered into a particular area of a drawing. For example, an insurance application might annotate a picture of a car to indicate damaged spots.
"

Annotation applications also need to know whether Ink has been entered into a particular area of a drawing. For example, an insurance application might annotate a picture of a car to indicate damaged places. The application might then need to detect whether an annotation had been added that indicated damage only to the door of the vehicle.

This capability is called “hit testing.” The basic technique to do hit testing for Ink is pretty easy. It uses a method of the Ink object, which checks to see if Ink is within or around a given rectangle. But given that the image may be scaled to different sizes and resolutions, the concept of scaling also applies to hit testing, because the rectangle for hit testing must be sized and positioned properly for the currently displayed image.

Because these topics are related, this article also looks at the basics of hit testing, and demonstrates how to scale hit tests to various image sizes.

Logistical notes

The examples in this article are in Visual Basic but can be translated to C# easily. The classes used are the .NET wrapper classes for Ink, so all examples must be done on the .NET Framework.

The step-by-step construction of the examples below assumes that you have a Tablet PC already set up with Visual Studio 2003, and that the standard Ink controls (InkPicture and InkEdit) are present in the Visual Studio toolbox.

These examples should work fine with Visual Studio 2005.

Basics of Scaling

Scaling Ink is an issue under two typical scenarios. First, if an image dynamically becomes larger or smaller in an application, the Ink that overlays the image must scale as well. Second, if Ink is stored and later retrieved, it must be scaled to the present size of the image.

To see the scaling problem, let’s start the example application. In Visual Studio, create a new Windows Application, and name it ScaleAndHitTestSample. When the application comes up, add a new form to the project named InkScaleForm. Drag the corner of the form to make it about twice as wide and twice as high as it appeared by default.

Drag an InkPicture control to the form, and name the control VehicleImage. Set the Image property for the InkPicture to some appropriate bitmapped image. In the example application that you can download for the article (http://dotnetmasters.com/downloads/CodeMagArticle.zip), I have a yellow car, as in Figure 1. Set the Anchor property for the InkPicture to anchor the image to all four sides of the form.

Click for a larger version of this image.

Figure 1: Before scaling is applied to the Ink, the Ink does not scale when the size of the image changes.

The InkPicture control inherits from the PictureBox control, and has a property derived from PictureBox called SizeMode. By default, this is set to Normal, which means that the image displays from the top left of the control, and that there will be no sizing of the image to accommodate the control’s size. If the image is larger than the control, the image will be clipped.

&

By: Billy Hollis

Billy Hollis is an author and consultant specializing in .NET technologies. He has written several books and was coauthor of the first book ever published on Visual Basic .NET. He speaks at major conferences worldwide, including TechEd, VSLive, DevConnections, and Microsoft’s Patterns and Practices Architect Summit events. He is available for consulting and training on .NET architecture, smart client systems, Tablet PC, and WPF.

bhollis@dotnetmasters.com

Fast Facts

Applications for the Tablet PC that annotate images usually need to accommodate changing image size. That requires scaling the ink data to the size of the image. The ink renderer takes a Matrix object that contains the scaling information.



Article Pages:  1  2 3 - Next Page: 'Basics of Scaling (con't)' >>

Page 1: Scaling and Hit-Testing in Ink Applications
Page 2: Basics of Scaling (con't)
Page 3: Hit-testing

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
4.5 out of 5

15 people have rated this article.

TOWER 48

      LearnNow

 

LearnNow