home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / ADPro251-3.DMS / ADPro251-3.adf / ADProScripts.lha / ScaleToFillArea.adpro < prev    next >
Encoding:
Text File  |  1994-01-31  |  1.9 KB  |  107 lines

  1. /*
  2. ** ScaleToFillArea.adpro
  3. **
  4. ** $VER: ScaleToFillArea.adpro 1.0.0 (22.11.93)
  5. **
  6. ** This ARexx program allows the user to scale an image to fill
  7. ** a specific area, but preserving the image aspect of the original.
  8. **
  9. ** This script requires ADPro v2.5.0 (or higher).
  10. **
  11. ** Copyright © 1993 ASDG, Incorporated
  12. ** All Rights Reserved
  13. */
  14.  
  15.  
  16. ADDRESS "ADPro"
  17. OPTIONS RESULTS
  18.  
  19. NL = '0A'X
  20. SQ = '27'X
  21. DQ = '22'X
  22. TRUE  = 1
  23. FALSE = 0
  24. TempDefaults = "T:TempADProDefaults"
  25.  
  26.  
  27. /*
  28. ** Save the current environment.
  29. */
  30.  
  31. SAVE_DEFAULTS TempDefaults
  32.  
  33.  
  34. /*
  35. ** See what type of data is loaded in ADPro/MorphPlus.
  36. */
  37.  
  38. CALL "FREDSCRIPTS:FREDFunctions/CheckForRawImageData" TRUE
  39. IF (RESULT ~= 0) THEN
  40.     CALL ErrorOut 10
  41.  
  42.  
  43. /*
  44. ** Specify the area to scale to.
  45. */
  46.  
  47. XSIZE
  48. ImageWidth = ADPRO_RESULT
  49.  
  50. YSIZE
  51. ImageHeight = ADPRO_RESULT
  52.  
  53. CALL "FREDSCRIPTS:FREDFunctions/GetANumber" '"Enter area''s width"' ImageWidth 1 99999 TRUE
  54. IF (RESULT = (1-1)) THEN
  55.     CALL ErrorOut 10
  56. MaxWidth = RESULT
  57.  
  58. CALL "FREDSCRIPTS:FREDFunctions/GetANumber" '"Enter area''s height"' ImageHeight 1 99999 TRUE
  59. IF (RESULT = (1-1)) THEN
  60.     CALL ErrorOut 10
  61. MaxHeight = RESULT
  62.  
  63. IF (MaxWidth = ImageWidth) & (MaxHeight = ImageHeight) THEN DO
  64.     ADPRO_TO_FRONT
  65.     OKAY1 "No scaling to perform."
  66.     CALL ErrorOut 10
  67. END
  68.  
  69.  
  70. /*
  71. ** Perform the percent scale.
  72. */
  73.  
  74. PctWidthDiff = MaxWidth * 100 / ImageWidth
  75. PctHeightDiff = MaxHeight * 100 / ImageHeight
  76.  
  77. IF (PctWidthDiff < PctWidthHeight) THEN
  78.     PctDiff = PctWidthDiff
  79. ELSE
  80.     PctDiff = PctHeightDiff
  81.  
  82. PCT_SCALE PctDiff PctDiff
  83. IF (RC ~= 0) THEN DO
  84.     ADPRO_TO_FRONT
  85.     OKAY1 "Could not scale dimensions" || NL ||,
  86.         "by " || PctDiff || "%."
  87.     CALL ErrorOut 10
  88. END
  89.  
  90. CALL ErrorOut 0
  91.  
  92.  
  93. ErrorOut:
  94.     PARSE ARG ExitCode
  95.  
  96.     IF (EXISTS( TempDefaults )) THEN DO
  97.         LOAD_DEFAULTS TempDefaults
  98.         IF (RC ~= 0) THEN DO
  99.             ADPRO_TO_FRONT
  100.             OKAY1 "Error restoring settings."
  101.         END
  102.  
  103.         ADDRESS COMMAND "Delete >NIL:" TempDefaults
  104.     END
  105.  
  106.     EXIT ExitCode
  107.