Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 2 > Newsgroup comp.lang.pop

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 08-22-2009, 12:10 AM
Aaron Sloman
Guest
 
Posts: n/a
Default (via pop-forum) getting arrays and files from X windows in Pop-11

David Young's popvision library has some very useful extensions to
the basic X window facilities in Pop-11.

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.

Aaron
http://www.cs.bham.ac.uk/~axs/

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

Reply

Popular Tags in the Forum
arrays, files, pop11, popforum, windows

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 11:24 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.