events and/or imlib



Hi.
I'm having some problems here with a simple image viewer I am making with
gtk and imlib. The program keeps showing a scaled-down version of the
image first, and that makes it hard to keep this a fast image viewer...

What my program does is this: load the image (gdk_imlib_load_image()), and
then resize the drawingarea to the size of the image
(gtk_widget_set_usize()). I have set up a function to handle 
configure_events, and a function to handle expose_events. These both print
for example "configure_event in GtkDrawingArea" (I use gtk_widget_get_name
to get the widget's name), and then do a
gdk_imlib_apply_image(image,widget->window), where the widget is the one
the function was called with. Finally, the event-functions both wait for a
keystroke (for debugging purposes). 
When I run the program, a default image is loaded.
Anyway, when I run my program, the following happens:
I get "configure_event in GtkDrawingArea", and nothing is visible yet.

Then the window pops up, and I get "expose_event in GtkDrawingArea".

Now the window is resized to the size of the image, and the
image is shown in the old size of the window (scaled down by
imlib), and I get "expose_event in GtkDrawingArea".

Then the image is tiled in the entire background of the window, still in
the size of the old window, and I get a "configure_event in
GtkDrawingArea".

Finally, I get 2 "expose_event in GtkDrawingArea"s, and the image is now
shown in the correct size.

So, I'm curious. Do I blame imlib or gtk? :)
I tried some times to disable one of configure_event and expose_event, and
when i did, the result was variable. With only configure_event, I
usually get (in the order of my text-output):
nothing
the resized window with nothing in it
(sometimes I get the full sized image with the image tiled in the
background in between here, this usually happens the first time after i
compile)
the correct sized image in the window

When I have only expose_event:
a blank, small window
the resized window with a scaled-down image in it
the resized window with the scaled-down image tiled in it
the correct sized image in the window

Is all this correct? Did anyone understand my explanation? :)

Ketil Froyn
--
All I ask is a chance to prove that money can't make me happy.

http://www.ifi.uio.no/~ketilf/       
mailto:ketilf@ifi.uio.no



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