home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / utilities / propage_pdraw / donsgenies / adproscripts.lha / AnimFader.adpro < prev    next >
Encoding:
Text File  |  1993-10-21  |  7.9 KB  |  275 lines

  1. /* Program to use ADPro to make a fade from one looping anim or still image to another. Best results if palette is not locked. Uses current screen type and colour range. */
  2. /* Op5 or Op8 select added 21/10/93 */
  3. /* Written by Don Cox. Copyright. Not Public Domain */
  4.  
  5. trace r
  6.  
  7. options results
  8. address "ADPro"
  9.  
  10. lformat "UNIVERSAL"
  11. lformat1 = "UNIVERSAL" /* for changing if file is an anim */
  12. lformat2 = "UNIVERSAL"
  13. still1 = 1
  14. still2 = 1
  15. sformat "ANIM"
  16.  
  17. render_type
  18. colours = ADPro_result
  19. screen_type
  20. stype = ADPro_result
  21. gamma
  22. gammasetting = ADPro_result
  23.  
  24. getfile '"Select first file ..."'
  25. if rc~=0 then do
  26.     okay1 "No file selected"
  27.     exit
  28.     end
  29.  
  30. filename1 = ADPro_result
  31. call open("input",filename1,"R")
  32. filetype = right(readch("input",12),4)
  33. if filetype = "ANIM" then do
  34.     lformat1 = "ANIM"
  35.     still1 = 0
  36.     end
  37. call close("input")
  38.  
  39.  
  40. getnumber '"How many frames of this one?"' 32 1 1400
  41. if rc~=0 then do
  42.     okay1 "User aborted program"
  43.     exit
  44.     end
  45. frames1 = ADPro_result
  46.  
  47.  
  48. getfile '"Select second file ..."'
  49. if rc~=0 then do
  50.     okay1 "No file selected"
  51.     exit
  52.     end
  53.  
  54. filename2 = ADPro_result
  55. call open("input",filename2,"R")
  56. filetype = right(readch("input",12),4)
  57. if filetype = "ANIM" then do
  58.     lformat2 = "ANIM"
  59.     still2 = 0
  60.     end
  61. call close("input")
  62.  
  63. getnumber '"How many frames of this one?"' 32 1 1400
  64. if rc~=0 then do
  65.     okay1 "User aborted program"
  66.     exit
  67.     end
  68. frames2 = ADPro_result
  69.  
  70. getnumber '"How many frames of fade?"' 32 1 1400
  71. if rc~=0 then do
  72.     okay1 "User aborted program"
  73.     exit
  74.     end
  75. fadeframes = ADPro_result
  76. if fadeframes>frames1 then fadeframes = frames1
  77. if fadeframes>frames2 then fadeframes = frames2
  78. totalframes = frames1+frames2-fadeframes
  79. startsecond = frames1-fadeframes+1
  80. mixincrement = trunc(100/fadeframes)
  81.  
  82.  
  83. getfile '"Select destination anim..."' "ADPro:" '"test.anim"'
  84. if rc~=0 then do
  85.     okay1 "No file selected"
  86.     exit
  87.     end
  88. filename3 = ADPro_result
  89.  
  90. getnumber '"Output width (pixels)"' 320 16 1400
  91. if rc~=0 then do
  92.     okay1 "User aborted program"
  93.     exit
  94.     end
  95. width = ADPro_result
  96.  
  97. getnumber '"Output height (pixels)"' 256 16 1024
  98. if rc~=0 then do
  99.     okay1 "User aborted program"
  100.     exit
  101.     end
  102. height = ADPro_result
  103.  
  104. /* okay2 "Adjust Dynamic Range?"
  105. dyrange = rc */
  106.  
  107. okay2 "Broadcast limit?"
  108. brlimit = rc
  109.  
  110. okay2 "OpCode 8 anim?"
  111. Op8 = rc
  112. animformat = "BYTE"
  113. if Op8~=0 then animformat = "LONG"
  114.  
  115. framecount1 = 1
  116. framecount2 = 1
  117. fadeframe = 1
  118. still3 = still1 /* store the value */
  119.  
  120.     do i = 1 to (startsecond-1)   
  121.  
  122.             load_type "REPLACE"
  123.             lformat lformat1  /* set load type for file */
  124.             if still1 = 0 then do /* load new anim frames */
  125.                 load filename1 "FRAME" framecount1
  126.                 if rc ~=0 then do /* run out of frames? */
  127.                     framecount1 = 3  /* loop the anim; if your anims are non-looping, this should be 1 not 3. */
  128.                     load filename1 "FRAME" framecount1
  129.                     if rc ~=0 then leave i /* real dud load */
  130.                     end
  131.                 abs_scale width height
  132.                 render_type colours   /* number of colours  */
  133.                 screen_type stype  /* PAL/NTSC, overscan, etc */
  134.                 if brlimit ~=0 then operator "BROADCAST_LIMIT" "PAL" "DEFAULT_LIM"
  135.                 gamma gammasetting
  136.                 execute
  137.                 end
  138.  
  139.             if still1 = 1 then do  /* still picture */
  140.                 load filename1
  141.                 still1 = 3 /* no more loads needed */
  142.                 abs_scale width height
  143.                 render_type colours   /* number of colours  */
  144.                 screen_type stype  /* PAL/NTSC, overscan, etc */
  145.                 if brlimit ~=0 then operator "BROADCAST_LIMIT" "PAL" "DEFAULT_LIM"
  146.                 gamma gammasetting
  147.                 execute
  148.                 end
  149.  
  150.             save filename3 "IMAGE" "APPEND" "SMALLER" animformat /* LONG gives Anim-8 format */
  151.             if rc~=0 then do
  152.                 okay1 '"Trouble saving file "filename3'
  153.                 exit
  154.                 end
  155.  
  156.  
  157.             framecount1 = framecount1+1
  158.     end  /* pre-fade section */
  159.  
  160.  
  161. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  162.  
  163. still1 = still3 /* restore value */
  164.  
  165. do i = startsecond to frames1     /* fading section */
  166.   
  167.         load_type "REPLACE"
  168.         lformat lformat2
  169.         if still2 = 0 then do 
  170.             load filename2 "FRAME" framecount2
  171.             if rc ~=0 then do /* run out of frames? */
  172.                 framecount2 = 3  /* loop the anim, or repeat still */
  173.                 load filename2 "FRAME" framecount2
  174.                 if rc ~=0 then leave i /* real dud load */
  175.                 end
  176.             end
  177.         else load filename2
  178.         abs_scale width height
  179.         testvalue = rc
  180.  
  181.         sformat "IFF"  /* save it for a moment */
  182.         save "adpro:temp.pic" "RAW"
  183.         if rc~=0 then do
  184.             okay1 '"Trouble saving temporary file."'
  185.             exit
  186.             end
  187.         sformat "ANIM"
  188.  
  189.         load_type "REPLACE"
  190.         lformat lformat1
  191.         if still1 = 0 then do
  192.             load filename1 "FRAME" framecount1  /* anim */
  193.             if rc ~=0 then do /* run out of frames? */
  194.                 framecount1 = 3  /* loop the anim, or repeat still */
  195.                 load filename1 "FRAME" framecount1
  196.                 if rc ~=0 then leave i /* real dud load */
  197.                 end
  198.             end
  199.         else load filename1  /* still */
  200.  
  201.         abs_scale width height
  202.     testvalue = rc
  203.         mix = mixincrement*fadeframe
  204.         if mix>100 then mix = 100
  205.         load_type "COMPOSE"  /* now bring back the other picture */
  206.         loader "IFF" "adpro:temp.pic" 0 0 mix
  207.  
  208.         render_type colours   /* number of colours  */
  209.         screen_type stype  /* PAL/NTSC, overscan, etc */
  210.         if brlimit ~=0 then operator "BROADCAST_LIMIT" "PAL" "DEFAULT_LIM"
  211.         gamma gammasetting
  212.         execute
  213.         save filename3 "IMAGE" "APPEND" "SMALLER" animformat /* LONG gives Anim-8 format */
  214.         if rc~=0 then do
  215.             okay1 '"Trouble saving file "filename3'
  216.             exit
  217.             end
  218.         framecount2 = framecount2+1
  219.         framecount1 = framecount1+1
  220.         fadeframe = fadeframe+1
  221.         end   /* fade section */
  222.  
  223.  
  224. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  225.  
  226. lformat lformat2
  227. load_type "REPLACE"
  228.  
  229. do i = frames1+1 to totalframes  /* section after fade */
  230.             if still2 = 0 then do
  231.                   load filename2 "FRAME" framecount2
  232.                 if rc ~=0 then do /* run out of frames? */
  233.                     framecount2 = 3  /* loop the anim, or repeat still */
  234.                     load filename2 "FRAME" framecount2
  235.                     if rc ~=0 then leave i /* real dud load */
  236.                     end
  237.  
  238.                 abs_scale width height
  239.                 render_type colours   /* number of colours  */
  240.                 screen_type stype  /* PAL/NTSC, overscan, etc */
  241.                 if brlimit ~=0 then operator "BROADCAST_LIMIT" "PAL" "DEFAULT_LIM"
  242.                 gamma gammasetting
  243.                 execute
  244.                 end  /* still2 = 0 */
  245.  
  246.             if still2 = 1 then do  /* still picture */
  247.                 load filename2
  248.                 still2 = 3 /* no more loads needed */
  249.                 abs_scale width height
  250.                 render_type colours   /* number of colours  */
  251.                 screen_type stype  /* PAL/NTSC, overscan, etc */
  252.                 if brlimit ~=0 then operator "BROADCAST_LIMIT" "PAL" "DEFAULT_LIM"
  253.                 gamma gammasetting
  254.                 execute
  255.                 end
  256.  
  257.             save filename3 "IMAGE" "APPEND" "SMALLER" animformat /* LONG gives Anim-8 format */
  258.             if rc~=0 then do
  259.                 okay1 '"Trouble saving file "filename3'
  260.                 exit
  261.                 end
  262.  
  263.             framecount2 = framecount2+1
  264.             end   /* section after fade */
  265.  
  266.  
  267. save filename3 "IMAGE" "WRAPUP"  /* looping closedown */
  268. lformat "UNIVERSAL"
  269.  
  270. address command
  271. "delete >nil: ADPro:temp.pic"
  272. exit
  273. end
  274.  
  275.