A
Andreas Romeyke
Hello,
In my script I want to blit PNG-images on the application screen via
the SDL-modules.
The problem is, that the alpha-channel of my PNG-images will be ignored
and drawed as black. My initilization looks like:
my $sdl_flags = SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF |
SDL_HWACCEL | SDL_ASYNCBLIT;
# define Application Window/Screen
my $app = SDL::App->new(
-title=> "Moving Balls",
-depth => 32, # color depth
-width => 800,
-height => 600,
-resizeable => 1,
-doublebuffer=>1,
-flags => $sdl_flags,
);
But the problem occurs also if I leave the flags and color depth empty.
I used the article on Ars Technica written by Andy Bakun
(http://arstechnica.com/guides/tweaks/games-perl.ars) and another onbe
written by Michael Schilli
(http://perlmeister.com/snapshots/200710/index.html) as base
documentation, because the core documentaion shipped with the
SDL-Module is, erm, unusable.
The blitting method of my sprite-objects looks like:
sub _draw {
my $self=shift;
my $app=shift;
my $image=shift;
my $pos = $self->get_position();
my $x = $pos->[0];
my $y = $pos->[1];
my $rect=$self->{rect};
my $old_rect = SDL::Rect->new(
-height => $rect->height,
-width => $rect->width,
-x => $rect->x,
-y => $rect->y,
);
$rect->x($pos->[0]);
$rect->y($pos->[1]);
$self->{rect}=$rect;
$app->fill($old_rect,
$bg_color);
$image->blit(0,$app,$rect);
$app->update($old_rect, $rect);
}
and the images are initialized in sprite-objects constructor by calling:
sub _init_image {
my $self=shift;
my $img = shift;
my $image = SDL::Surface->new(
-name=> $img,
-depth => 32,
);
return $image;
}
The blitting works as expected, but the pixels of transparency on
given PNG are drawed black.
$> file *.png
reports that:
flower.png: PNG image data, 48 x 48, 8-bit/color RGBA, non-interlaced
logo.png: PNG image data, 28 x 22, 8-bit/color RGBA, non-interlaced
smiley.png: PNG image data, 48 x 48, 8-bit/color RGBA, non-interlaced
thing.png: PNG image data, 48 x 48, 8-bit/color RGBA, non-interlaced
Please could you help me where I am wrong and what kind of
SDL-needs I have not used?
I am working under Debian Etch with SDL version:
libsdl-perl: 1.20.3dfsg-1
perl -e 'use SDL; print $SDL::VERSION;' reports "1.20.3".
Any hints?
Bye Andreas
In my script I want to blit PNG-images on the application screen via
the SDL-modules.
The problem is, that the alpha-channel of my PNG-images will be ignored
and drawed as black. My initilization looks like:
my $sdl_flags = SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF |
SDL_HWACCEL | SDL_ASYNCBLIT;
# define Application Window/Screen
my $app = SDL::App->new(
-title=> "Moving Balls",
-depth => 32, # color depth
-width => 800,
-height => 600,
-resizeable => 1,
-doublebuffer=>1,
-flags => $sdl_flags,
);
But the problem occurs also if I leave the flags and color depth empty.
I used the article on Ars Technica written by Andy Bakun
(http://arstechnica.com/guides/tweaks/games-perl.ars) and another onbe
written by Michael Schilli
(http://perlmeister.com/snapshots/200710/index.html) as base
documentation, because the core documentaion shipped with the
SDL-Module is, erm, unusable.
The blitting method of my sprite-objects looks like:
sub _draw {
my $self=shift;
my $app=shift;
my $image=shift;
my $pos = $self->get_position();
my $x = $pos->[0];
my $y = $pos->[1];
my $rect=$self->{rect};
my $old_rect = SDL::Rect->new(
-height => $rect->height,
-width => $rect->width,
-x => $rect->x,
-y => $rect->y,
);
$rect->x($pos->[0]);
$rect->y($pos->[1]);
$self->{rect}=$rect;
$app->fill($old_rect,
$bg_color);
$image->blit(0,$app,$rect);
$app->update($old_rect, $rect);
}
and the images are initialized in sprite-objects constructor by calling:
sub _init_image {
my $self=shift;
my $img = shift;
my $image = SDL::Surface->new(
-name=> $img,
-depth => 32,
);
return $image;
}
The blitting works as expected, but the pixels of transparency on
given PNG are drawed black.
$> file *.png
reports that:
flower.png: PNG image data, 48 x 48, 8-bit/color RGBA, non-interlaced
logo.png: PNG image data, 28 x 22, 8-bit/color RGBA, non-interlaced
smiley.png: PNG image data, 48 x 48, 8-bit/color RGBA, non-interlaced
thing.png: PNG image data, 48 x 48, 8-bit/color RGBA, non-interlaced
Please could you help me where I am wrong and what kind of
SDL-needs I have not used?
I am working under Debian Etch with SDL version:
libsdl-perl: 1.20.3dfsg-1
perl -e 'use SDL; print $SDL::VERSION;' reports "1.20.3".
Any hints?
Bye Andreas