M
M
Michael2015-04-11 16:52:08
WPF
Michael, 2015-04-11 16:52:08

How to change scaling algorithm to icon in window (WPF)?

If a large image is displayed at a size smaller than the original, then "pixelation" artifacts begin to appear:
8a61985069cb4d0097540bf0d07f4a68.png
But this can be solved by specifying an attribute of the object, in XAML, a scaling algorithm with a higher quality:

<Image Height="50" Width="50" 
             Source="Resources/logo.png" 
             RenderOptions.BitmapScalingMode="HighQuality" />

Then the image looks normal
81986348f9ab454a9d6b676d88321d0a.pngQuestion. How to change the scaling algorithm that is applied to the icon in the window?
The icon is set via XAML (last line):
<Window x:Class="MyApp.AboutWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:res="clr-namespace:MyApp.Properties"
        Title="{x:Static res:Resources.AboutWindowTitle}" 
        Height="450" Width="300" 
        ResizeMode="NoResize" 
        WindowStartupLocation="CenterOwner"
        Icon="Resources/info.png">
...

And the icon in the title bar of the window looks like this.
946bb767b66042aba985a8e55a21b078.png
The attribute RenderOptions.BitmapScalingMode="HighQuality" applied to the window does nothing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Papin, 2015-04-11
@gmikhail94

In general, any scaling leads to a loss of quality. No smoothing of a situation does not rescue.
As for the icon in the window title, it is not rendered by WPF, as far as I know, but by dwm itself, so nothing can be solved with markup. Unless you make a custom header.
It is best to draw the icon size to size. Or several icons for different dpi. At least that's how we deal with pictures in our projects.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question