Browsed by
Month: November 2017

Text Encoding

Text Encoding

Many programmers get by without having to worry about text encodings at all. Most of the time text is just a sequence of chars, chars are just numbers that map to letters, numbers and symbols, and to save text to a file you just write out a sequence of chars, or let whatever API you are using handle the encode/decode. Unfortunately it’s not always that simple. It’s not until you start supporting multiple languages, or come across a file in…

Read More Read More

.NET Image DPI Scaling Problems

.NET Image DPI Scaling Problems

Today I noticed that the buttons in my Windows forms app were being scaled. As you can see from the image below there is a ghosting around the edges of the lines which isn’t in the original image. I eventually tracked this down to DPI scaling issues. I’m drawing the image using DrawImage: System.Windows.Forms.Graphics.DrawImage The graphics object has a correct DPI of 96, but the image DPI isĀ 95.91039. This incorrect DPI value is what is causing the scaling. e.Graphics.DpiY =…

Read More Read More