[Python-de] pygtk pixbuf_new_from_file
Thomas Guettler
guettli at thomas-guettler.de
Mit Apr 20 21:41:43 CEST 2005
On Mon, Apr 18, 2005 at 05:44:39PM +0200, Ron Opitz wrote:
> Hallo,
>
> ich habe ein Problem mit der Funktion pixbuf_new_from_file.
Hallo,
hilft dir das weiter? Ich glaube du brauchst mind. gtk2.2 für die
Funktion. Ansonsten ist die pygtk Referenz eigentlich ganz gut.
def scale2pixbuf(width_max, height_max, filename):
pixbuf=gtk.gdk.pixbuf_new_from_file(filename)
width=float(pixbuf.get_width())
height=float(pixbuf.get_height())
if (width/width_max) > (height/height_max):
height=int((height/width)*width_max)
width=width_max
else:
width=int((width/height)*height_max)
height=height_max
pixbuf=pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
gc.collect() # Tell Python to clean up the memory
return pixbuf
--
Thomas Guettler <guettli at thomas-guettler.de>
http://www.thomas-guettler.de