Imagescaling在功能区看起来很糟糕

van*_*nos 5 wpf ribbon image render antialiasing

我正在基于MS RibbonControlsLibrary(3.5.41019.1)以编程方式填充功能区(WPF ).所有图像(最明显的大图像)看起来非常糟糕和"像素":

2 Ribbon的屏幕截图

  • 顶部屏幕截图是从"pixly"丝带(图像缩放看坏)
  • 底部屏幕截图是从相同的区域中的窗口基于与相同的源图像的WinForms拍摄(图像缩放好看)
  • 所有图像都以32位PNG 48x48保存

我试图将BitmapScalingMode设置为" HighQuality "而没有任何影响,源代码:

BitmapImage img = new BitmapImage();
try
{
    Uri uri = new Uri("pack://application:,,,/UIMainWindow;component/Resources/" + iPictureName);                
    img.BeginInit();
    img.SetValue(BitmapImage.CacheOptionProperty, BitmapCacheOption.OnLoad);
    RenderOptions.SetBitmapScalingMode(img, BitmapScalingMode.HighQuality);
    img.UriSource = uri;
    img.EndInit();
    img.Freeze();
}
catch (Exception ex)
{
    throw new Exception("Creation of image failed: " + ex.Message, ex);
}
Run Code Online (Sandbox Code Playgroud)

问题 为什么图像的缩放看起来很糟糕?我该如何解决这个问题?

All*_*hua 0

尝试使用矢量图形。有很多工具可以用来生成此类图像的 xaml 等效项,您可以看看这篇文章,它可能会有所帮助。