Re: How to draw a single pixel in a Canvas

From: Andrew Dorrell <andrewd_at_mountains.net.au>
Date: Sat, 27 Feb 1999 03:07:07 +0000

Erick Gallesio wrote:
>
> Hi Paolo,
>
> > What's the simplest--and possibly most efficient--way of drawing a _single_
> > pixel in a Canvas widget? The only one I can think of is to draw a 1 pixel
> > wide rectangle item.
>
> The simplest and not too efficient way to draw a single pixel is to
> use a line of length 1 pixel.
>

Yes... yuck! There is a much touted set of patches collectively called
the "dash patch" which includes a number of performance improvements for
canvases. They are actively maintained by Jan.Nijtmans_at_cmg.nl and you
can find them by following pointers at any of the Tcl/Tk archive sites.
Unfortunately I found that it was very difficult to reconcile these
against the STk source tree :-(
And I don't know enough about patch to try and manually unbundle
individual components of the full patch.

>
> In the Tk distrib there is (was ?) some code for making lines on a
> widget. This code was in #ifdef which wer not active by default. If
> you have a lot of points to draw, I could have a look to see if it is
> a practicable solution.

I also recal that someone released a "raster" widget for Tk with just
this purpose in mind.
 
> Another probable solution consists to allocate an image and make draw
> you points in it. I'm not sure that it is simple but if I remember
> someone has already tried this solution (I don't remember if it produces
> something)

My narray code (under contrib on kaolin) can be used for this purpose.
In that you can create an array and use it as a :data argument to a
regualar image create or configure call. It does have a number of
limitations however, not the least of which is that it won't compile
with gcc 2.8 (or egcs) but requires 2.7.X (for the c++ part)

Sorry... no simple solution.

-- 
Mr Andrew Dorrell                                *
Envision Computing                 /---\  Whoo?      *
http://www.pnc.com.au/~enviscom    (o o) /     *
                                   ( : )            .
                                    ^ ^
                                                    *
Received on Fri Feb 26 1999 - 22:25:05 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST