2010-02-18 130 views

回答

1

你需要做以下的事情,使透明像素:

  • 呼叫set_color_depth(32)调用set_gfx_mode()

  • 之前调用set_gfx_mode()

  • 使用masked_blit()draw_sprite()绘制后加载图片图片。

如果你这样做,所有的“魔术粉红色”像素(100%红色,0%绿色,100%蓝色)将被视为透明。

BITMAP *bmp; 
allegro_init(); 
set_color_depth(32); 
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); 
clear_to_color(screen, makecol(0,0,0)); 

// once the video mode has been set, it is safe to create/load images. 
// this bitmap will be 640x480 with pure pink. 
bmp = create_bitmap(640, 480); 
clear_to_color(bmp, makecol(255,0,255)); 
rectfill(bmp, 100,100, 200,200, makecol(255,255,255)); 

draw_sprite(screen, bmp, 0, 0); 

// or 
// masked_blit(bmp, screen, 0,0, 0,0, 640,480);