home *** CD-ROM | disk | FTP | other *** search
- /*
- ** ScaleToFillArea.adpro
- **
- ** $VER: ScaleToFillArea.adpro 1.0.0 (22.11.93)
- **
- ** This ARexx program allows the user to scale an image to fill
- ** a specific area, but preserving the image aspect of the original.
- **
- ** This script requires ADPro v2.5.0 (or higher).
- **
- ** Copyright © 1993 ASDG, Incorporated
- ** All Rights Reserved
- */
-
-
- ADDRESS "ADPro"
- OPTIONS RESULTS
-
- NL = '0A'X
- SQ = '27'X
- DQ = '22'X
- TRUE = 1
- FALSE = 0
- TempDefaults = "T:TempADProDefaults"
-
-
- /*
- ** Save the current environment.
- */
-
- SAVE_DEFAULTS TempDefaults
-
-
- /*
- ** See what type of data is loaded in ADPro/MorphPlus.
- */
-
- CALL "FREDSCRIPTS:FREDFunctions/CheckForRawImageData" TRUE
- IF (RESULT ~= 0) THEN
- CALL ErrorOut 10
-
-
- /*
- ** Specify the area to scale to.
- */
-
- XSIZE
- ImageWidth = ADPRO_RESULT
-
- YSIZE
- ImageHeight = ADPRO_RESULT
-
- CALL "FREDSCRIPTS:FREDFunctions/GetANumber" '"Enter area''s width"' ImageWidth 1 99999 TRUE
- IF (RESULT = (1-1)) THEN
- CALL ErrorOut 10
- MaxWidth = RESULT
-
- CALL "FREDSCRIPTS:FREDFunctions/GetANumber" '"Enter area''s height"' ImageHeight 1 99999 TRUE
- IF (RESULT = (1-1)) THEN
- CALL ErrorOut 10
- MaxHeight = RESULT
-
- IF (MaxWidth = ImageWidth) & (MaxHeight = ImageHeight) THEN DO
- ADPRO_TO_FRONT
- OKAY1 "No scaling to perform."
- CALL ErrorOut 10
- END
-
-
- /*
- ** Perform the percent scale.
- */
-
- PctWidthDiff = MaxWidth * 100 / ImageWidth
- PctHeightDiff = MaxHeight * 100 / ImageHeight
-
- IF (PctWidthDiff < PctWidthHeight) THEN
- PctDiff = PctWidthDiff
- ELSE
- PctDiff = PctHeightDiff
-
- PCT_SCALE PctDiff PctDiff
- IF (RC ~= 0) THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Could not scale dimensions" || NL ||,
- "by " || PctDiff || "%."
- CALL ErrorOut 10
- END
-
- CALL ErrorOut 0
-
-
- ErrorOut:
- PARSE ARG ExitCode
-
- IF (EXISTS( TempDefaults )) THEN DO
- LOAD_DEFAULTS TempDefaults
- IF (RC ~= 0) THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Error restoring settings."
- END
-
- ADDRESS COMMAND "Delete >NIL:" TempDefaults
- END
-
- EXIT ExitCode
-