GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Noobie help with gdk_draw_pixbuf

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
ldavies
Familiar Face


Joined: 12 May 2008
Posts: 10

PostPosted: Wed May 14, 2008 2:41 pm    Post subject: Noobie help with gdk_draw_pixbuf Reply with quote

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: (C)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP