home *** CD-ROM | disk | FTP | other *** search
- /*
- ** ScaleToPixelAspect.fred
- **
- ** $VER: ScaleToPixelAspect.fred 1.1.0 (23.10.93)
- **
- ** This program can be run from an InvokeADPro list to scale the image
- ** to a specific pixel aspect.
- **
- ** Clips Imported:
- ** FREDScaleToXAspect - X Aspect user entered
- ** FREDScaleToYAspect - Y Aspect 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.
- */
-
- DesiredXAspect = GETCLIP( "FREDScaleToXAspect" )
- IF (DesiredXAspect = "") THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Required clip, FREDScaleToXAspect," || NL ||,
- "is not specified."
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
-
- DesiredYAspect = GETCLIP( "FREDScaleToYAspect" )
- IF (DesiredYAspect = "") THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Required clip, FREDScaleToYAspect," || 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
-
-
- /*
- ** Scale to desired pixel aspect.
- */
-
- OPERATOR "DEFINE_PXL_ASPECT"
- IF (RC ~= 0) THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Could not get current pixel aspect"
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
-
- XAspect = WORD( ADPRO_RESULT, 1 )
- YAspect = WORD( ADPRO_RESULT, 2 )
-
- IF (XAspect = DesiredXAspect) & (YAspect = DesiredYAspect) THEN
- EXIT 0
-
-
- /*
- ** Always scale UP
- */
-
- OriginalAspect = XAspect / YAspect
- NewAspect = DesiredXAspect / DesiredYAspect
-
- IF (OriginalAspect = NewAspect) THEN /* Exit, if no scaling necessary */
- EXIT 0
-
- ScaleX = OriginalAspect / NewAspect
- ScaleY = 1.0 / ScaleX
-
- IF (ScaleX >= 1.0) THEN DO
- PCT_SCALE TRUNC( ScaleX * 100 ) 100
- IF (RC ~= 0) THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Scale X up failed."
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
- END
- ELSE DO
- PCT_SCALE 100 TRUNC( ScaleY * 100 )
- IF (RC ~= 0) THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Scale Y up failed."
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
- END
-
- OPERATOR "DEFINE_PXL_ASPECT" DesiredXAspect DesiredYAspect
-
- EXIT 0
-