WPF: Strange image stretching in Buttons

后端 未结 3 1854
没有蜡笔的小新
没有蜡笔的小新 2021-01-23 03:51

I have multiple buttons, each having a 32x32 pixels PNG image. The strange thing is, that both buttons show different sizes (Yes, I triple checked that icons are really 32x32!).

3条回答
  •  迷失自我
    2021-01-23 04:13

    If you have set Stretch="None" for the Image, and it still looks larger/smaller/blurry, then it's probably because of the DPI mismatch.

    For example, PNG files store DPI. Windows has a particular DPI. Check your system DPI and check the PNG DPI.

    In Photoshop you can go to Image -> Image Size and it will display the dots/inch box. You can also use it to change the DPI. Make sure you disable Resample Image checkbox so that you only alter the DPI. You need to use the Save for Web dialog for saving that change because the normal Save As won't save that information.

    enter image description here

    In my case, I had a PNG file with size of 24x24, and a DPI 72.009 and my system is at the default DPI. The picture looked larger and blurrier, now it's fine after adjusting the PNG DPI from 72.009 to 72 with Photoshop and using the Save for Web.

提交回复
热议问题