For example the rc_array procedure allows an array of numbers to be
used to display an image in an X window:
rc_array(array, arr_region, win_region, colour_rule, palette)
Displays data from the 2-D array array, restricted possibly to
the region arr_region, as an image in the part of rc_window
specified by win_region. The mapping from array values to
colours is specified by colour_rule and the colours used by
palette.
However I have not seen anything either in popvision, or in any
other place I have looked in Poplog, that allows an array to be
derived from an image, e.g. something like this:
getimageregion(widget, win_region, array, arr_region)
copies the specified region of the window into the specified
region of the array, doing appropriate smoothing,etc.
Or even
getimageregion(widget, win_region, array, arrX, arrY)
copies the specified rectangular region of the window into
the array, starting at the location arrX, arrY in the
array.
(assumes a 1 to 1 mapping, no stretching or compressing, rotating,
etc.)
There also does not seem to be a way of getting an X window dumped
into an image file, from inside Pop-11. The procedure sunrasterfile
and its updater, allow an image file to be read into a Pop-11 array,
or a Pop-11 array of image data to be saved as a file, but because
there seems to be no way to get from an image to an array, that
can't be used to save the image as a file.
It is possible to use the unix utility 'xwd' to dump an image to a
file, and then to read it in using sunrasterfile, but in order to
get the image dumped, you have to click on it, or use the name of
the window. Using the name requires some guarantee that there is no
other window open with the same name. It also, as far as I can see,
means that it can't be done without giving an image a title bar with
a name.
I have managed to define a Pop-11 procedure 'xwd' so that if there
is a window with name 'Xgraphic', this command
xwd('Xgraphic', 'f1.jpg');
causes the external utility 'xwd' to be called to produce
Xgraphic.xwd, and then the 'convert' utility is called to produce a
jpeg version called 'f1.jpg'.
define xwd(widgetname, newname);
;;; dump a window with the widgetname, using 'xwd' then
;;; invoke 'convert' to produce a version of type specified
;;; by the suffix of 'newname'
lvars
xwdname1 = widgetname >< '.xwd';
sysobey('xwd -nobdrs -out ' >< xwdname1 >< ' -name Xgraphic');
sysobey('convert ' >< xwdname1 >< ' ' >< newname);
enddefine;
Then sunrasterfile could be used to read in the f1.jpg file to a
Pop11 array.
However that is really messy. Pop-11 should be able to do directly
whatever it is that xwd does, and it should be able to get the array
data directly from the widget, without having to go through a file
produced by xwd.
Does anyone know what I am missing?
Thanks.