【问题标题】:How can I change app's thumbnail in the taskbar? SFML 2.4如何在任务栏中更改应用程序的缩略图? SFML 2.4
【发布时间】:2017-04-14 18:18:46
【问题描述】:

有人知道如何在 SFML 2.4 中更改或制作缩略图

【问题讨论】:

    标签: visual-c++ sfml


    【解决方案1】:

    可以在 SFML 文档页面上快速找到解决方案,here. sf::RenderWindow::setIcon() 方法可以给应用程序窗口一个图标,但是实际的图标必须由一个指向像素数组的指针来表示。

    这可以通过创建一个 .rc 头文件和一个包含像素数组的 .c 文件来实现。可以使用 GIMP 的“C 源图像转储”功能创建数组。

    例子:

    .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,
      "k\177h\377k\177h\377\377\377\377\0\377\377\377\0\377\377\377\0\204`\236\201"`
    
    //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 的任何位置。

    【讨论】:

      猜你喜欢
      • 2011-11-12
      • 2017-10-18
      • 1970-01-01
      • 2013-08-12
      • 2011-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      相关资源
      最近更新 更多