ImageTk.PhotoImage vs. Tkinter.PhotoImage
Les Schaffer
godzilla at netmeg.net
Wed Sep 29 16:14:52 EDT 1999
John Carter said:
> I've simply used the crop method, so I would do something like
yes. i did a crop followed by a resize.....
def releaseZoom(self, event):
xy = self.canvas.canvasx(event.x), self.canvas.canvasy(event.y)
box = ( self.anchorZoom[0], self.anchorZoom[1], xy[0], xy[1] )
x1, y1, x2, y2 = box
img = self.image.crop( box )
newW = self.zoom * (x2 - x1)
newH = self.zoom * (y2 - y1)
img = img.resize( (newH, newH), Image.BILINEAR )
newRoot = Tkinter.Toplevel()
newRoot.title("Zoom")
newView = Viewer(newRoot, img)
newView.pack()
Viewer does a setimage:
def setimage(self, image):
self.canvas.delete("all")
self.image = image
self.photo = ImageTk.PhotoImage(image)
self.canvas.create_image(0, 0, image=self.photo, anchor=Tkinter.NW)
self.canvas.config(width=image.size[0], height=image.size[1])
Frederick Lundh said on the IMAGE-SIG that a transform would run
faster. havent tried it yet.
--
____ Les Schaffer ___| --->> Engineering R&D <<---
Theoretical & Applied Mechanics | Designspring, Inc.
Center for Radiophysics & Space Research | http://www.designspring.com/
Cornell Univ. schaffer at tam.cornell.edu | les at designspring.com
More information about the Python-list
mailing list