Re: Can specific pixel values be referenced in an IMAGE object?

Scott Raney ((no email))
Wed, 8 Mar 1995 15:52:28 -0700 (MST)

>
> I want to build a scatter plot on the fly. It contains a very large
> number of (non-unique) points (921 K). Is it reasonable to build an
> image on the fly in MC? I expect the image will have to be on the
> order of 900x900 to show what I need reasonably.

The only way to set individual pixels in an image would be to use the
"click" command with the pencil tool. This is a pretty expensive
operation, though, and is probably only useful if you have a few dozen
points to graph.

A faster way would be to set the points property of a graphic object
with a very small marker at each point. Note that if you separate the
points by blank lines they will be plotted as individual points rather
than as points on a line.

But for the number of points you're talking about, even this will be
too slow. The solution for a problem of this scale is to write an
external. Fortunately a template that does 90% of what you need is
part of the standard distribution. The "life" card of the external
tutorial draws squares into a MetaCard image object, which is very
similar to what you need to do.

Finally, note that if you're really talking 900,000 points (that's a
lot of points!), even doing a raw Xlib call to draw each point will be
too slow due to the protocol overhead. What you'll probably have to
do is create an XImage and set the pixels directly (even the XPutPixel
function is probably too much overhead for this many points), and then
do an XPutImage call to move it down to the server for MetaCard to
use. The disadvantage of this approach is that you'll have to handle
the color-to-pixel-value translation and different display depths
yourself.

-- 
***********************************************************************
* Scott Raney  303-447-3936            Remember: the better you look, *
* raney@metacard.com                   the more you'll see -- Lidia   *
***********************************************************************