Re: Simple alpha fade

[email protected] (Guillaume Cottenceau)
Newsgroups perl.sdl.devel
Message-ID <[email protected]>
"Karl Dane" <karl 'at' rince.net> writes:

> Hi all,
> 
> I'm trying to write a simple alpha cross-fade app: basically a slideshow
> that fades one image in and the other out. However, can not get alpha fades
> to work.
> 
> I'm very new to SDL, so please don't laugh at my code! But I'd be very
> grateful if anyone could point out where I'm going wrong. The code snippet
> below results in the image being displayed without any change.
> 
> Many thanks,
> 
> Karl Dane
> 
> 
> #!/usr/bin/perl
> 
> use warnings;
> use SDL::App;
> 
> our $app = SDL::App->new(
>     -width => 640,
>     -height => 480,
>     -depth => 24,
>     -fullscreen => 0,
>     );
> 
> for ($i=260; $i >=0; $i-=1) {
>         print "$i\n";
> 
>         my $img1 = SDL::Surface->new( -name => "./img1.png" );
> 
>         $img1->display_format();
> 
>         $img1->set_alpha(SDL_SRCALPHA, $i);

/usr/include/SDL/SDL_video.h says for this method:

 * The 'alpha' parameter is ignored for surfaces that have an alpha channel.

One solution might be to remove the alpha by converting the
surface or creating a new surface with proper properties then
blitting the original surface to it.
 
>         $img1->blit( SDL::Rect->new(
>             -width => 640, -height => 480), $app, undef);
> 
>         $app->sync;
>         }

-- 
Guillaume Cottenceau
Create your personal SMS or WAP Service - visit http://mobilefriends.ch/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.