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

Ralph Seguin rpseguin@yahoo.com
Tue, 28 Mar 2000 15:10:05 -0800 (PST)

> What exactly do you mean by "direct access to
> pixels"? If you want to

I mean being able to set a given pixel a given color.
For each pixel in a canvas.
Fractals, surface plots, graphics rendering, ray
trace, ...
I can see a number of things that I could use this

for curY in range ( 0, 1000 ) :
	for curX in range ( 0, 1000 ) :
		# fooBar () is some time-consuming
		# function which will compute a color
		# value, possibly/probably unique per
		# pixel.
		val = fooBar( curX, curY )
		myCanvas.setPixel( curX, curY, val )

In this example, fooBar() is some arbitrary,
time-consuming function, so the cost of doing
setPixel() is small in comparison.

Doing this by generating degenerate (Canvas)
rectangles or
degenerate (Canvas) lines is very inefficient in both
storage space and compute/render time.

Currently, I can use PIL to render to an off-screen
image and then assign this image to the image for a
Tkinter.Label or other widget, but this is really not
good either.

> exercise is futile: Python is simply too slow for
> that. (Exception are 

Setting a pixel represents a minor fraction of the
amount of time for computing some things like
fractals, ray traces, ...

> night sky after computing it you can get away with
> it because there's so few pixels to paint).


> Whether you have direct access to slightly higher
> abstractions (like
> scanlines or rectangular areas) depends on the gui

Having a rectangle for each pixel is incredibly

> interesting: it won't help you much if I tell you
> the raw bitmap for any window from MacPython if
> you're not using a mac:-)

I'd like to be platform independent.

Since I do most of my work under UNIX, I could hack up
some code to write pixels directly to X drawables, but
this is hardly elegant or the way that I would like to
do it.


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