如何更改应用程序在任务栏中的缩略图? SFML 2.4
How can I change app's thumbnail in the taskbar? SFML 2.4
有人知道如何在 SFML 2.4 中更改或制作 缩略图 吗?
可以在 SFML 文档页面上快速找到解决方案,here.
sf::RenderWindow::setIcon() 方法可以给应用程序 window 一个图标,但是实际的图标必须由指向像素数组的指针表示。
这可以通过创建一个 .rc 头文件和一个包含像素数组的 .c 文件来实现。可以使用 GIMP 的 "C-Source image dump" 功能创建数组。
示例:
.rc 文件:
//icon.rc
IDR_APP_ICON ICON "icon.ico"
GLUT_ICON ICON "icon.ico"
.c 文件:
//icon.c
/* GIMP RGBA C-Source image dump (icon.c) */
static const struct {
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
unsigned char pixel_data[32 * 32 * 4 + 1];
} gimp_image = {
32, 32, 4,
"k7h7k7h7777[=11=]777[=11=]777[=11=]4`61"`
//The array pixel array would continue here until }; closing the struct.
然后可以将生成的结构对象作为参数传递给 setIcon() 方法。
sf::RenderWindow::setIcon(gimp_image.width, gimp_image.height, gimp_image.pixel_data);
并且 icon.c 文件应包含在您的 main.cpp 文件中,或者您将图标设置为 RenderWindow 的任何位置。
有人知道如何在 SFML 2.4 中更改或制作 缩略图 吗?
可以在 SFML 文档页面上快速找到解决方案,here. sf::RenderWindow::setIcon() 方法可以给应用程序 window 一个图标,但是实际的图标必须由指向像素数组的指针表示。
这可以通过创建一个 .rc 头文件和一个包含像素数组的 .c 文件来实现。可以使用 GIMP 的 "C-Source image dump" 功能创建数组。
示例:
.rc 文件:
//icon.rc
IDR_APP_ICON ICON "icon.ico"
GLUT_ICON ICON "icon.ico"
.c 文件:
//icon.c
/* GIMP RGBA C-Source image dump (icon.c) */
static const struct {
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
unsigned char pixel_data[32 * 32 * 4 + 1];
} gimp_image = {
32, 32, 4,
"k7h7k7h7777[=11=]777[=11=]777[=11=]4`61"`
//The array pixel array would continue here until }; closing the struct.
然后可以将生成的结构对象作为参数传递给 setIcon() 方法。
sf::RenderWindow::setIcon(gimp_image.width, gimp_image.height, gimp_image.pixel_data);
并且 icon.c 文件应包含在您的 main.cpp 文件中,或者您将图标设置为 RenderWindow 的任何位置。