简体   繁体   English

C/C++ Allegro 程序导致 Windows 7 切换到 Aero Basic

[英]C/C++ Allegro program causes Windows 7 to switch to Aero Basic

I'm just trying out the allegro library, and here is the code which I've got so far:我只是在尝试 allegro 库,这是我目前得到的代码:

#include <allegro.h>

int main(int argc, char *argv[]) {
    allegro_init();  // initialize the allegro libraries
    install_keyboard(); // initialize keyboard functions
    
    set_color_depth(16); // set the color depth
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); // set up 640*480px window
    
    BITMAP *pic = NULL;
    pic = load_bitmap("C:/picture.bmp", NULL); // load the picture
    blit(pic, screen, 0, 0, 0, 0, 1000, 1000);

    readkey();
    destroy_bitmap(pic);
    return 0;
} 
END_OF_MAIN()

It works fine, but when I run it, while the program's window is open, Windows 7 changes the theme from Aero to Aero basic.它工作正常,但是当我运行它时,当程序的窗口打开时,Windows 7 将主题从 Aero 更改为 Aero basic。 If you aren't sure what I mean, this pops up (I got this from Google, which is why it says Vista rather than Windows 7):如果你不确定我的意思,会弹出这个(我从谷歌那里得到的,这就是为什么它说的是 Vista 而不是 Windows 7):

http://www.suitedcowboys.com/wp-content/uploads/2007/01/010607_0906_HelloVistai28.png
(source: suitedcowboys.com ) (来源: suitecowboys.com

  1. Why?为什么?
  2. How can I ensure that this doesn't happen?我怎样才能确保这不会发生?

Aero 需要将颜色设置为 32 位,但您将其设置为 16:

set_color_depth(16);

Unless you have good reason to use a specific color depth, do this:除非您有充分的理由使用特定的颜色深度,否则请执行以下操作:

int cd = desktop_color_depth();
if (cd < 15) cd = 32;
set_color_depth(cd);

While generally not a problem today, many older video cards only support one of 15/16 bit and one of 24/32 bit.虽然今天通常不是问题,但许多较旧的视频卡仅支持 15/16 位之一和 24/32 位之一。

If you need to use 8-bit color depth because you use a palette, then just use the GFX_GDI driver for maximum compatibility.如果您因为使用调色板而需要使用 8 位颜色深度,那么只需使用GFX_GDI驱动程序以获得最大兼容性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM