views:

10

answers:

0

In my C GTK+ application I must load and display images using a GtkAnimView widget.

I have a loading function:

void loading(GtkWidget *widget, const char* file_path, MainWin* mw) 
{ 
   GError* error;  
        gssize n_read; 
   gboolean res; 
   guchar buffer[LOAD_BUFFER_SIZE]; 
   GInputStream* input_stream; 
   GFile *file = g_file_new_for_path(file_path); 

        mw->loader =    gdk_pixbuf_loader_new(); 
   mw->animation = gdk_pixbuf_animation_new_from_file(file_path,error);    
   input_stream = g_file_read(file, generator_cancellable , NULL); 

   res = TRUE; 

   while (1){ 
      n_read = g_input_stream_read(input_stream, buffer, sizeof (buffer),generator_cancellable,error); 

      if (n_read < 0) { 
                        res = FALSE; 
                        error = NULL;  
                     gdk_pixbuf_loader_close(mw->loader,NULL); 
                     g_input_stream_close(input_stream,NULL,NULL);   
                        break; 
                } 

   if (n_read == 0) 
        break; 

   if (!gdk_pixbuf_loader_write(mw->loader, buffer, sizeof(buffer), error)){ 
      res = FALSE; 
      g_input_stream_close(input_stream,NULL,NULL); 
      gdk_pixbuf_loader_close(mw->loader,NULL); 
       break; 
      } 

   if (res){       

      if ( !gdk_pixbuf_animation_is_static_image(mw->animation ) ) 
      gtk_action_group_set_sensitive(rotation_actions, FALSE); 
     else 
      gtk_action_group_set_sensitive(rotation_actions, TRUE); 

      mw->animation = gdk_pixbuf_loader_get_animation((mw->loader)); 
       gtk_anim_view_set_anim (mw->aview,mw->animation);    
   } 
  } 
   g_input_stream_close(input_stream,NULL,NULL); 
   gdk_pixbuf_loader_close(mw->loader,NULL); 
} 

This code loads the image located at file_path into the GtkAnimView widget. The fact is that every time you call this function and hence load and display a image, its size is added to the memory occupied by the application. What is the problem?