[pygtk] Trouble with resizing images
Gary Jaffe
gfj555 at gmail.com
Mon Dec 10 08:21:18 WST 2007
Hi all --
I have a pygtk application that allows the user to shrink and enlarge
images. I work with a gtk.gdk.Pixbuf that gets put into a gtk.Image
which in turn gets added to a gtk.ScrolledWindow. This is all working
well, that is until I enhanced it.
The original version used the pixbuf method scale_simple. It scaled the
pixbuf nicely, but I wanted the center of the image to remain in the
center, so I switched to using the scale method. The scale method also
works but has the side effect of taking the outermost pixels on all 4
sides of the image and spreading them across the empty space between the
edge of the image and the side of the scrolledWindow (when the image is
smaller than the scrolledWindow).
My call to the scale method looks like this.
oldBuf.scale(newBuf, 0, 0, winWidth, winHeight, xdisp, ydisp, newScale,
newScale, gtk.gdk.INTERP_BILINEAR)
The winWidth and winHeight are the dimensions of the scrolledWindow, and
I calculate xdisp and ydisp to keep the center in the center.
I would like the empty space around the image to be the color of the
scrolledWindow background. The scale_simple method did this. Does
anyone know how to get the scale method to do this also?
Thanks,
Gary
More information about the pygtk
mailing list