【问题标题】:How to change the scaling algorithm that is applied to the icon in the window?如何更改应用于窗口中图标的缩放算法?
【发布时间】:2015-05-10 07:23:28
【问题描述】:

如果大图像以小于原始尺寸显示,则开始显示伪影“像素化”:

https://habrastorage.org/files/8a6/198/506/8a61985069cb4d0097540bf0d07f4a68.png

但这可以通过在XAML中指定对象的属性来解决,缩放算法质量更高:

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

然后,图像看起来很好:

https://habrastorage.org/files/819/863/48f/81986348f9ab454a9d6b676d88321d0a.png

问题。如何更改应用于窗口中图标的缩放算法? 通过 XAML 设置的图标(最后一行):

<Window x:Class="MyApp.AboutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/present"
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"><!-- Icon -->

标题栏中的图标如下所示:

_https://habrastorage.org/files/946/bb7/67b/946bb767b66042aba985a8e55a21b078.png(抱歉,我没有足够的声望来发布第三个链接)

属性 RenderOptions.BitmapScalingMode = "HighQuality" 应用于窗口,没有给出任何内容。

【问题讨论】:

标签: wpf xaml


【解决方案1】:

与客户区中的元素不同,标题栏中的元素不受 WPF 应用程序的直接控制。设置为 Window 的 Icon 属性的 png 文件将转换为标题栏(以及任务栏中的图标)中的图标图像,但正如您所见,转换似乎非常有限。

据我所知,不幸的是,在标题栏中设置良好显示的图标的唯一实用解决方案是创建或找到一个图标文件 (.ico),其中包含多个图像并使用它而不是仅仅使用 png 文件.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-26
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多