/* v0.01 RunHook Marko Seppänen marko.seppanen@wwnet.fi */ address IMAGEENGINEER Options results tempfile = 't:Image_from_IE' tempfile2 = 't:Image_from_ImageFX' if arg()=0 then exit pic=arg(1) MARK pic PRIMARY PROJECT_INFO pic WIDTH origpicwidth=result PROJECT_INFO pic HEIGHT origpicheight=result PROJECT_INFO pic ZOOM origzoomval=result /* Export */ if ~show(ports,'IMAGEFX.1') then do 'REQUEST' '"Could not locate Arexx-port of ImageFX!"' '" OK "' CALL ErrorOut 10 end 'SAVE_DATA' pic '"'||tempfile||'"' '"ILBM CmpByteRun1"' if (RC ~= 0) then do 'REQUEST' '"Error when saving temporary image!"' '" OK "' CALL ErrorOut 10 end address "IMAGEFX.1" Screen2Front LoadBuffer '"'tempfile'"' force if (RC ~= 0) then do address 'IMAGEENGINEER' 'REQUEST' '"Error when loading temporary image into ImageFX!"' '" OK "' CALL ErrorOut 10 end /* Choose a Hook */ RequestFile '"Choose a Hook..."' 'ImageFx3:Hooks/' if RC == "0" then HOOK result else do KILLBUFFER FORCE address 'IMAGEENGINEER' IE_TO_FRONT exit end /* Import */ SaveBufferAs ILBM '"'tempfile2'"' if (RC ~= 0) then do address 'IMAGEENGINEER' 'REQUEST' '"Failed to save temporary image from ImageFX!"' '" OK "' CALL ErrorOut 10 end address 'IMAGEENGINEER' 'OPEN' tempfile2 'COLOUR' if (RC ~= 0) then do 'REQUEST' '"Failed to load temporary image into IE!"' '" OK "' CALL ErrorOut 10 end newpic = result address "IMAGEFX.1" KILLBUFFER FORCE address 'IMAGEENGINEER' IE_TO_FRONT PROJECT_SET newpic ZOOM origzoomval CALL Errorout 0 exit /* Errorout procedure */ ErrorOut: PARSE ARG ExitCode if (exists( tempfile )) then address command "Delete >NIL:" tempfile if (exists( tempfile2 )) then address command "Delete >NIL:" tempfile2 EXIT ExitCode /*******************************************************************/ /* This is where control goes when an error code is returned by IE */ /* It puts up a message saying what happened and on which line */ /*******************************************************************/ error: if RC=5 then do /* Did the user just cancel us? */ IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' exit end else do address 'IMAGEENGINEER' IE_TO_FRONT LAST_ERROR 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!' exit end