[Image-SIG] Pixmap widget with access to pixels?

Ralph Seguin rpseguin@yahoo.com
Tue, 28 Mar 2000 20:29:09 -0800 (PST)

> class displayPixMap:
>     def __init__(self, parent, imageSize):
>         self.image = Image.new("RGB", imageSize,
> (0,0,0))
>         self.TkImage =
> ImageTk.PhotoImage(self.image)
>         self.imageDisplay = Label(parent, image =
> self.TkImage)
>         self.imageDisplay.pack()
>     def putPixel(self, x, y, value):
>         self.image.putpixel((x,y), value)
>         self.TkImage =
> ImageTk.PhotoImage(self.image)
>         self.imageDisplay.update_idletasks()

I already have something like this example, but I feel
that it is very inneficient to copy an entire
pixmap/image when changing a single pixel.

Let's say that I've got an image that is 4000x4000
A single putPixel(), requires me to copy 16 million
pixels worth of data, or worse.

Am I wrong and simply missing something?

If you have a label widget with a pixmap, then you
already have the storage allocated for storing the
pixels, it would be nice to be able to write directly
into that pixmap.  Granted it's a bit more work for
palette stuff...

Just as a quick/dirty/ugly hack, I wrote some C code
that enabled me to write directly to an X Drawable.
The code does work as an experiment for tweaking
pixels, but I have to put in a bunch of stuff related
to color matching and palettes, visuals, ... (some of
the ugly side of dealing with X).

Honestly, I think that this is where some of the
problem lies.  Basically, since Tkinter and PIL are
"cross-platform", you have some of these issues to
deal with on the implementation side.


Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.