96 DPI

Probably every programmer on this world has his image collection to use in toolbars. It is usually collected over years and gets reused quite a lot. I have collection of my own and it seemed like a natural solution to use it in WPF also.

As I am big fan of high DPI setting and I got used to expect little bit of blurriness in my toolbar as unfortunate result of scaling bitmap from 16×16 (at 96 DPI) to 20×20 (at 120 DPI). However, nothing could prepare me for amount of blur that WPF brought.

Quick search discovered a clue and look on my system confirmed it. Almost all images I had were 72 DPI. That meant WPF did scaling even on systems with “normal” DPI settings.

Scott gave easy fix in form of PNGOUT tool. I tried it out and checked results in Paint.NET. Unfortunately, instead of promised 96 DPI, I got 120 DPI images. Issue here is that PNGOUT uses DPI settings as defined on system. High-DPI setting on my system meant that PNGOUT will not work correctly without configuration change (and required logoff/logon).

Quite annoyed I made quick program in C# that just loads whatever image you give it on command line (e.g. “dpi96.exe *.png”) and changes it’s DPI setting. This finally worked as promised. This small utility is available for your use also.

P.S. Yes, I know that I should prepare separate bitmaps for all common DPI settings. I am lazy and artistically-challenged.

P.P.S. This utility was made in less than 10 minutes. Do not expect extra-quality code (or any exception handling).

One thought to “96 DPI”

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.