home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Science / Science.zip / goat006.zip / SRC.ZIP / goatsrc / SubProcs / openimage < prev    next >
Text File  |  2002-08-17  |  2KB  |  65 lines

  1. imagefilename = VpFileDialog(window,'OPEN',filetypes,'GOAT - Open Image File')
  2.  
  3. if length(imagefilename) > 0 then
  4.   do
  5.     imagefileexist=stream(imagefilename,'C','QUERY EXISTS')
  6.     parse upper value imagefileexist with,
  7.     pathandimagename'.'ext
  8.     value=filespec("name",imagefileexist)
  9.     parse upper value value with,
  10.       imagename'.'ext
  11.   end
  12.   else
  13.     imagefileexist=''
  14.  
  15. imagetype=0
  16. Do i=1 to 25 
  17.   if word(extensions, i) = translate(ext) then
  18.     Do
  19.       if translate(ext)='PNM' then
  20.         /* need to use pnmtotiff */
  21.         imagetype=2
  22.       /* everything else is internal */
  23.       else imagetype=1
  24.     End
  25. End
  26. drop i
  27. IF (LENGTH(imagefileexist) > 0) & (imagetype=1 | imagetype=2) THEN
  28.   do
  29.     if imagetype=2 then
  30.       do
  31.         convertimage=1
  32.         pnmtotiff imagefilename||' > '||imagename||'_TMP.TIF'||' 2>>error.log'
  33.         imagefilename=imagename||'_TMP.TIF'
  34.       end
  35.       else convertimage=0
  36.     /* Load image from file 1000 Image Editor */
  37.     CALL VpImgEdt window,1000,'LOAD',imagefilename,''
  38.     imageattributes=VpImgEdt(window, 1000, 'GETBMPATTRIBUTES')
  39.       parse var imageattributes imagex imagey numcolors
  40.     if numcolors <> 0 then
  41.       Call VpImgEdt window, 1000, 'SETBMPATTRIBUTES', x, y, 65536
  42.     /* Set changed flag off 1000 Image Editor */
  43.     CALL VpImgEdt window,1000,'RESETCHANGED'
  44.     /* Get the zoom level value */
  45.     zoomlevel=VpImgEdt(window, 1000, 'GETZOOM')
  46.     /* set the title to include the image name */
  47.     CALL VpWindow window,'SETTITLE','GOAT - '||imagename||'.'||ext
  48.     if imageautorun=1 then
  49.       call externalimageeditor
  50.   end
  51.   else
  52.     do
  53.       if (length(imagefileexist) > 0) & imagetype=0 then
  54.         response=vpmessagebox(window,'Unknown Format','The File Format Is unknown')
  55.       else
  56.         if (length(imagefileexist) = 0) & (length(imagefilename) > 0) then
  57.           response=vpmessagebox(window,'File Not Found','The File Was not Found')
  58.     end
  59.  
  60. rc=vpimgedt(window,1000,'RESETDISABLEUNDO')
  61.  
  62. /* rc=vpimgedt(window,1000,'GETDISABLEUNDO')
  63. say rc */
  64.  
  65.