Wpf - 调整图标大小,模糊图像数量

发布于 2024-10-06 07:29:07 字数 1043 浏览 7 评论 0原文

我尝试首先从可执行文件中提取图标,将其保存到特定文件并将其显示在 WPF 窗口中。

32x32 的质量非常好,但当我尝试将其调整到更大时,它开始变得模糊。

来自我的应用程序的图像,100x100 图像旁边的 32x32 图像:
图片 http://img821.imageshack.us/img821/8967/imageresizemine.jpg

正如您所看到的,它非常模糊,相比之下,这是来自不同应用程序的图像,该应用程序也从可执行文件(甚至更大)获取图标,因此这显然是可能的。
图片 http://img714.imageshack.us/img714/1842/imageresizeother.jpg

关于此问题有几个主题(或至少相关),但我无法弄清楚问题到底是什么。

我正在使用此代码显示图像。

<Image Height="100" 
       Width="100" 
       HorizontalAlignment="Left" 
       Source="{Binding ImagePath}" 
       RenderOptions.BitmapScalingMode="HighQuality"/>

我认为问题在于图像的显示,而不是最初如何保存它,但以防万一......我正在使用此代码保存图像。

Bitmap image = Icon.ExtractAssociatedIcon(FilePath).ToBitmap();   
image.Save(imagePath, System.Drawing.Imaging.ImageFormat.Png);

I'm attempting to first pull a icon from an executable file, save it to a particular file and display that in a WPF window.

The quality is perfectly fine at 32x32 but when I try to resize it to being larger, it starts to get blurry.

Image from my application, 32x32 image beside 100x100 image:
Image http://img821.imageshack.us/img821/8967/imageresizemine.jpg

As you can see, it's quite blurry, by comparison here's an image from a different application which is getting the icon from executable also (and even larger) so it's obviously possible.
Image http://img714.imageshack.us/img714/1842/imageresizeother.jpg

There are several topics on this (or at least related) but I'm not managed to figure out what exactly the problem is.

I'm displaying the image using this code.

<Image Height="100" 
       Width="100" 
       HorizontalAlignment="Left" 
       Source="{Binding ImagePath}" 
       RenderOptions.BitmapScalingMode="HighQuality"/>

I assume the issue is with the displaying of the image rather then how it's saved initially but just in case...I'm saving the image using this code.

Bitmap image = Icon.ExtractAssociatedIcon(FilePath).ToBitmap();   
image.Save(imagePath, System.Drawing.Imaging.ImageFormat.Png);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生来就爱笑 2024-10-13 07:29:07

ExtractAssociatedIcon 仅获取 32x32 图标,即使应用程序的资源有其他图标也是如此。您可能必须一路 p/invoke 某些东西才能获取 exe 中的任何其他图标。

ExtractAssociatedIcon only gets the 32x32 icon, even if the app's resources have others. You'll probably have to go all the way to p/invoke something to get any of the other icons in an exe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文