home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / ADPro251-3.DMS / ADPro251-3.adf / FREDScripts.lha / FREDSavers / SaveAsX.fred < prev    next >
Encoding:
Text File  |  1994-01-31  |  4.0 KB  |  165 lines

  1. /*
  2. ** SaveAsX.fred
  3. **
  4. ** $VER: SaveAsX.fred 1.1.0 (24.10.93)
  5. **
  6. ** This program can be run from an InvokeADPro list to save images in
  7. ** X format.  Including this program automatically causes a pre script
  8. ** to be executed as well (to select the X file extension).
  9. **
  10. ** It is up to the user to include the necessary scripts to create raw or
  11. ** rendered data.  This script will only try to save out what you tell it,
  12. ** and not do any error detecting regarding what type of image data is
  13. ** available.
  14. **
  15. ** Clips Imported:
  16. **    FREDXSaveType        -    Image type to save
  17. **    FREDXSaveWindowFormat     -    Type of window format to use
  18. **    FREDXFNameSelect    -    String describing how the filename
  19. **                    should be modified
  20. **    FREDXSeqFileSelect    -    Name of sequence file created
  21. **
  22. ** NOTE: Clip names are case sensitive.
  23. **
  24. ** This script requires FRED v1.4.0 (or higher) to run.  Also required is
  25. ** ADPro v2.5.0 (or higher) and Professional Conversion Pack v2.1.0
  26. ** (or higher).
  27. **
  28. ** Copyright © 1993 ASDG, Incorporated
  29. ** All Rights Reserved
  30. */
  31.  
  32.  
  33. ADDRESS "ADPro"
  34. OPTIONS RESULTS
  35.  
  36. PARSE ARG FrameNum FrameFName Length LoadFlag FirstCallSeq FirstCallCell
  37.  
  38. NL = '0A'X
  39. SQ = '27'X
  40. DQ = '22'X
  41. TRUE  = 1
  42. FALSE = 0
  43.  
  44. FrameFName = STRIP(STRIP(FrameFName , "B" , " ") , "B" , '"')
  45.  
  46.  
  47. /*
  48. ** Get the required parameters.  Error if any are missing.
  49. */
  50.  
  51. SaveType = GETCLIP( "FREDXSaveType" )
  52. IF (SaveType = "") THEN DO
  53.     ADPRO_TO_FRONT
  54.     OKAY1 "Required clip, FREDXSaveType," || NL ||,
  55.         "is not specified."
  56.     SCREEN_TO_FRONT "FRED"
  57.     EXIT 10
  58. END
  59.  
  60. SaveWindowFormat = GETCLIP( "FREDXSaveWindowFormat" )
  61. IF (SaveWindowFormat = "") THEN DO
  62.     ADPRO_TO_FRONT
  63.     OKAY1 "Required clip, FREDXSaveWindowFormat," || NL ||,
  64.         "is not specified."
  65.     SCREEN_TO_FRONT "FRED"
  66.     EXIT 10
  67. END
  68.  
  69. FNameSelect = GETCLIP( "FREDXFNameSelect" )
  70. IF (FNameSelect = "") THEN DO
  71.     ADPRO_TO_FRONT
  72.     OKAY1 "Required clip, FREDXFNameSelect," || NL ||,
  73.         "is not specified."
  74.     SCREEN_TO_FRONT "FRED"
  75.     EXIT 10
  76. END
  77.  
  78. SeqFileSelect = GETCLIP( "FREDXSeqFileSelect" )
  79. IF (SeqFileSelect = "") THEN DO
  80.     ADPRO_TO_FRONT
  81.     OKAY1 "Required clip, FREDXSeqFileSelect," || NL ||,
  82.         "is not specified."
  83.     SCREEN_TO_FRONT "FRED"
  84.     EXIT 10
  85. END
  86.  
  87.  
  88. /*
  89. ** See what type of data is loaded in ADPro/MorphPlus.
  90. */
  91.  
  92. IF (SaveType = "RAW") THEN DO
  93.     CALL "FREDSCRIPTS:FREDFunctions/CheckForRawImageData" TRUE
  94.     IF (RESULT ~= 0) THEN
  95.         EXIT 10
  96. END
  97. ELSE IF ((SaveType = "IMAGE") | (SaveType = "SCREEN")) THEN DO
  98.     CALL "FREDSCRIPTS:FREDFunctions/CheckForRenderedImageData" TRUE
  99.     IF (RESULT ~= 0) THEN
  100.         EXIT 10
  101. END
  102.  
  103.  
  104. /*
  105. ** X images cannot be in an Amiga-specific format, such as EHB, HAM, or HAM8.
  106. */
  107.  
  108. RENDER_TYPE
  109. RenderType = ADPRO_RESULT
  110. IF (RC ~= 0) THEN DO
  111.     ADPRO_TO_FRONT
  112.     OKAY1 "Error retrieving render type."
  113.     SCREEN_TO_FRONT "FRED"
  114.     EXIT 10
  115. END
  116.  
  117. IF (RenderType = "EHB") | (RenderType = "HAM") | (RenderType = "HAM8") THEN DO
  118.     ADPRO_TO_FRONT
  119.     OKAY1 RenderType || " images are not supported" || NL ||,
  120.         "as valid X files."
  121.     SCREEN_TO_FRONT "FRED"
  122.     EXIT 10
  123. END
  124.  
  125.  
  126. /*
  127. ** "DUMP"ed files can only be used with 1 bit-plane rendered data.
  128. */
  129.  
  130. IF ((SaveType = "IMAGE") | (SaveType = "SCREEN")) THEN
  131.     IF (RenderType = "2") & (SaveWindowFormat ~= "DUMP") THEN DO
  132.         ADPRO_TO_FRONT
  133.         OKAY1 "1 bit-plane rendered data" || NL ||,
  134.             "cannot be saved in " || SaveWindowFormat || " format."
  135.         SCREEN_TO_FRONT "FRED"
  136.         EXIT 10
  137.     END
  138.  
  139.  
  140. /*
  141. ** Do the save.  If we aren't using the same filename, we will use the
  142. ** same basename and make every effort possible to replace the
  143. ** perceived filename extension with the selected X extension.
  144. */
  145.  
  146. CALL "FREDSCRIPTS:FREDFunctions/ModifyFilename" FNameSelect '"'FrameFName'"' FrameNum FALSE
  147. NewFName = '"'RESULT'"'
  148.  
  149. SAVER "X" NewFName SaveType SaveWindowFormat
  150. IF (RC ~= 0) THEN DO
  151.     Why = ADPRO_RESULT
  152.     ADPRO_TO_FRONT
  153.     OKAY1 "X save failed:" || NL || Why || NL ||,
  154.         "Argument Information:" || NL ||,
  155.         "Filename = " || NewFName || NL ||,
  156.         "Type = " || SaveType || NL ||,
  157.         "Compression = " || SaveWindowFormat
  158.     SCREEN_TO_FRONT "FRED"
  159.     EXIT 10
  160. END
  161.  
  162. CALL "FREDSCRIPTS:FREDFunctions/SeqFileAppend" SeqFileSelect NewFName 1
  163.  
  164. EXIT 0
  165.