ImageTk.PhotoImage vs. Tkinter.PhotoImage
John Carter
jnc at ecs.soton.ac.uk
Wed Sep 29 06:00:11 EDT 1999
On Mon, 27 Sep 1999 21:42:15 GMT, Les Schaffer <godzilla at netmeg.net>
wrote:
>i need to zoom in on a user specified subset of an image.
>
>but i am confussed about ImageTk.PhotoImage and
>Tkinter.PhotoImage. the former creates an instance of the latter in
>its self.__photo, used for pasting. but i need access to
>Tkinter.Photoimage's copy and zoom commands. i dont understand why
>ImageTk.PhotoImage doesnt just extend Tkinter.PhotoImage so the copy
>and zoom methods are available, or delegate those calls to __photo
>methods.
>
>also, i notice that in Tkinter.PhotoImage the -from and -to keywords
>for the image copy methods are not explicitly defined. wonder why....
>
>this is my first real foray into using tkinter/PIL for some astro
>work, so please excuse if my questions are stupid.
>
>
>so, with code like this:
>
> ...
> self.photo = ImageTk.PhotoImage(image)
> self.canvas.create_image(0, 0, image=self.photo, anchor=NW)
> ...
>
>i want to create a new PhotoImage consisting of a zoom in on a subset
>of self.photo (i have the x,y coords of the desired zoom area in
>self.photo).
I've simply used the crop method, so I would do something like
image1 = image,crop((x1,y1,x2,y2))
self.photo = ImageTk.PhotoImage(image1)
self.canvas.create_image(0, 0, image=self.photo, anchor=NW)
Do all the image manipulation before I create an instance of Image.TK.
This worked well, except when I called a C extension, there was
clearly something I dodnt usnder stand about PIL's internal data
structures, as my C code accted on the whole origional image. This was
easily solved by using a copy after the crop.
John Carter
jnc at ecs.soton.ac.uk
>
>--
>____ 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