• Products
  • Download
  • Purchase
  • Support
  • Company
Actipro Software company logo
Twitter Follow Actipro RSS Subscribe (RSS Feed)

The Actipro Blog

Tag Cloud

  • aero
  • blog
  • docking
  • editors
  • gauge
  • intelliprompt
  • navigation
  • propertygrid
  • ribbon
  • shared library
  • silverlight
  • syntaxeditor
  • themes
  • views
  • winforms
  • wpf

Latest Twitter News

November 21, 2011 at 11:14 AM
#WPF Studio 2011.2 is out now! Includes enhanced themes for native WPF conrtols and new SyntaxEditor features. http://t.co/uEMCaGPG

September 26, 2011 at 1:25 PM
If you'd like to see our #WPF / #Silverlight SyntaxEditor code editor control ported to Metro, provide feedback here: http://t.co/xXBNIDTi

September 15, 2011 at 8:31 PM
If you want to see SyntaxEditor eventually show up in Win8's #xaml UI, be sure to add your support to this MS thread: http://t.co/FBjz6TuC

August 15, 2011 at 1:47 PM
New SyntaxEditor IntelliPrompt parameter info feature docs/samples ready for the 2011.2 #WPF and #Silverlight releases. http://t.co/ezoYIjv

August 2, 2011 at 2:40 PM
First look at new automated IntelliPrompt parameter info coming to our C#/VB editor control in #WPF / #Silverlight http://t.co/CUz6O1T

Twitter Follow us on Twitter

Month List

  • 2012
    • February (3)
    • January (2)
  • 2011
    • December (2)
    • November (7)
    • October (2)
    • September (1)
    • August (5)
    • July (3)
    • June (6)
    • May (5)
    • April (8)
    • March (4)
    • February (5)
    • January (9)
  • 2010
    • December (9)
    • November (10)
    • October (4)
    • September (8)
    • August (12)
    • July (9)
    • June (7)
    • May (6)
    • April (7)
    • March (6)
    • February (6)
    • January (4)
  • 2009
    • December (2)
    • November (2)
    • October (12)
    • September (3)
    • August (11)
    • July (10)
    • June (6)
    • May (3)
    • April (7)
    • March (6)
    • February (8)
    • January (10)
  • 2008
    • December (10)
    • November (2)
    • October (3)
    • September (5)
    • August (5)
    • July (8)
    • June (4)
    • May (4)
    • April (10)
    • March (8)
    • February (1)
    • January (2)

Category List

  • RSS feed for ActiproActipro (289)
  • RSS feed for Blog SummaryBlog Summary (13)
  • RSS feed for GeneralGeneral (34)
  • RSS feed for In developmentIn development (150)
  • RSS feed for New featuresNew features (140)
  • RSS feed for New productNew product (30)
  • RSS feed for PromotionPromotion (2)
  • RSS feed for SilverlightSilverlight (71)
  • RSS feed for Tips and tricksTips and tricks (4)
  • RSS feed for Visual Studio 2008Visual Studio 2008 (2)
  • RSS feed for Windows FormsWindows Forms (20)
  • RSS feed for Windows VistaWindows Vista (10)
  • RSS feed for WPFWPF (235)
  • RSS feed for XAMLXAML (23)

About Us

Actipro Software is a leading provider of .NET user interface controls for the WPF, Silverlight, and WinForms frameworks, and is most well-known for their SyntaxEditor syntax-highlighting code editor control.

Please take some time to learn more about us and our product offerings.

How to prevent blurry images and lines in WPF

May 14, 2008 at 11:26 PM
by Bill Henning (Actipro)

In our latest maintenance release of WPF Studio's Shared Library v3.5.0427, we have added a simple decorator class called PixelSnapper.

The PixelSnapper decorator basically snaps the measurement of its child content to integer values, thereby helping to prevent blurry images and borders that may appear after it.

The Issue: Blurry Images and Lines in WPF

A problem in WPF is that images and borders can become very blurry when they are positioned on non-pixel boundaries.  This makes the application appear to be poorly designed to end users even though technically, the developer did nothing wrong.

How does this scenario occur?  Very easily in fact.  Say you have a standard WPF Menu at the top of your Window.  The text in the menu items may measure to 12.5 pixels high.  Then lets assume that we have 2 pixels of padding.  Now we have a Menu that is 16.5 pixels high and the problem has been introduced.

The control directly under the Menu will start at vertical location 16.5.  If this control is an Image, all the pixels in the image will appear blurry in the vertical direction since each lies half on one pixel and half on the one below it.  Even setting SnapsToDevicePixels to true does nothing to correct the issue.

A Visual Sample

In the screenshot below, we have a Border with a PixelSnapper surrounding it.  In the left sample, the PixelSnapper has snapped its contents to integers, the default behavior.  In the right sample, the PixelSnapper functionality has been disabled.

PixelSnapper

A demonstration of the differences between using and not using PixelSnapper

Note how the images, which are laid out after the Border, are blurry when not using PixelSnapper functionality due to the decimal size of the Border.

Effective Use of PixelSnapper

Where should you use PixelSnapper?  Generally, text elements like TextBlock controls are the only ones that will measure to decimal values.  So any time you have a text control in your UI and that control will affect the layout of other controls, we recommend you surround it with a PixelSnapper in your XAML.  This will keep everything in your UI on pixel boundaries, enabling images and lines to remain crisp and clear.

Several Options

PixelSnapper includes options for controlling how the separate horizontal and vertical measurements are rounded.   Options for each include None, Floor, Ceiling, and Round.

Tags: wpf, shared library
Filed under: Actipro, WPF, New features, XAML
Submit to DotNetKicks...
Permalink | Comments (4)

Related posts

Themes for WPF Part 1 - Native WPF Control Themes In prior blog posts, we’ve detailed some of the great new features coming to the WPF SyntaxEditor ...The future of WPF, Silverlight, and HTML5 - Are they dead?As I’m sure you are all aware, last week’s PDC 2010 conference set off a firestorm of tweets and new...WPF Studio integrates with and adds features to the official Microsoft WPF DataGridIn the most recent WPF Studio 2009.1 builds, we've integrated with and enhanced Microsoft's open sou...

Comments

August 17, 2008 at 08:36  

calciu sorin

give us an xaml sample. i can't find PixelSnapper in xaml. i have .net 3.5 SP1 installed.

calciu sorin

August 17, 2008 at 15:20  

Bill Henning (Actipro)

Hi, we include a full source sample of its usage in our WPF Studio evaluation's Sample Browser, under the Shared Library tab.  Also the WPF Studio documentation has help on how to use it.

Bill Henning (Actipro)

January 3, 2009 at 11:21  

Jason

Will this also fix the infamous "fuzzy-text" rendering problem?  By placing everything in a PixelSnapper, will everything just look right?  A lot of developers I know are skipping WPF altogether because clients are complaining about fuzzy text, and Microsoft doesn't seem to be able to come-up with a solution...

Jason

January 4, 2009 at 01:06  

Hi Jason,

It may help a little with some anti-aliasing of text depending on the layout scenario but it's not controlling the rendering of the text at all so it probably won't have an effect on what you're speaking of.

The PixelSnapper is meant to work with the WPF layout system to help ensure that controls with non-integer measurements do end up with integer-based measurements.  This keeps any other controls that have lines (like borders) as wel as icons, etc. clear and crisp.

Also the documentation and samples describe in more detail how to use it, but you basically wrap each control (like TextBlocks) that affect layout with a PixelSnapper.  It has made a huge clarity difference for images and borders, etc. in the applications we've made where we use it.

Bill Henning (Actipro)

Comments are closed
Copyright © 1999-2012 Actipro Software LLC. All rights reserved.
Home Actipro Software | Products | Download | Contact Us