將render放到expose中試試

來源:互聯網
上載者:User

#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);//負載檔案到緩衝
    pixmap=gdk_pixmap_new(window->window,gdk_pixbuf_get_width(pixbuf),gdk_pixbuf_get_height(pixbuf),-1);//設定顯示圖形的地區

      gtk_widget_show_all(window)   ; 

     gdk_pixbuf_render_to_drawable(pixbuf,pixmap,
window->style->fg_gc[GTK_STATE_NORMAL], 
0,0,0,0, 
gdk_pixbuf_get_width(pixbuf), 
gdk_pixbuf_get_height(pixbuf), 
GDK_RGB_DITHER_NORMAL,0,0);  //把圖形提交到地區中去,倒數第4,5個都設為-1即可
g_object_unref(pixbuf);
/**/
    /*gdk_draw_pixbuf(pixmap, window->style->bg_gc[GTK_STATE_NORMAL],
pixbuf, 0,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   ; 
      
  }  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.