Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tk - canvas accessing color for each pixel

24 views
Skip to first unread message

Ed Redman

unread,
Oct 18, 2005, 8:39:33 AM10/18/05
to
I would like to access and change the color of any pixel on a Tk/canvas.
I want to be able to scan the canvas and if the color at a certain point
is lets say 'red' then make it 'green". I don't see a point widget for
tkcanvas. Can I do this?

thanks
Ed Redman
ed.r...@dal.ca

Hidetoshi NAGAI

unread,
Oct 18, 2005, 12:02:01 PM10/18/05
to
From: Ed Redman <ed.r...@dal.ca>
Subject: tk - canvas accessing color for each pixel
Date: Tue, 18 Oct 2005 21:41:57 +0900
Message-ID: <pan.2005.10.18....@dal.ca>

> I would like to access and change the color of any pixel on a Tk/canvas.

A canvas widget doesn't support to access per pixel.
Although you can do that if each pixel is represented by a line item,
that will be incredibly slow.

If you want to do that, I think, you'll have to use a PhotoImage object.
On a PhotoImage, you can access and change the color of any pixel.
Please use TkPhotoImage#get and TkPhotoImage#put.
And please read "photo" manual of Tcl/Tk.

Stadard Tcl/Tk libraries supports only GIF and PPM/PGM.
If you want to treat other image formats,
please use "Img" extesion of Tcl/Tk.
--
Hidetoshi NAGAI (na...@ai.kyutech.ac.jp)


0 new messages