On 2011-12-05, at 4:51 PM, Alex wrote:
> Dear all!
>
> I would like to draw a menu like the one in the game TRAUMA (cf.
> http://images.netzwelt.de/thumb/27/2011/4322/32288-test-trauma.jpg && no, I
> don't want to code a game).
>
> So, it's basically 4 picture slides in a row. For testing purposes, I assume
> my window to be 640x400. Each of the 4 pics should have 160 x 400 px.
> I need to load each one of the 4 images and blit them to the surface.
>
> How do I do that?
>
> Here is what I got so far and I don't see anything else than a black screen
> with 640 x 400 pixels :-s
>
> [code]
> #!perl
>
> use strict;
> use warnings;
> use utf8;
> use Data::Dumper qw/Dumper/;
> use SDL;
> use SDLx::Surface;
> use SDL::Event;
> use SDL::Events;
> use SDLx::App;
> use SDL::Image;
>
> # create our main screen
> my $app = SDLx::App->new(
>w => 640,
>h => 400,
>exit_on_quit => 1,
>dt => 0.2,
>title => 'SDLx Menu'
> );
>
> $app->update(); # make it black
>
> my $some_jpg_file = 'images/1-0d5ff539c7a3d166.jpg';
> my $image = SDL::Image::load( $some_jpg_file );
>
> $app->blit_by(
>$image,
>[0, 0, 160, 400],
> );
>
$app->blit();
> $app->run();
>
> # -- Cleanup.
> exit(0);
> [/code]
>
> And, is it possible to extract a picture section from the image loaded? In
> case the app is loaded with 4:3 aspect ratio, I would like to snip a bit of
> the images at the left and the right, so that the pictures fit in without
> the need of black bars at the top and the bottom of the screen.
Yup this is possible. Make a smaller SDLx::Surface of the final
snipped image, blit_by the original image with the right offset.
>
> Best regards,
> Alex
>