Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-06 - 43,50416/pixdmp.sai
There are 2 other files named pixdmp.sai in the archive. Click here to see a list.
Entry;
COMMENT
.SEC(PIXDMP.SAI - procedure to dump images on LPT)
.index(PIXDMP.SAI - procedure to dump images on LPT)
.;
Begin "PIXDMP.SAI"


Internal Procedure PIXDMP(Reference Integer Array image;
	 String file!name, title, print!mode;
	Real scalefactor);

COMMENT
                  Peter Lemkin, Bruce Shapiro
                     Image Processing Unit
                   National Cancer Institute
                 National Institutes of Health
                     Building 36 Room 4D28
                 Bethesda, Maryland 20014 USA

                      Phone 301-496-2394

	Nov 14, 1976 - Lemkin, fixed dmax/dmin
	Oct 12, 1976 - Lemkin, added gamma correction
	May 26, 1976 - Lemkin added TTY print
	March 20, 1976 - Lemkin clarify title in printout
	March 11, 1976 - Lemkin
	March 10, 1976

	Description
	-----------
	PIXDMP  is  used  to dump images onto LPT: files within
the current computing window. The LPT: file  name  consists  of
the first 3 characters of the file!name concatinated with  3  digit
number and a .LPT extension.

(i.e the number is generated from an OWN variable).  For a full
256x256 pixel image, the image must be broken up into pieces in
order  to  fit  it  onto  136x61  lineprinter  paper.  Thus for
graysale and single hex modes, the  image  is  broken  into  8
32x128  pixel  pieces.   For  the  decimal  dump it is broken
into 64  32x32  pieces.   The  mode  of  the  picture  dump  is
determined by the string variable 'print!mode':

	print!mode
	----------
	S - Single Hexidecimal print
	D - decimal print
	... - (default) 8 character simulated graysale

	If print!mode is (STTY,DTTY, or TTY) then the TTY is used
instead of the LPT.
;

Begin "PIXDMP"


Comment
	PIXDMP dumps the specified picture on a  LPT:  file  in
decimal    hex.    The    image    is    dumped    starting   at
(first!row,first!column) for 36 rows and columns which  is  all
that  will  fit nicely in a 136 column print (actually uses 108
columns);
Require "DEFINE.REQ" Source!file;
Require "PRCMAX.REQ" Source!file;
Require "PRCINV.REQ" Source!file;
Define form!feed="('14)";

Integer 
	data,
	fr,
	lr,
	fc,
	lc,
	no!row!pieces,
	no!column!pieces,
	row!piece,
	column!piece,
	r,
	c,
	i,
	j,
	k,
	p,
	q,
	dmp!chan,
	eof,
	brchar;

String
	file,
	dmp!device;

	Preload!with
	" ",
	".",
	",",
	":",
	"!",
	"/",
	"&",
	"#";
	Own String Array gray!print[0:7];

Preload!with
	"0",
	"1",
	"2",
	"3",
	"4",
	"5",
	"6",
	"7",
	"8",
	"9",
	"A",
	"B",
	"C",
	"D",
	"E",
	"F";
	Own String Array hex!print[0:16];

Own Integer
	number;

"	[1] open the LPT: channel"
	Getformat(p,q);
	Setformat(-2,0);
	dmp!chan_GETCHAN;
	If Equ(print!mode,"TTY") or Equ(print!mode[2 for 3],"TTY")
		Then dmp!device_"TTY"
		Else dmp!device_"LPT";
	Open(dmp!chan,dmp!device,0,0,2,200,brchar,eof);

"	Create a file name with no spaces - replace spaces with X"
	number_(number+1) Mod 100;
	file_file!name[1 for 3]&"X"&cvs(number)&".LPT";
	Enter(dmp!chan,file,flag);
	Outstr("Dumping image on "&dmp!device&" file: "&file&crlf);


"	[2] divide the image into enough 32X32 or 32x128 images
	to make up the number of pieces from the image size"
	no!column!pieces_ If print!mode="D"
				Then 8 Min ((imsiz+1)/32 Max 1)
				Else 2 Min ((imsiz+1)/128 Max 1);
	no!row!pieces_8 Min ((imsiz+1)/32 Max 1);

For column!piece_1 step 1 until no!column!pieces Do
	For row!piece_1 step 1 until no!row!pieces Do
		Begin "Print a piece"

"		[2.1] print a piece, but first define the region
		to be printed and verify that it is within the
		computing window"
		If print!mode="D"
			Then fc_32*(column!piece-1)
			Else  fc_128*(column!piece-1);
		If print!mode="D"
			Then lc_fc+31 Else lc_fc+127;

		fr_32*(row!piece-1);
		lr_fr+31;
		If (firstrow leq fr leq lastrow) and
		   (firstcolumn leq fc leq lastcolumn)
			Then
			Begin "within computing window"
"			only print the minimum window"
			fr_fr Max firstrow;
			lr_lr Min lastrow;
			fc_fc Max firstcolumn;
			lc_lc Min lastcolumn;

"		[2.2] print the form feed, title,
		 and (row,column) piece"
		Out(dmp!chan,form!feed&dmp!device&": file= "&file&crlf&
			"Title="&title&crlf&
			"("&cvs(fr)&":"&cvs(lr)&","
			&cvs(fc)&":"&cvs(lc)&")"&crlf);
		Outstr("("&cvs(fr)&":"&cvs(lr)&","
			&cvs(fc)&":"&cvs(lc)&")"&crlf);

"		[2.3] dump line by line"
		For r_fr step 1 until lr Do
		  Begin "line"
		  For c_fc step 1 until lc Do
			Begin "print it"
			data_(dmin Max FETCH2D(image,r,c))
				Min dmax;
"			default to pretty print"
"			Print with contrast stretching"
	If scalefactor=0
		Then
		data_(255/(dmax-dmin))*(data-dmin)
		Else
		data_255*scalefactor*data/(dmax-dmin);
			s_gray!print[data Lsh -5];
			If print!mode="D"
				Then
				Begin "decimal"
				s_" "&CVS(data);
				If data=0 Then s_"   0";
				End "decimal";
			If print!mode="S"
				Then
				Begin "single hex"
				s_hex!print[(data Lsh -4)];
				End "single hex";
			Out(dmp!chan,s);
			End "print it";
		    Out(dmp!chan,crlf);
		  End "line";
			End "within computing window";
		End "Print a piece";

"	[3] done"
	Release(dmp!chan);
	Setformat(p,q);
End "PIXDMP";
End "PIXDMP.SAI";