Wpf - 调整图标大小,模糊图像数量
我尝试首先从可执行文件中提取图标,将其保存到特定文件并将其显示在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.