Re: [gtk-list] events and/or imlib



On 13 Feb, Ketil Froyn scribbled:
->  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? :)

no - blame yourself. :)

1. gdk_imlib_apply_image() scales the image tothe CURRENT windows' size
and sets it as the bgpixmap and if shaped sets the windows shape to the
image.
2. you dont need to handle expose events using this method.
3. you need to have flags to not apply the image untilt he widnow has
finalyl been sized to the corretc sieze you need/want by gtk- it will
not start at the size you want until its packed and realized.

so basically you have to be more careful :)


->  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
->  

-- 
--------------- Codito, ergo sum - "I code, therefore I am" --------------------
raster@rasterman.com       /\___ /\ ___/||\___ ____/|/\___  raster@redhat.com
Carsten Haitzler           | _ //__\\ __||_ __\\ ___|| _ /  Red Hat Advanced
218/21 Conner Drive        || // __ \\_ \ | |   \ _/_|| /   Development Labs
Chapel Hill NC 27514 USA   ||\\\/  \//__/ |_|   /___/||\\   919 547 0012 ext 282
+1 (919) 929 9443, 801 4392   For pure Enlightenment   http://www.rasterman.com/

              \|/ ____ \|/  For those of you unaware. This face here is in fact
	      "@'/ ,. \@"   a Linux Kernel Error Message.
	      /_| \__/ |_\
		 \__U_/
							   



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