2010-02-18 128 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);