Welcome to irritatedVowel.com Sign in | Help

POKE 53280,0: Pete Brown's Blog

Silverlight, WPF, Woodworking, .NET Programming, CNC, Nature, and other topics.

Pete Brown writes on a number of topics including Silverlight, WPF, .NET, woodworking and working as a consultant in the DC area. On most forums, Pete goes by the name Psychlist1972. Pete has worked at Applied Information Sciences (AIS) since 1996 where he currently performs as a lead architect and project manager.

Subscribe to my feed

Add to Technorati Favorites
Applied Information Sciences - My Employer



World Domination

who's online

Networks


View Pete Brown's profile on LinkedIn

AddThis Social Bookmark Button
DPI Matters in Blend

A recent post on Silverlight.net led me to revisit something I haven't played with in quite some time: DPI.

If you wonder why you sometimes drag those pngs or other images onto the design surface in blend, and they come out the wrong size, there are several things to consider:

  1. Do I have the image inside a grid cell that is constraining or stretching it?
  2. Did I use the mouse to set the size of the image on the design surface instead of just dropping it in place?
  3. Did I set the DPI properly when I saved the image?

The last one can be the most vexing, as without proper tools, you can't tell the DPI of an image just by looking at it. I thought you could tell via the properties tab in Vista, but it turns out that isn't the case.

In WPF, Silverlight and Blend, 1 pixel is approximately 1/96th of an inch. Therefore, for dropped images to look correct, you need to save them with a DPI of 96. Here is a screenshot showing the three images. All three have pixel dimensions of 150x196, but all three were saved in PhotoShop using different DPI settings.

image

The 72dpi one looks a little blurry, as it has been stretched. The 96dpi one is correct. The 300dpi one (used to be a common print image size) just looks way too small.

Note that due to 1/96 being an approximation, the center image comes out to 149.981 pixels wide, instead of 150px. Annoying, but not show-stopping.

If you want to set the DPI in Photoshop, you do this via the Image Size dialog. You'll want to change the image DPI to 96 and then change the dimensions to what you want them to be..

image

Of course, you can go into Blend and set the values to the correct pixel dimensions after the fact, but setting DPI correctly will help potentially eliminate an extra step for the interactive designer.

Hope this helps clear up this question.

  Add to Technorati Favorites
Posted: Wednesday, March 12, 2008 11:24 PM by Pete.Brown

Comments

Younes said:

Nice post! DPI has always had some mystery to it. Thanks
# March 13, 2008 6:44 AM

DPI Matters in Blend said:

A recent # March 13, 2008 12:11 PM

Ben Hayat said:

I think I saw a post from someone complaining why their image is not clear at runtime (blur). I think this is the problem. Thanks for the info. ..Ben
# March 13, 2008 7:09 PM

Peter Bromberg said:

Thanks! I'm edging my way into Silverlight now that 2.0 is out and your posts have been extremely helpful! Keep sticking the links on my IttyUrl.net site!
# March 13, 2008 7:10 PM

Community Blogs said:

Pete Brown on DPI in Blend, Joe Stagner on SL and Security, Laurence Moroney on DeepZoom in C#, SL Developer
# March 13, 2008 8:15 PM

Community Blogs said:

Pete Brown on DPI in Blend, Joe Stagner on SL and Security, Laurence Moroney on DeepZoom in C#, SL Developer
# March 13, 2008 8:47 PM

Scott Conrad said:

Hello, to futher lessen the barrier to entry of this post, what would you recommend that megapixel shots should be shot at? I have noticed that my 5 megapixel shots look quite clear (in my experience), should I be shooting at a larger megapixel or is 5 fine? -Scott Conrad
# March 14, 2008 12:26 AM

Christopher Steen said:

ASP.NET Attack and Defense: Securing ASP.NET 2.0 Apps [Via: Keith Brown ] WPF A WPF File Selection...
# March 14, 2008 9:13 AM

Pete.Brown said:

@Scott

For typical web graphics (not Seadragon/Deep Zoom stuff), most any current digital camera will get you an image of more than large enough size.

More megapixels primarily providers you with the ability to crop to smaller areas of the image while retaining the pixel size you need (it's almost like free zooming)

Pete

# March 14, 2008 11:55 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Enter the text you see in the image:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS