title: GTK+ Drawing_Area Image Redraw with Expose Event
body: <p>I have a program in C that basically reads an image into a char buffer, performs some manipulation to its pixels before displaying the image back to the screen. </p>
  
  <p>So far, the image displays fine; but I encountered the two issues below:</p>
  
  <ol>
  <li>When I minimize the GTK window and bring it back up again, the image just disappears, leaving the Drawing_Area empty.</li>
  <li>How do I redraw/update the image in the Drawing_Area with a button push? </li>
  </ol>
  
  <p>Here's the function that does the drawing:</p>
  
  <pre><code>void Draw_Img(GtkWidget *widget, unsigned char **buffer,int x_offset,int y_offset,int x1, int y1,int x2, int y2)
  {
    int i,j;
    int width,height;
  
    width=x2-x1+1;
    height=y2-y1+1;
  
    for(j=0;j&lt;width*height;j++)
      tmp_buf[j]=0;
  
    for(j=y1;j&lt;=y2;j++)
      for(i=x1;i&lt;=x2;i++)
        tmp_buf[j*width+i-x1]=buffer[j][i];
  
    gdk_draw_gray_image(widget-&gt;window,
        widget-&gt;style-&gt;fg_gc[GTK_STATE_NORMAL], x_offset, y_offset,
       width, height, GDK_RGB_DITHER_NONE, tmp_buf, width);
  }
  </code></pre>
  
  <p>The main function:</p>
  
  <pre><code>int main(int argc,char **argv)
  {
    gtk_init (&amp;argc, &amp;argv);    
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  
    gtk_window_set_title(GTK_WINDOW (window), "RESET DEMO");
    gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
    g_signal_connect (G_OBJECT (window), "destroy",
        G_CALLBACK (gtk_main_quit), NULL);
  
    button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
    g_signal_connect_swapped (button, "clicked", G_CALLBACK (display), drawing_area);
  
    vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (window), vbox);
    gtk_widget_show (vbox);
  
    gtk_widget_set_size_request(drawing_area, Test_Size*3, Test_Size);
    gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);
    gtk_widget_show(drawing_area);
  
    gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
    gtk_widget_set_can_default (button, TRUE);
    gtk_widget_grab_default (button);
    gtk_widget_show (button);
    gtk_widget_show(window);
  
    /*
      reads image into buffer before calling the "display" function in which 
      calls the Draw_Img function
    */
    myinit();
    g_signal_connect (G_OBJECT (drawing_area), "expose_event",
         G_CALLBACK (display), NULL);
  
    gtk_main();
  }
  </code></pre>
  
  <p>Thanks in advance for any help/input.</p>