MULTIMEDIA

Vectors in WPF

7/25/2010 5:11:12 PM
I_sect12_d1e724.html
Most graphics nowadays are pixel-based. Every point in the graphic is represented by one pixel. This is a really good solution for most scenarios, including digital photography (where you really want to maintain every single piece of information the camera is "seeing"), but there are shortcomings too. For instance, have a look at Figure 1, where you see some simple text created in Microsoft Paint. This text is pixel-based. In Figure 2, you see the same text, but this time the image width and height have been enlarged. Do you see the stairway effect that appears along the edge of each letter? So, when you make a pixel-based image larger, you lose quality.

Figure 1. The word "Silverlight" displayed by Paint, a pixel based tool


Figure 2. Increased in size, text in a pixel-based tool displays "stair step" edges


That's obvious, of course. Imagine that a 100 x 100 pixel image is resized to 200 x 200 pixels. Instead of 10,000 pixels, we now have 40,000 pixels. So, where we had a 1 x 1 pixel in the original image, we now have 2 x 2 pixels. Paint is using a very simple algorithm to resize images: if the graphic becomes larger, just clone the pixels. This then creates the stairway effect.

NOTE

Professional software such as Adobe Photoshop comes with several sophisticated algorithms to make the quality loss less severe when resizing images (especially when making them smaller); however, there still is a notable effect when increasing an image's dimensions.

Vectors

There is an alternative approach: vector-based images. In a vector-based image, every element is represented as a geometrical object—for example, a line, a circle, a polygon, or a curve, just to name a few. The main advantage is that there is no quality loss when resizing an image: a circle changes its diameter, but that's all. There is no stairway effect, since a circle is still a circle and not, as with a pixel image, a set of pixels ordered in a circular fashion.

Obviously, not every image can be represented as vectors. Think again of photos—it is theoretically possible to try to find geometrical elements and patterns in a portrait or a landscape (there are even algorithms for that!), but it is virtually impossible to create an exact representation of a photo by just using vectors. However, in computing there are several areas where vectors make real sense. One such area is fonts. See Figure 3 for a typical Windows font (coincidentally the same font used in figures Figure 1 and Figure 2). Most fonts are vectors, so there is no quality difference whether you use them in 8pt, 10pt, 12pt, or 100pt. If you type a letter in a word processor and then change the font size to something really large, you still get smooth edges. Once you paste text into pixel-based imaging software such as Paint, you lose the vector information and are back to pixels.

Figure 3. A vector-based Windows font


Another area prone for vector representation is the user interface (UI). The standardized UIs of an application are, most of the time, vector-compatible. Most of them need to be resizable, so the content can remain intact if the user changes the width or the height of a window. However, in reality, very few UIs have been based on vectors.

Other  
 
Top 10
Installing the Exchange Server 2010 prerequisites
Algorithms for Compiler Design:
Business Intelligence in SharePoint 2010 with Business Connectivity Services : Consuming External Content Types (part 3) - Business Connectivity Services Web Parts
Windows Azure : Static reference data (part 2) - Performance disadvantages of a chatty interface & Caching static data
The Membership Data Store
Optimizing an Exchange Server 2010 Environment - Analyzing and Monitoring Core Elements
Algorithms for Compiler Design: IMPLEMENTATION in Bottom-up Parsing
Collaborating Within an Exchange Server Environment Using Microsoft Office SharePoint Server 2007 : Customizing and Developing MOSS Sites
Microsoft Malicious Software Removal Tool
Modifying Display Appearance and Video Settings
Most View
BizTalk 2006 : Building a Resequencing Aggregator
Windows Server 2008 : Transport-Level Security - Using IPSec Encryption with Windows Server 2008 R2
Windows 7 : Understanding User Account Control and Its Impact on Performance
Algorithms for Compiler Design: THE LR PARSER
Port-Binding Shellcode
Building Android Apps: Web SQL Database (part 4) - Deleting Rows
Silverlight : Play a Video
Windows Phone 7 Development : Understanding Trial and Full Modes (part 1) - Using the IsTrial Method
iPhone Application Development : Understanding Interface Builder
Server 2008 : Hardening Server Security
Managing Local User Accounts and Groups in Vista
Using Windows Phone 7 Technologies : Retrieving Accelerometer Data (part 1)
iPhone Application Development : Creating User Interfaces
Programming with DirectX : Textures in Direct3D 10 (part 1) - Textures Coordinates
Installing SQL Server 2008
Defensive Database Programming with SQL Server: The Ticket-Tracking System (part 2) - Removing the performance hit of ON UPDATE CASCADE
Android’s Securable IPC Mechanisms
Windows 7 :Navigating Your Computer with the Address Bar (part 1) - Accessing Locations on Your Computer
Advanced ASP.NET : Component-Based Programming - The ObjectDataSource
Windows 7 : Using Advanced Security Options (part 2) - Configuring Windows Defender