Put render in expose.

Source: Internet
Author: User
Tags gtk

# Include <GTK/GTK. h>
# Include <stdlib. h>
Int main (INT argc, char * argv [])
{
Gtkwidget * window, * Fix;
Gdkpixbuf * pixbuf = NULL;
Gdkpixmap * pixmap = NULL;
Gtkstyle * style;
// Gtkwidget * fixed;
Gtk_init (& argc, & argv );


Window = gtk_window_new (gtk_window_toplevel );
Gtk_signal_connect (gtk_object (window), "Destroy", gtk_signal_func (gtk_main_quit), null );

// Fixed = gtk_fixed_new ();
// Gtk_fixed_set_has_window (gtk_fixed (fixed), true );
// Gtk_container_add (gtk_container (window), fixed );
Gtk_window_set_default_size (gtk_window (window), 100,200 );
// Gtk_widget_set_app_paintable (window, true );
Pixbuf = gdk_pixbuf_new_from_file ("./tvbutton.png", null); // load the file to the cache
Pixmap = gdk_pixmap_new (window-> window, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),-1); // set the display area of the image

Gtk_widget_show_all (window );

Gdk_pixbuf_render_to_drawable (pixbuf, pixmap,
Window-> style-> fg_gc [gtk_state_normal],
0, 0, 0,
Gdk_pixbuf_get_width (pixbuf ),
Gdk_pixbuf_get_height (pixbuf ),
Gdk_rgb_dither_normal, 0, 0); // submit the image to the region. Set the last four or five to-1.
G_object_unref (pixbuf );
/**/
/* Gdk_draw_pixbuf (pixmap, window-> style-> bg_gc [gtk_state_normal],
Pixbuf, 0, 0, 0,-1,-1, gdk_rgb_dither_normal, 0, 0 );*/

/* Gdk_pixbuf_render_pixmap_and_mask (pixbuf, & pixmap, null, 0 );
Style = gtk_style_copy (window-> style );

If (style-> bg_pixmap [gtk_state_normal])
G_object_unref (style-> bg_pixmap [gtk_state_normal]);

Style-> bg_pixmap [gtk_state_normal] = g_object_ref (pixmap );
Style-> bg_pixmap [gtk_state_active] = g_object_ref (pixmap );
Style-> bg_pixmap [gtk_state_prelight] = g_object_ref (pixmap );
Style-> bg_pixmap [gtk_state_selected] = g_object_ref (pixmap );
Style-> bg_pixmap [gtk_state_insensitive] = g_object_ref (pixmap );

Gtk_widget_set_style (window, style );
G_object_unref (style );*/

Gdk_window_set_back_pixmap (window-> window, pixmap, false );
// Gdk_window_clear (window-> window );
/* Fix = gtk_fixed_new ();
Gtk_container_add (gtk_container (window), fix );
Set_widget_bg ("bg1.jpg", fix );

Gtk_widget_show (fix );*/


Gtk_main ();

Return 0;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.