	subroutine image
#
# liest das Grauwertbild aus einem Bild-File in den Common-Block bild.
# Falls der File nicht gefunden wird, liefert die Routine xanz=yanz=0.
#
include	b:defmax.rat
#
define	LUN	6		# Logical Unit No.
define	DRIVE	2		# Drive B:
#
byte	char,yes
byte	rep(3),fmti(10)		# Eingabe-Format
byte	pixel(XMAX,YMAX)	# Grauwertbild
#
integer	xanz,yanz,		# Bildgrenzen
	dxpel,dypel,		# Pixelgroesse
	gwmax			# max.Grauwert (<32)
integer	i,j,k			# Laufindizes
#
double precision fname(2)	# Filename + Extension
#
common	/bild/xanz,yanz,pixel
#
data	yes/'Y'/
data	fmti/'(','1','X',',','.','.','.','I','3',')'/
data	fname/'        ','PIC     '/
#
1  write(1,10)
10 format(' IMAGE - Name des Bild-Files ? ')
read(1,22) fname(1)
22 format(a8)
write(1,24) fname
24 format(' Bild-File ',2a8)
call open(LUN,fname,DRIVE)
xanz=0 ; yanz=0
read(LUN,30,err=900,end=900) xanz,yanz,dxpel,dypel,gwmax
30 format(5i3)
do i=0,gwmax	[ read(LUN,32) j ]	# Dummy Input Grauwerte
read(LUN,32) j				# - Schwellwert
32 format(i3)
#
do i=1,yanz
[	for (j=1; j<=xanz; j=j+2)
	[	read(LUN,34) k
		34 format(i5)
		pixel(i,j)=k/256
		pixel(i,j+1)=k
	]	]
write(1,36)
36 format(' gelesen.')
endfile LUN
#
write(1,40) xanz,yanz
40 format(' Bildgroesse (X x Y) ',2i4,/' Bildmatrix anzeigen ? (Y/N) ')
read(1,42) char
42 format(a1)
if (char==yes)
[	jj=min0(26,xanz)
	encode(rep,50) jj
	50 format(i3)
	do i=1,3	[ fmti(i+4)=rep(i) ]
	do i=1,yanz	[ write(1,fmti) (pixel(i,j),j=1,jj) ]
	read(1,52) char
	52 format(a1)
]
return
#
#	Error Handling
#
900	write(1,902)
902	format(' nicht gefunden.')
endfile LUN
goto 1
end
#
	subroutine spoint(stx,sty)
#
# liefert den Startpunkt fuer die Triangulation.
#
integer	stx,sty			# Startpunkt-Pixelkoord.
#
write(1,10) 
10	format(' SPOINT - Startpunkt-Koord. = ')
read(1,20) stx,sty
20	format(2i3)
return
end
