Re: Forcing first exposure



On 1/13/06, Gravis Zero <gtk-app-devel-list adaptivetime com> wrote:
not exposed until after you load the file.  needless to say i would like
to be able to load the image into the drawing area when loaded instead
of when it is exposed as it make the app look slugish or frozen.  i have

I would load the image in chunks (perhaps 100 scan lines?). For each
chunk, gtk_widget_queue_draw_area() then let the mainloop run for a
few iterations so the expose is processed.

Something like (untested):

// malloced memory we load to
guchar *image_buffer;

void
load_image_progressive( GtkWidget *drawing_area )
{
  static const int chunk_height = 100;
  int y;

  for( y = 0; y < 4096; y += chunk_height ) {
    read( fd, image_buffer + y * 4096, 4096 * chunk_height );
    gtk_widget_queue_draw( drawing_area, 0, y, 4096, chunk_height );
    while( g_main_context_iteration( NULL, FALSE ) )
      ;
  }
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]