Re: Splash screen.



On Wed, 9 Aug 2000, Naba Kumar wrote:

> Thanks Steve. The idea of producing a splash screen
> was great. But it uses xpm file for the image. As I
> have already told the image is going to be anything
> other than xpm. Can there be some way to display other
> file formats (eg. jpg formate)in the given function?

 If you don't mind using gnome libs, then use gnome pixmap + imlib (this way
you will be able to use a multitude of file formtas imlib understands) and
this function (note: it's C++ - you will have to reorder things a little)

GtkWidget* load_image(char* file)
{
    GdkImlibImage* im = gdk_imlib_load_image(file);
    if (!im)
        return NULL;
    int imw = im->rgb_width, imh=im->rgb_height;
    GtkWidget* ret = gnome_pixmap_new_from_imlib_at_size(im,imw,imh);
    gdk_imlib_destroy_image(im);
    return ret;
}

 Also you can use plain implib for loading, but it's trickier as I remember.

 Imlibg supports jpg, gif, png, tiff, xpm, xbm and probably some others.

> --- Steve Ramsay <ramsay@spatialcomponents.com> wrote:
> 
> > // show the splash screen
> > void splash_screen(void)
> > {
> > 	// make a window for splash scrren, make it a popup
> > so it will stay on
> > 	// top of everything.
> >         GtkWidget *MainFrame = gtk_window_new
> > (GTK_WINDOW_POPUP);
> >         gtk_object_set_data (GTK_OBJECT (MainFrame),
> > "Caris",
> > MainFrame);
> > 
> > 	// set the size to that of our splash image.
> >         gtk_widget_set_usize (MainFrame, 428, 314);
> >         gtk_window_set_title (GTK_WINDOW
> > (MainFrame), "Caris");
> > 	// center it on the screen
> >         gtk_window_set_position(GTK_WINDOW
> > (MainFrame),
> > GTK_WIN_POS_CENTER);
> > 
> > 	// set up key and mound button press to hide splash
> > screen
> >        
> >
> gtk_signal_connect(GTK_OBJECT(MainFrame),"button_press_event",
> >                
> > GTK_SIGNAL_FUNC(splash_button_pressed),NULL);
> >        
> >
> gtk_signal_connect(GTK_OBJECT(MainFrame),"key_press_event",
> >                
> > GTK_SIGNAL_FUNC(splash_key_pressed),NULL);
> >         gtk_widget_add_events(MainFrame,
> >                               GDK_BUTTON_PRESS_MASK|
> >                              
> > GDK_BUTTON_RELEASE_MASK|
> >                               GDK_KEY_PRESS_MASK);
> > 
> > 	// make the image for the splash screen
> >         GtkWidget* pixmap =
> > create_pixmap_from_data(MainFrame,
> >                                 splash_xpm);
> > 
> >         gtk_container_add (GTK_CONTAINER
> > (MainFrame),pixmap);
> >         gtk_widget_show(pixmap);
> >         gtk_widget_show(MainFrame);
> > 
> > 	// force it to draw now.
> > 	gdk_flush();
> > 
> > 	// go into main loop, processing events.
> >         while(gtk_events_pending() ||
> > !GTK_WIDGET_REALIZED(pixmap))
> >                 gtk_main_iteration();
> > 
> > 	// after 3 seconds, destroy the splash screen.
> >         gtk_timeout_add( 3000, splash_screen_cb,
> > MainFrame );
> > }
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Kick off your party with Yahoo! Invites.
> http://invites.yahoo.com/
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-list
> 

 Best regards,
  -Vlad





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