home *** CD-ROM | disk | FTP | other *** search
- /*
- ** ScaleToSize.fred
- **
- ** $VER: ScaleToSize.fred 1.2.0 (23.10.93)
- **
- ** This program can be run from an InvokeADPro list to scale the image
- ** to a size previously defined by the user and stored in REXX clips.
- **
- ** Clips Imported:
- ** FREDDesiredWidth - Width user entered
- ** FREDDesiredHeight - Height user entered
- **
- ** NOTE: Clip names are case sensitive.
- **
- ** This script requires FRED v1.4.0 (or higher) to run. Also required is
- ** ADPro v2.5.0 (or higher).
- **
- ** Copyright © 1993 ASDG, Incorporated
- ** All Rights Reserved
- */
-
-
- ADDRESS "ADPro"
- OPTIONS RESULTS
-
- PARSE ARG FrameNum FrameFName Length LoadFlag FirstCallSeq FirstCallCell
-
- NL = '0A'X
- SQ = '27'X
- DQ = '22'X
- TRUE = 1
- FALSE = 0
-
-
- /*
- ** Get the required clips. Error if any are missing.
- */
-
- DesiredWidth = GETCLIP( "FREDDesiredWidth" )
- IF (DesiredWidth = "") THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Required clip, FREDDesiredWidth," || NL ||,
- "is not specified."
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
-
- DesiredHeight = GETCLIP( "FREDDesiredHeight" )
- IF (DesiredHeight = "") THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Required clip, FREDDesiredHeight," || NL ||,
- "is not specified."
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
-
-
- /*
- ** See what type of data is loaded in ADPro/MorphPlus.
- */
-
- CALL "FREDSCRIPTS:FREDFunctions/CheckForRawImageData" TRUE
- IF (RESULT ~= 0) THEN
- EXIT 10
-
-
- /*
- ** If the size we want to scale to is exactly half the current size,
- ** then we can gain a lot of speed by using the Halve operator instead
- ** of scaling.
- */
-
- XSIZE
- CurrentWidth = ADPRO_RESULT
-
- YSIZE
- CurrentHeight = ADPRO_RESULT
-
- IF (DesiredWidth = CurrentWidth / 2) & (DesiredHeight = CurrentHeight / 2) THEN
- OPERATOR "HALVE"
- ELSE
- ABS_SCALE DesiredWidth DesiredHeight
-
- IF (RC ~= 0) THEN DO
- Why = ADPRO_RESULT
- ADPRO_TO_FRONT
- OKAY1 "Scaling failed:" || NL ||,
- "Argument Information:" || NL ||,
- "Width = " || DesiredWidth || NL ||,
- "Height = " || DesiredHeight
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
-
-
- /*
- ** Update the clips.
- */
-
- SETCLIP( "FREDDesiredWidth", DesiredWidth )
- SETCLIP( "FREDDesiredHeight", DesiredHeight )
-
- EXIT 0
-