There are speed differences between gdkrgb and imlib due to the way they
operate.  Gdkrgb simply renders rgb or grey data to a drawable (ie. a
GdkWindow or GdkPixmap).  On the other hand, imlib handles a bit more, and
just passes you a GdkPixmap (and optionally a corresponding mask).  If you
wish to draw the complete image, then this is fine.  On the other hand, if
you only want to display part of the image data, or the data changes
frequently, the flexibility of gdkrgb helps a lot.

To get imlib like speed for expose events with gdkrgb, consider creating a
GdkPixmap (with create_pixmap) to hold the image data, and use
draw_gray_data() to render the image data to it.  Then on expose events,
you can use a single draw_pixmap() call to draw the pixmap to the window.

libglade is a C library that I wrote that borrows a lot from the pyglade
module.  It is currently more up to date, and by virtue of being written
in C, substantially faster.  It is also more complete -- it supports most
of the gnome enhancements in the latest versions of glade.  The libglade
module in recent versions of pygtk allows you to use libglade to build
interfaces rather than the slower pyglade.

James.

--
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


On Fri, 22 Oct 1999, Remi Delon wrote:

> Thanks. With your help, I was able to make it work. In fact, I was
> just missing the push_rgb_visual call. (I don't know what exactly it does).
> 
> But it looks like gdkrgb is much slower than imlib. I used a 800x800 image
> that
> I display in a scrolled window. When I move the scrollbars, the image gets
> updated
> very slowly (square by square), whereas the same image converted to an rgb
> moves
> smoothly with imlib.
> 
> By the way, what is the libglade library ? So far, I used pyglade to parse
> my xml glade files and create my widgets. It works fine, except for a few
> little things that I had to modify in the build.py file. (But it may be
> because of the version of glade I'm using (0.4.1)). If you are interested,
> I can give you the list of the changes I made (for example, in the table_new
> function, the keyword for the column spacing is column_spacing, and not
> col_spacing)
> 
> Remi.
> 
> > -----Original Message-----
> > From: James Henstridge [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, October 21, 1999 6:36 PM
> > To: [EMAIL PROTECTED]
> > Subject: RE: [pygtk] Greyscale images with imlib
> >
> >
> > I am not sure what is causing the problems for you.  Here is a test
> > program I wrote.  Do you get errors when running this one?
> >
> > from gtk import *
> >
> > # this bit is a little slow ...
> > data = ""
> > for i in range(255):
> >         for j in range(255):
> >                 data = data + chr((i+j)/2)
> >
> > push_rgb_visual()
> >
> > win = GtkWindow()
> > win.connect("destroy", mainquit)
> > da = GtkDrawingArea()
> > da.size(255, 255)
> > def expose(wid, event):
> >
> > wid.draw_gray_image(wid.get_style().fg_gc[STATE_NORMAL], 0,0, 255,255,
> >                             GDK.RGB_DITHER_NORMAL, data, 255)
> > da.connect("expose_event", expose)
> > win.add(da)
> > win.show_all()
> > mainloop()
> >
> >
> > As for scaling, gdkrgb does not provide support for that.  There is
> > another library called libart that can handle those sort of
> > things, but I
> > don't have a wrapper for it at the moment.
> >
> > James.
> >
> > --
> > Email: [EMAIL PROTECTED]
> > WWW:   http://www.daa.com.au/~james/
> >
> >
> 
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
> 

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to