Skip to main content
GameDev.net gamedev.net
🔒 Locked

Fade Out - Allegro

Started by LamerGamer May 15, 2005 at 6:17 PM 2 replies 4.9k views
Original Post
LamerGamer
LamerGamer
How do I fade in and fade out a BITMAP blitted to the screen? One way is to have the images available in a file, and blit them sequentially, but I want to do this with a function in Allegro.
Edward_Sheets
Edward_Sheets
fade_in(const PALETTE p, int speed);
fade_out(int speed);

These functions only work properly for 8 bit color depth. They fade using the specified 256 color palette. If you're using higher than 8 bit color depth then you can certainly do the method you mentioned.

[edit]
You can also use Allegro's color blending functions to draw a translucent BITMAP over the BITMAP you want to fade.

Look in the Allegro manual for info on the use of these functions:

set_trans_blender(int r, int g, int b, int a);
draw_trans_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y);
draw_lit_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int color);

[Edited by - Edward_Sheets on May 15, 2005 6:33:54 PM]
prh99
prh99
Quote:
Original post by LamerGamer
How do I fade in and fade out a BITMAP blitted to the screen? One way is to have the images available in a file, and blit them sequentially, but I want to do this with a function in Allegro.


The Allegro[http://www.allegro.cc] has some fade code[http://www.allegro.cc/resource/code/fade.php] in their code gallery.
It basicly implements Edward_Sheets suggestion.
Patrick
PaulCesar
PaulCesar
Like poster above said, you are probably going to want to render an alpha blended black image on top, real easy, write a simple function around that if you want. Its not difficult at all (a 5-10min task)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.