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

  1. /*
  2. ** ScaleToSize.fred
  3. **
  4. ** $VER: ScaleToSize.fred 1.2.0 (23.10.93)
  5. **
  6. ** This program can be run from an InvokeADPro list to scale the image
  7. ** to a size previously defined by the user and stored in REXX clips.
  8. **
  9. ** Clips Imported:
  10. **    FREDDesiredWidth    -    Width user entered
  11. **    FREDDesiredHeight    -    Height 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. DesiredWidth = GETCLIP( "FREDDesiredWidth" )
  40. IF (DesiredWidth = "") THEN DO
  41.     ADPRO_TO_FRONT
  42.     OKAY1 "Required clip, FREDDesiredWidth," || NL ||,
  43.         "is not specified."
  44.     SCREEN_TO_FRONT "FRED"
  45.     EXIT 10
  46. END
  47.  
  48. DesiredHeight = GETCLIP( "FREDDesiredHeight" )
  49. IF (DesiredHeight = "") THEN DO
  50.     ADPRO_TO_FRONT
  51.     OKAY1 "Required clip, FREDDesiredHeight," || 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. ** If the size we want to scale to is exactly half the current size,
  69. ** then we can gain a lot of speed by using the Halve operator instead
  70. ** of scaling.
  71. */
  72.  
  73. XSIZE
  74. CurrentWidth = ADPRO_RESULT
  75.  
  76. YSIZE
  77. CurrentHeight = ADPRO_RESULT
  78.  
  79. IF (DesiredWidth = CurrentWidth / 2) & (DesiredHeight = CurrentHeight / 2) THEN
  80.     OPERATOR "HALVE"
  81. ELSE
  82.     ABS_SCALE DesiredWidth DesiredHeight
  83.  
  84. IF (RC ~= 0) THEN DO
  85.     Why = ADPRO_RESULT
  86.     ADPRO_TO_FRONT
  87.     OKAY1 "Scaling failed:" || NL ||,
  88.         "Argument Information:" || NL ||,
  89.         "Width = " || DesiredWidth || NL ||,
  90.         "Height = " || DesiredHeight
  91.     SCREEN_TO_FRONT "FRED"
  92.     EXIT 10
  93. END
  94.  
  95.  
  96. /*
  97. ** Update the clips.
  98. */
  99.  
  100. SETCLIP( "FREDDesiredWidth", DesiredWidth )
  101. SETCLIP( "FREDDesiredHeight", DesiredHeight )
  102.  
  103. EXIT 0
  104.