/* ** ScaleANIM.adpro ** ** $VER: ScaleANIM.adpro 1.3.1 (17.1.94) ** ** This AREXX program will take an existing ANIM file and scale ** its frames to the users specifications. ** ** This script requires ADPro v2.5.0 (or higher). ** ** Copyright © 1990-1994 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 PSTATUS "UNLOCKED" /* ** Select the file to scale. */ CALL "FREDSCRIPTS:FREDFunctions/GetAFile" '"Enter ANIM To Scale"' '"ADPRO:"' '""""' TRUE IF (RESULT = DQ||DQ) THEN DO ADPRO_TO_FRONT OKAY1 "Error, no source ANIM specified." CALL ErrorOut 10 END SrcANIMFName = RESULT CALL "FREDSCRIPTS:FREDFunctions/GetAFile" '"Enter name of ANIM file to create"' '"ADPRO:"' '""""' TRUE IF (RESULT = DQ||DQ) THEN DO ADPRO_TO_FRONT OKAY1 "Error, no dest ANIM specified." CALL ErrorOut 10 END DestANIMFName = RESULT IF (EXISTS( DestANIMFName )) THEN DO ADPRO_TO_FRONT OKAYN '"CropANIM"' '"Truncate destination ANIM?"' '"Start New File|Append To File|Cancel"' IF (RC = 0) THEN DO CALL ErrorOut 10 END ELSE IF (RC = 1) THEN DO IMAGE_TYPE ImageType = ADPRO_RESULT IF (WORD( ImageType, 1 ) = "NONE") THEN DO LOADER "BACKDROP" "XXX" "WIDTH" 10 "HEIGHT" 10 "COLOR" IF (RC ~= 0) THEN DO ADPRO_TO_FRONT OKAY1 "Unable to create temp image." || NL ||, "Argument Information:" || NL||, "Width = " || 10 || NL ||, "Height = " || 10 || NL ||, "Type = " || "COLOR" CALL ErrorOut 10 END END IF (WORD( ImageType, 1 ) ~= "BITPLANE") THEN DO EXECUTE IF (RC ~= 0) THEN DO ADPRO_TO_FRONT OKAY1 "Unable to create temp rendered data." CALL ErrorOut 10 END END SAVER "ANIM" DestANIMFName "IMAGE" "QUIT" IF (RC ~= 0) THEN DO ADPRO_TO_FRONT OKAY1 "Could not close current ANIM file." || NL ||, "Argument Information:" || NL ||, "Filename = " || DestANIMFName || NL ||, "Type = " || "IMAGE" || NL ||, "Flags = " || "QUIT" CALL ErrorOut 10 END ADDRESS COMMAND "Delete >NIL:" DestANIMFName END END LOADER "ANIM" SrcANIMFName "COUNT" IF (RC ~= 0) THEN DO ADPRO_TO_FRONT OKAY1 "Can't find ANIM file." CALL ErrorOut 10 END NumFrames = ADPRO_RESULT /* ** Ask which frames to process. */ CALL "FREDSCRIPTS:FREDFunctions/GetANumber" '"Starting frame"' 1 1 NumFrames TRUE StartFrame = RESULT IF (StartFrame = (1-1)) THEN CALL ErrorOut 10 CALL "FREDSCRIPTS:FREDFunctions/GetANumber" '"Ending frame"' NumFrames StartFrame NumFrames TRUE EndFrame = RESULT IF (EndFrame = (StartFrame-1)) THEN CALL ErrorOut 10 XSIZE ImageWidth = ADPRO_RESULT YSIZE ImageHeight = ADPRO_RESULT CALL "FREDSCRIPTS:FREDFunctions/FileOnly" SrcANIMFName srcANIMNodeName = RESULT str = "ANIM:" srcANIMNodeName || NL || "(" || ImageWidth "x" ImageHeight || ")" ADPRO_TO_FRONT OKAYN '"ScaleANIM"' '"'str'"' '"Scale ANIM|Cancel"' IF (RC = 0) THEN DO CALL ErrorOut 10 END CALL "FREDSCRIPTS:FREDFunctions/GetANumber" '"New width (0 = same)"' 0 0 10000 TRUE xRes = RESULT IF (xRes = (0-1)) THEN CALL ErrorOut 10 CALL "FREDSCRIPTS:FREDFunctions/GetANumber" '"New height (0 = same)"' 0 0 10000 TRUE yRes = RESULT IF (yRes = (0-1)) THEN CALL ErrorOut 10 IF (xRes = 0) & (yRes = 0) THEN CALL ErrorOut 0 LOADER "ANIM" SrcANIMFName "FRAME" 1 IF (RC ~= 0) THEN DO ADPRO_TO_FRONT OKAY1 "Cannot find source anim." CALL ErrorOut 10 END PSTATUS "LOCKED" SCREEN_TYPE oldSType = ADPRO_RESULT SCREEN_TYPE ADPRO_RESULT IF (xRes = 0) THEN xRes = ImageWidth IF (yRes = 0) THEN yRes = ImageHeight num = StartFrame continue = FALSE DO WHILE (continue = FALSE) LOADER "ANIM" SrcANIMFName "FRAME" num IF (RC ~= 0) THEN DO ADPRO_TO_FRONT OKAY1 "Error during load" || NL ||, "of frame " || num || "." CALL ErrorOut 10 END ABS_SCALE xRes yRes IF (RC ~= 0) THEN DO ADPRO_TO_FRONT OKAY1 "Error scaling image data" || NL ||, "to" xRes "x" yRes CALL ErrorOut 10 END EXECUTE IF (RC ~= 0) THEN DO ADPRO_TO_FRONT OKAY1 "Error creating rendered data." CALL ErrorOut 10 END SAVER "ANIM" DestANIMFName "APPEND" "IMAGE" IF (RC ~= 0) THEN DO OKAY1 "Error during load" || NL ||, "of frame " || num || "." CALL ErrorOut 10 END num = num + 1 IF (num > EndFrame) THEN continue = TRUE END SAVER "ANIM" dest "QUIT" "IMAGE" IF (RC ~= 0) THEN DO ADPRO_TO_FRONT OKAY1 "Error closing dest anim." CALL ErrorOut 10 END CALL ErrorOut 0 ErrorOut: PARSE ARG ExitCode IF (EXISTS( SrcANIMFName )) & (ErrorCode ~= 0) THEN DO LOADER "ANIM" SrcANIMFName "QUIT" IF (RC ~= 0) THEN DO ADPRO_TO_FRONT OKAY1 "Error closing source ANIM:" || NL ||, SrcANIMFName || NL || NL ||, "You need to close it" || NL ||, "manually." END END IF (EXISTS( DestANIMFName )) & (ErrorCode ~= 0) THEN DO SAVER "ANIM" DestANIMFName "IMAGE" "QUIT" IF (RC ~= 0) THEN DO ADPRO_TO_FRONT OKAY1 "Error closing dest ANIM:" || NL ||, DestANIMFName || NL || NL ||, "You need to close it" || NL ||, "manually." END END 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