home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: Circle_alpha_pattern.ieb 1.11, IE Arexx script ** Image Engineer Batch Processing script ** Copyright © by Patrik M Nydensten ** 25/1 1997 Stockholm/Sweden ** ** Place PRIMARY images in a circular pattern on SECONDARY image with ** ALPHA channel as transparency level. */ options results signal on error parse arg input command input = upper(strip(input)) address 'IMAGEENGINEER' select /* Required batch script commands */ when input = 'INFO' then return get_info() when input = 'CONFIG' then return get_config(command) when input = 'PROCESS' then return process_image(command) otherwise do 'REQUEST' '"Failure in call to batch script!"' '" Quit "' return '<ERROR>' end end exit 0 /* Required "Get_info" procedure ------------------------------------ */ /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files */ /* F = Current image number */ get_info: back = 'OK S2 A2 F' return back /* Required "Get_config" procedure ---------------------------------- */ get_config: parse arg '"'command'"' Xoff=128 ; Yoff=128 ; Angle=0 ; Radius=64 if command ~= '' then parse var command Xoff Yoff '#'Objects Angle Radius '#'Rotate 'IE_TO_FRONT' form = 'FORM "Circle Alpha Pattern" " OK | Cancel "', ' INTEGER,"X offset",0,4096,'Xoff',SLIDER', ' INTEGER,"Y offset",0,4096,'Yoff',SLIDER', ' INTEGER,"Rotation angle",-3600,3600,'Angle',SLIDER', ' INTEGER,"Pattern radius",0,4096,'Radius',SLIDER' if command = '' then do form = form||' INTEGER,"Number of objects",1,360,5,SLIDER', ' CHECKBOX,"Rotate objects within circle?",1' form parse var result ok Xoff Yoff Angle Radius Objects Rotate if ok = 0 then return '<ERROR>' end else do form parse var result ok Xoff Yoff Angle Radius if ok = 0 then return '<ERROR>' Objects = 'none' Rotate = 'none' end back = Xoff Yoff '#'Objects Angle Radius '#'strip(Rotate) return back /* Required "Process_image" procedure ------------------------------- */ process_image: parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'sec_image'"' '"'alp_image'"' '"'frame':'num_frames'"' parse var options Xoff Yoff '#'Objects Angle Radius '#'Rotate . if add_mathlib() = '<ERROR>' then return '<ERROR>' 'OPEN' '"'src_image'"' '24' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "' return '<ERROR>' end else LoadImage = result 'OPEN' '"'sec_image'"' '24' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load SECONDARY image:' d2c(10)||sec_image'"' '" OK "' return '<ERROR>' end else SecImage = result 'OPEN' '"'alp_image'"' '8' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load ALPHA image:' d2c(10)||alp_image'"' '" OK "' return '<ERROR>' end else AlphaImage = result do until ((Angle < 360)&(Angle >= 0)) if Angle > 359 then Angle = Angle - 360 if Angle < 0 then Angle = Angle + 360 end 'PROJECT_INFO' LoadImage 'WIDTH' /* PRI image width */ PIW = RESULT 'PROJECT_INFO' LoadImage 'HEIGHT' /* PRI image height */ PIH = RESULT 'PROJECT_INFO' AlphaImage 'WIDTH' /* ALP image width */ AIW = RESULT 'PROJECT_INFO' AlphaImage 'HEIGHT' /* ALP image height */ AIH = RESULT /* Check if ALP and PRI has same size */ if (AIW ~= PIW)|(AIH ~= PIH) then do 'SCALE' AlphaImage PIW PIH 'BEST' ScaledAlphaImage = Result 'CLOSE' AlphaImage AlphaImage = ScaledAlphaImage end 'PROJECT_INFO' SecImage 'WIDTH' /* SEC image width */ SIW = RESULT 'PROJECT_INFO' SecImage 'HEIGHT' /* SEC image height */ SIH = RESULT do i = 1 to Objects ObjAngle = Angle+((i-1)*360/Objects) NewXoff = Xoff + trunc( cos(((ObjAngle)/360*6.2831853)+1.57079633)*Radius ) NewYoff = Yoff + trunc( sin(((ObjAngle)/360*6.2831853)+1.57079633)*Radius ) ObjAngle = trunc( ObjAngle ) if (Rotate = 1)&(ObjAngle ~= 0) then do 'ROTATE' LoadImage ObjAngle 'BEST' /* Rotate image */ NewLoadImage = result 'ROTATE' AlphaImage ObjAngle 'BEST' /* Rotate alpha */ NewAlphaImage = result end /* do rotate within */ else do NewLoadImage = LoadImage NewAlphaImage = AlphaImage end 'PROJECT_INFO' NewLoadImage 'WIDTH' /* NewPRI image width */ NewPIW = Result 'PROJECT_INFO' NewLoadImage 'HEIGHT' /* NewPRI image height */ NewPIH = Result NewXoff = NewXoff - trunc( NewPIW/2 ) NewYoff = NewYoff - trunc( NewPIH/2 ) if NewXoff < -NewPIW then NewXoff = -NewPIW if NewXoff > SIW then NewXoff = SIW if NewYoff < -NewPIH then NewYoff = -NewPIH if NewYoff > SIH then NewYoff = SIH 'MARK' NewLoadImage 'PRIMARY' 'MARK' SecImage 'SECONDARY' 'MARK' NewAlphaImage 'ALPHA' 'COMPOSITE' NewXoff NewYoff 'ALPHA' NewSecImage = Result 'CLOSE' SecImage SecImage = NewSecImage if (Rotate = 1)&(ObjAngle ~= 0) then do 'CLOSE' NewLoadImage 'CLOSE' NewAlphaImage end end /* Objects loop */ 'CLOSE' AlphaImage 'CLOSE' LoadImage OutputImage = SecImage if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1') 'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "' return '<ERROR>' end 'CLOSE' OutputImage back = 'OK' return back /* Internal procedures ---------------------------------------------- */ add_mathlib: if ~show(L,'rexxmathlib.library') then do if exists('LIBS:rexxmathlib.library') then do if ~addlib('rexxmathlib.library',0,-30,0) then do 'REQUEST' '"Failed to load libs:rexxmathlib.library!"' '" OK "' return '<ERROR>' end end /* lib found on disk */ else do 'REQUEST' '"Failed to find libs:rexxmathlib.library!"' '" OK "' return '<ERROR>' end end /* lib exists in mem */ return 'OK' /*******************************************************************/ /* 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 IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' end else do 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!' end return '<ERROR>'