Re: Working with images



muppet wrote:

On Aug 19, 2004, at 8:39 PM, Daniel Kasak wrote:

                $fade_image->composite->(

you don't want that extra -> there.

                    $fade_image->composite(

Ah. Yes, now I feel stupid. Man, I looked at that line for 20 minutes without spotting that.

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'.

if you're using scale factors of 1, then the interptype is rather uninteresting.

??? The scale factor of 1 is the only setting that gives me the image scaled at the right size. Other settings make it ... well ... too big.

I've changed a few other things around. If I used a 'blank' window from a glade file and added the DrawingArea to it, the splash_screen_expose_callback sub wasn't being called. Don't know why. Maybe it was just another of my mistakes. Anyway, not matter. I've currently got:

-----

sub load_splash_screen {
$splash_screen = Gtk2::Window->new;
   $splash_screen->set_size_request (400, 300);
   $splash_screen->set_title ("Pixbufs");
   $splash_screen->set_resizable (0);
$splash_screen->signal_connect (destroy => sub {$splash_screen=undef; 1});
   $splash_screen->signal_connect (destroy => \&splash_screen_cleanup);
$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->signal_connect (destroy => sub {$splash_screen=undef; 1});
   $splash_screen->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->add($splash_drawing_area);
$splash_screen->show_all; $splash_timeout = Glib::Timeout->add (50, \&splash_timeout);
   $splash_counter = 1;
}

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

sub splash_timeout {
if ($splash_counter > 126) { $splash_screen->destroy; } else { $background_image->copy_area(
                                       0, 0,
                                       400, 300,
                                       $splash_frame,
                                       0, 0
                                   );
print "Counter: $splash_counter\n"; $fade_image->composite(
                                       $splash_frame,
                                       0, 0,
                                       400, 300,
                                       50, 100,
                                       1, 1,
                                       'nearest',
                                       $splash_counter * 2
                             );
$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; }

-----

This runs and at least produces 'something'.
There are 2 remaining problems.

Problem 1:
The first one is probably just my lack of understanding. What I *want* is to have the background image remain 'static' in the background, ie always completely visible. Then I want the $fade_image to fade in.

What I'm getting is *both* images fading in, and towards the end the $fade_image masks out the background completely. This last bit is fine - I understand that if I set the overall_alpha value to 255 it will mask everything else. But why does the background image fade *in*? I thought it would be completely visible from the start, and then fade out while the other image's overall_alpha caused it to be masked out.

Problem 2:
This one is a little worse. I'm getting strange 'streaks' - rendering bugs - in the image. The best way to describe it is with a screenshot or two.

Half-way through the loop:
http://www.nusconsulting.com.au/internal/render_01.jpg
A little further through the loop:
http://www.nusconsulting.com.au/internal/render_02.jpg

See the horizontal and vertical lines streaking out from the logo in the middle?
What are they?
I've tried using all the different interptypes. They all produce the same thing, but slower.

Other than that, it's working :)

--
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 87474

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]