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

  1. /*
  2. ** ScaleToPixelAspect.fred
  3. **
  4. ** $VER: ScaleToPixelAspect.fred 1.1.0 (23.10.93)
  5. **
  6. ** This program can be run from an InvokeADPro list to scale the image
  7. ** to a specific pixel aspect.
  8. **
  9. ** Clips Imported:
  10. **    FREDScaleToXAspect    -    X Aspect user entered
  11. **    FREDScaleToYAspect    -    Y Aspect user entered
  12. **
  13. ** NOTE: Clip names are case sensitive.
  14. **
  15. ** This script requires FRED v1.4.0 (or higher) to run.  Also required is
  16. ** ADPro v2.5.0 (or higher).
  17. **
  18. ** Copyright © 1993 ASDG, Incorporated
  19. ** All Rights Reserved
  20. */
  21.  
  22.  
  23. ADDRESS "ADPro"
  24. OPTIONS RESULTS
  25.  
  26. PARSE ARG FrameNum FrameFName Length LoadFlag FirstCallSeq FirstCallCell
  27.  
  28. NL = '0A'X
  29. SQ = '27'X
  30. DQ = '22'X
  31. TRUE  = 1
  32. FALSE = 0
  33.  
  34.  
  35. /*
  36. ** Get the required clips.  Error if any are missing.
  37. */
  38.  
  39. DesiredXAspect = GETCLIP( "FREDScaleToXAspect" )
  40. IF (DesiredXAspect = "") THEN DO
  41.     ADPRO_TO_FRONT
  42.     OKAY1 "Required clip, FREDScaleToXAspect," || NL ||,
  43.         "is not specified."
  44.     SCREEN_TO_FRONT "FRED"
  45.     EXIT 10
  46. END
  47.  
  48. DesiredYAspect = GETCLIP( "FREDScaleToYAspect" )
  49. IF (DesiredYAspect = "") THEN DO
  50.     ADPRO_TO_FRONT
  51.     OKAY1 "Required clip, FREDScaleToYAspect," || NL ||,
  52.         "is not specified."
  53.     SCREEN_TO_FRONT "FRED"
  54.     EXIT 10
  55. END
  56.  
  57.  
  58. /*
  59. ** See what type of data is loaded in ADPro/MorphPlus.
  60. */
  61.  
  62. CALL "FREDSCRIPTS:FREDFunctions/CheckForRawImageData" TRUE
  63. IF (RESULT ~= 0) THEN
  64.     EXIT 10
  65.  
  66.  
  67. /*
  68. ** Scale to desired pixel aspect.
  69. */
  70.  
  71. OPERATOR "DEFINE_PXL_ASPECT"
  72. IF (RC ~= 0) THEN DO
  73.     ADPRO_TO_FRONT
  74.     OKAY1 "Could not get current pixel aspect"
  75.     SCREEN_TO_FRONT "FRED"
  76.     EXIT 10
  77. END
  78.  
  79. XAspect = WORD( ADPRO_RESULT, 1 )
  80. YAspect = WORD( ADPRO_RESULT, 2 )
  81.  
  82. IF (XAspect = DesiredXAspect) & (YAspect = DesiredYAspect) THEN
  83.     EXIT 0
  84.  
  85.  
  86. /*
  87. ** Always scale UP
  88. */
  89.  
  90. OriginalAspect = XAspect / YAspect
  91. NewAspect = DesiredXAspect / DesiredYAspect
  92.  
  93. IF (OriginalAspect = NewAspect) THEN    /* Exit, if no scaling necessary */
  94.     EXIT 0
  95.  
  96. ScaleX = OriginalAspect / NewAspect
  97. ScaleY = 1.0 / ScaleX
  98.  
  99. IF (ScaleX >= 1.0) THEN DO
  100.     PCT_SCALE TRUNC( ScaleX * 100 ) 100
  101.     IF (RC ~= 0) THEN DO
  102.         ADPRO_TO_FRONT
  103.         OKAY1 "Scale X up failed."
  104.         SCREEN_TO_FRONT "FRED"
  105.         EXIT 10
  106.     END
  107. END
  108. ELSE DO
  109.     PCT_SCALE 100 TRUNC( ScaleY * 100 )
  110.     IF (RC ~= 0) THEN DO
  111.         ADPRO_TO_FRONT
  112.         OKAY1 "Scale Y up failed."
  113.         SCREEN_TO_FRONT "FRED"
  114.         EXIT 10
  115.     END
  116. END
  117.  
  118. OPERATOR "DEFINE_PXL_ASPECT" DesiredXAspect DesiredYAspect
  119.  
  120. EXIT 0
  121.