AuthorMessage
Meka][Meka
Unstopable
Posts: 700

The following is an example of how to place a series of CT images into a single file of compressed images.  Once the output file is created, a script is placed in the image file. When the file is loaded into the viewer, The images are de-compressed into individual files and loaded into the viewer for normal viewing/processing.
Procedure:
1) The user loads the desired images into the viewer
2) The  CTSET.imp  script file is run from the viewer.
3) The user specifies the output file and the images are compressed into the file.
4) The script file: OPENCTSET.imp  is placed into the output file and the operation is completed.
5) When the file is loaded into a viewer at a later time (perhaps after being sent as an E-Mail attachment) the original files are decompressed into temporary files and loaded into the viewer.
Contents of CTSET.IMP:
Code:

$cfile = $temppath "\ctemp.img"
a = 0
loop begin 4096
 memory(a) = 0
 a = a + 1
loop end
$listq = $temppath "\filelist.q"
input_file $listq
finput inum
finput inum
allocate 1000000
a = 0
loop begin 4096
 memory(a) = 0
 a = a + 1
loop end
$mfile = "*.set"
getfile $mfile "Select an Output file"
memory(20) = inum
delete $mfile
open $mfile int
write 0 4096 0
 
idx = 2048
offset = 4096
tot = 1
*Main
 finput $infile
 compress -300 $infile $cfile
 getfilesize size $cfile
 memory(idx) = offset
 memory(idx + 256) = size
 idx = idx + 1
 kb = round(offset / 1024)
 message "Image Set Build: " tot " - " kb " KBytes"
 tot = tot + 1
 
 open $cfile byt
 read 4096 size 0
 open $mfile byt
 write 4096 size offset
 offset = offset + size
inum = inum - 1
if inum > 0
  goto Main
endif
open $mfile flt
write 2048 512 512
$script = $basedir "\scripts\auto\openctset.imp"
getfilesize size $script
open $script byt
read 0 size 0
open $mfile byt
write 0 size 80
message "Ready..."
exit

Contents of OPENCTSET.IMP:
Code:

autoscript
$ofile = $temppath "\set-01.img"
$list = $temppath "\filelist.q"
allocate 1000000
open $imagefile int
read 0 1 20
inum = memory(0)
open $imagefile flt
read 0 512 512
idx = 0
delete $list
print_file $list
fprint inum
fprint inum
viewer writeback on
viewer notify
a = 1
tot = inum
*Main
 message "Loading Image Set: " a " of " tot
 a = a + 1
 offset = memory(idx)
 size = memory(idx + 256)
 idx = idx + 1
 open $imagefile byt
 read 1024 size offset
 open $ofile byt
 write 1024 size 0
 open null
 fprint $ofile
 viewer display $ofile
 viewer notify
 nextfile $ofile
inum = inum - 1
if inum > 0
 goto Main
endif
viewer loadlist $list
viewer prior
viewer notify
message "Ready..."
exit