如何在wxWIdgets中显示清晰的图标 [英] How to display sharp icons in wxWIdgets
问题描述
我正在使用 wxWidgets
为我的应用显示图标
。我使用以下代码并使用 .ico文件
与 128 * 128
维度。但显示的图标不清晰。我应该如何使它锐利?
我使用以下代码:
I am displaying icon
for my app using wxWidgets
. I am using following code and using a .ico file
with 128*128
dimensions. but the icon displayed is not sharp. How should I make it sharp?
I am using following code:
bool ImageFileToIcon(wxString &path, wxIcon &icon)
{
wxImage image;
if (!image.LoadFile(path))
{
wxLogError(wxT("Couldn't load image from '%s'."), path.c_str());
return false;
}
icon.CopyFromBitmap(image);
return true;
}
someFunction()
{
wxIcon tempIcon;
ImageFileToIcon(IconImagePath, tempIcon);
SetIcon(tempIcon);
}
我应该怎么做,我应该使用尺寸较小的.ico文件还是做我需要改变代码吗?有没有.ico文件包含所有尺寸,我们必须根据屏幕分辨率进行调整。如何在wxWidgets中执行此操作?
what should I do, should I use .ico file with less dimension or do I need to change code? Is there anything like .ico files contain all dimensions and we have to adjust it according to screen resolution. How to do that in wxWidgets?
推荐答案
wxIcon
在Windows下是特殊的因为它可以包含不同分辨率下相同图片的多个表示,而 wxImage
只包含一个图像。因此,当您将 .ico
文件加载到 wxImage
时,除了其中一个图标外,您将失去所有图标。
wxIcon
under Windows is special as it can contain several representations of the same picture at different resolutions, while wxImage
only contains a single image. So when you load an .ico
file into wxImage
you lose all but one of the icons.
相反,你应该使用专门的 wxIconBundle 一个>类而不是。它还可以使你的代码更简单,基本上你可以
Instead, you should use the specialized wxIconBundle class instead. It will also make your code much simpler, basically you just can
SetIcon(wxIconBundle(IconImagePath));
这篇关于如何在wxWIdgets中显示清晰的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!