GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Nov 21, 2014 5:58 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Noobie help with gdk_draw_pixbuf
PostPosted: Wed May 14, 2008 2:41 pm 
Offline
Familiar Face

Joined: Mon May 12, 2008 1:50 pm
Posts: 10
Hi Everyone,

I wounder if anyone can help with what is probably a simple problem. I'm struggling to display an image in a window. Here is the code ...

Quote:
Code:
void init_window ( GdkWindow *window )
{
    GdkWindowAttr wattr ;
    guint rw, rh ;
    GdkWindow *root_window ;

    if ( !window )
    {
        root_window = GDK_ROOT_PARENT ( ) ;

        gdk_window_get_size ( root_window, &rw, &rh ) ;
   
        wattr.title = "Slide";
        wattr.x = 0 ;
        wattr.y = 0 ;
        wattr.width = rw ;
        wattr.height = rh ;
        wattr.wclass = GDK_INPUT_OUTPUT ;
        wattr.visual = gdk_window_get_visual ( root_window ) ;
        wattr.window_type = GDK_WINDOW_TOPLEVEL ;
        wattr.override_redirect = TRUE ;
        window = gdk_window_new ( root_window, &wattr, GDK_WA_TITLE | GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_NOREDIR ) ;
    }

    gdk_window_show ( window ) ;
    gdk_window_raise( window ) ;
}


int main (int argc, char **argv)
{
    GdkWindow *window = NULL ;
    GdkPixbuf *pixbuf ;   
    GdkPixmap *pixmap ;

    gtk_init ( &argc, &argv ) ;

    init_window ( window ) ;

    // Get screen details for scaling   
    gdk_window_get_size ( window, &xres, &yres ) ;

    // Load and scale image
    pixbuf = gdk_pixbuf_new_from_file_at_scale ( "/downloads/slideshow/slideshow/images/g_pint_01.jpg", xres, yres, FALSE, NULL ) ;

    pixmap = gdk_pixmap_new ( window, xres, yres, gdk_visual_get_best_depth ( ) ) ;

    gdk_draw_pixbuf ( pixmap , gdk_gc_new ( window ) , pixbuf,
         0, 0, 0, 0, xres, yres, GDK_RGB_DITHER_NORMAL, 0, 0 ) ;
   
    // Terminate handler
    g_signal_connect ( G_OBJECT ( window ), "destroy", gtk_main_quit, NULL ) ;

    gtk_main ( ) ;
      
    return 0 ;
}



Anything obvious?

Regards,

Lee


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group