home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
historic
/
v941.tgz
/
icon.v941src.tar
/
icon.v941src
/
ipl
/
gprocs
/
imagedim.icn
< prev
next >
Wrap
Text File
|
2001-05-02
|
2KB
|
65 lines
############################################################################
#
# File: imagedim.icn
#
# Subject: Procedures for getting image dimensions
#
# Author: Ralph E. Griswold
#
# Date: May 2, 2001
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# imagedim(s) returns a record that contains the type and dimensions of an
# image named s.
#
# The assumptions about image formats are naive.
#
############################################################################
#
# Requires: Version 9 graphics
#
############################################################################
record idim(type, w, h)
procedure imagedim(s)
local Image, line, dim
Image := open(s) | stop("*** cannot open ", s)
line := read(Image) | idim_bad()
line ? {
if tab(find("width") + 6) then {
dim := idim("xbm")
dim.w := integer(tab(0)) | idim_bad()
read(Image) ? {
tab(find("height") + 7) | idim_bad()
dim.h := integer(tab(0)) | idim_bad()
} | idim_bad()
}
else if find("XPM") then {
dim := idim("xpm")
read(Image) | idim_bad()
read(Image) ? {
="\"" & dim.w := integer(tab(many(&digits))) &
=" " & dim.h := integer(tab(many(&digits)))
} | idim_bad()
}
}
# close(Image)
return dim
end
procedure idim_bad()
stop("*** bad image data")
end