Re: Working with images



Thanks muppet.

It's possible that I'm making progress on this :)
I *think* I have basically everything I need in place. So far I have:

my ( $splash_frame, $background_image, $fade_image, $splash_timeout,
    $splash_drawing_area, $splash_counter );

sub load_splash_screen {
$splash_screen = Gtk2::GladeXML->new($gladefile, 'Splash'); $splash_frame = Gtk2::Gdk::Pixbuf->new ('rgb', 'FALSE', 8, 400, 300); $background_image = Gtk2::Gdk::Pixbuf->new_from_file("$currentdir/sales/background.jpg"); $fade_image = Gtk2::Gdk::Pixbuf->new_from_file("$currentdir/sales/nus_consulting_group.png"); $splash_screen->get_widget("Splash")->signal_connect (destroy => sub {$splash_screen=undef; 1}); $splash_screen->get_widget("Splash")->signal_connect (destroy => \&splash_screen_cleanup); $splash_drawing_area = Gtk2::DrawingArea->new; $splash_drawing_area->signal_connect (expose_event => \&splash_screen_expose_callback);
    $splash_screen->get_widget("Splash")->add($splash_drawing_area);
    $splash_timeout = Glib::Timeout->add (1000, \&splash_timeout);
    $splash_counter = 0;
}

sub splash_screen_cleanup {
Glib::Source->remove ($splash_timeout);
    $splash_timeout = 0;
}

sub splash_timeout {
if ($splash_counter > 255) { $splash_screen->get_widget("Splash")->destroy; } else { $background_image->copy_area(
                                        0, 0,
                                        400, 300,
                                        $splash_frame,
                                        0, 0
                                    );
$fade_image->composite->(
                                        $splash_frame,
                                        100, 100,
                                        200, 150,
                                        0, 0,
                                        1, 1,
                                        'nearest',
                                        $splash_counter
                                );
$splash_counter++; $splash_drawing_area->queue_draw;
        return 1;
} }

sub splash_screen_expose_callback {
my ($widget, $event) = @_; my $drawable = $widget->window; $drawable->draw_pixbuf(
                            $widget->style->black_gc,
                            $splash_frame,
                            $event->area->x, $event->area->y,
                            $event->area->x, $event->area->y,
                            $event->area->width, $event->area->height,
                            'normal',
                            $event->area->x, $event->area->y
                          );
return 1; }

However the $fade_image->composite->() line gives me:

*** unhandled exception in callback:
*** Usage: Gtk2::Gdk::Pixbuf::composite(src, dest, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type, overall_alpha) at /home/dan/sales/sales.pl line 112.

At this point, $splash_frame certainly containts a Gtk2::Gdk::Pixbuf. The only bit I'm unsure of is the Gtk2::Gdk::InterpType bit, for which I used 'nearest'.

Any clues?

Dan

--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au
website: http://www.nusconsulting.com.au
Title: CanIt Vote for ID 86565

The following links have been inserted by the NUS Consulting internal spam filter and are for NUS Consulting staff only
Spam
Not spam
Forget previous vote


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]