home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / arexx / scripti.lha / 3-DEE / Scripti / Composition / Morph.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1993-05-19  |  3.9 KB  |  171 lines

  1. /*
  2. -----------------------------------------------------------------------------
  3. This AREXX-Script will morph any image by any number of frames to any image.
  4. The endmorph-image and the number of frames must be specified by the user 
  5.        in the arguments .
  6. Warning! The number of colors is determined by the 2nd argument!
  7.  
  8. Host address: ADPro (Art Department Professional   ®ASDG)
  9. Written by Jan Van Overbeke, 3-DEE, ©1993.
  10. Read the AREXX-Scripti doc, for more information about operation and rights!
  11. -----------------------------------------------------------------------------
  12. */
  13.  
  14. arg filename endmorphname frames
  15. if ~exists(filename)|filename='' then do
  16.     say 'Unable to find the image !!'
  17.     say 'See Ya...'
  18.     say ''
  19.     exit
  20.     end
  21.  
  22. /* ---- If the 2nd argument does not have a path, ---- */
  23. /* ----        we'll have to give it one.         ---- */
  24. /* --------------------------------------------------- */
  25. endmorph=endmorphname
  26. if pos('/',endmorphname)=0 & pos(':',endmorphname)=0 then do
  27.     endpath=lastpos('/',filename)
  28.     if endpath=0 then endpath=lastpos(':',filename)
  29.     endmorph=delstr(filename,endpath+1)||endmorphname
  30.     end
  31.  
  32. if ~exists(endmorph) then do
  33.     say 'Unable to find the endmorph image.'
  34.     say 'End of program.'
  35.     say ''
  36.     exit
  37.     end
  38. if frames<1|frames>9999 then do
  39.     say 'Invalid argument: frames out of range.'
  40.     say 'See Ya......'
  41.     say ''
  42.     exit
  43.     end
  44.  
  45. options results
  46. address 'ADPro'
  47. say 'Morph: Written by JAN VAN OVERBEKE, 3-DEE, ©1993'
  48. say 'Image: 'filename
  49. say 'Endmorph: 'endmorph
  50. say 'Frames-in-between: 'frames
  51. say 'SAVE: IFF Original Colors of the endmorph (!)'
  52. say ''
  53.  
  54. SFORMAT "IFF"
  55. if RC~=0 then do
  56.     say 'Unable to select the IFF saver!'
  57.     say 'See Ya......'
  58.     say ''
  59.     exit
  60.     end
  61.  
  62. LFORMAT "UNIVERSAL"
  63. if RC ~=0 then do
  64.     say 'Unable to select the UNIVERSAL loader.'
  65.     say 'See Ya...'
  66.     say ''
  67.     exit
  68.     end
  69.  
  70. /* ---- One test needs one load! ---- */
  71. /* ---------------------------------- */
  72. percent=trunc(100/(frames+1))
  73. say 'Loading1 for 'percent'%.........'
  74. first='ok'
  75. load endmorph
  76. if RC~=0 then do
  77.     say 'Unable to load the enmorph!'
  78.     say 'See Ya......'
  79.     say ''
  80.     exit
  81.     end
  82.  
  83. /* ---- Get some info about image: 24Bit? Gray? ---- */
  84. /* ------------------------------------------------- */
  85. IMAGE
  86. help=ADPRO_RESULT
  87. dontrender='ok'
  88. graymode='no'
  89. if pos('Rendered',help)>0 | pos('BITPLANE',help)>0 then dontrender='nok'
  90. if pos('GRAY',help)>0 then graymode='yes'
  91. render_type
  92. colors=ADPRO_RESULT
  93.  
  94. do t=1 to frames
  95.     percent=trunc(t*100/(frames+1))
  96.  
  97.     if first='nok' then do
  98.         say 'Loading1 for 'percent'%.........'
  99.         LOAD endmorph
  100.         if RC ~=0 then do
  101.             say 'Had some problems while loading the endmorph.'
  102.             say 'See Ya...'
  103.             say ''
  104.             exit
  105.             end
  106.         end
  107.     first='nok'
  108.  
  109.     /* ---- ADPro doesn't allow to overlay color on gray ---- */
  110.     /* ------------------------------------------------------ */
  111.     if graymode='yes' then do
  112.         say 'Setting Color data.....'
  113.         operator Gray_To_Color
  114.         if RC~=0 then do
  115.             say 'Gray_To_Color failed!!!'
  116.             say 'See Ya.....'
  117.             say ''
  118.             exit
  119.             end
  120.         end
  121.  
  122.     say 'Loading 2ndPart....'
  123.     LOAD filename 0 0 percent -1 -1 -1
  124.     if RC ~=0 then do
  125.         say 'Had some problems while loading the image.'
  126.         say 'See Ya.'
  127.         say ''
  128.         exit
  129.         end
  130.  
  131.     /* ---- Make the palette fit the image ---- */
  132.     /* ----     and render a new one       ---- */
  133.     /* ----       if we do need one        ---- */
  134.     /* ---------------------------------------- */
  135.     if dontrender='nok' then do
  136.         say 'Converting......'
  137.         savemode='IMAGE'
  138.         render_type colors
  139.         palette=0
  140.         if colors='HAM' then palette=16
  141.         if colors='HAM8' then palette=64
  142.         if palette=0 then palette=colors
  143.         ptotal palette
  144.         pused palette
  145.         execute
  146.         if RC ~= 0 then do
  147.             say 'Execute failed.'
  148.             say 'See Ya...'
  149.             say ''
  150.             exit
  151.             end
  152.         say 'Saving IMAGE 'colors'.....'
  153.         end
  154.         else do
  155.             savemode='RAW'
  156.             say 'Saving RAW......'
  157.              end
  158.  
  159.     say ''
  160.     dest=filename'.'percent'%'
  161.     SAVE dest savemode
  162.     if RC~=0 then do
  163.         say 'Problems while saving: NOT SAVED.'
  164.         say 'See Ya...'
  165.         say ''
  166.         exit
  167.         end
  168. end
  169. say ''
  170. exit
  171.