Sign in to follow this  

Fade Out - Allegro

This topic is 4594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites

This topic is 4594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this