/* ** $VER: Preserve 2.21, IE Arexx script ** Image Engineer Macro script ** Copyright © by Patrik M Nydensten ** 15/1 1997 Stockholm/Sweden ** ** Preserves selected basecolor(s) in image. ** ** Support for saving last used results added by MS */ Options results Signal on error if arg()==0 then exit NL = x2c(0a) Select = '------' WorkType = 'Fields' if exists("ie:prefs/vepreserve.cfg") == "1" then do call open("temp","ie:prefs/vepreserve.cfg","R") values=readln("temp") parse var values ok R Y G C bb M LHueTol RHueTol WorkType . call close("temp") end else do R=1 Y=0 G=1 C=0 bb=1 M=0 LHueTol="-21" RHueTol=21 WorkType=0 end 'FORM "Preserve" " Accept | Cancel "', ' TEXT,"Preserves selected basecolors in image while'NL'unselected colors are made grey."', ' CHECKBOX,"Red (R)",'r'', ' CHECKBOX,"Yellow (Y)",'y'', ' CHECKBOX,"Green (G)",'g'', ' CHECKBOX,"Cyan (C)",'c'', ' CHECKBOX,"Blue (B)",'bb'', ' CHECKBOX,"Magenta (M)",'m'', ' INTEGER,"Left hue tolerance",-21,0,'LHueTol',SLIDER', ' INTEGER,"Right hue tolerance",0,21,'RHueTol',SLIDER', ' CYCLE,"Work type:","Fields, (separate color areas)|Spread, (use areas between close colors)",'WorkType'' values=result parse var values ok R Y G C B M LHueTol RHueTol WorkType . if ok = 0 then exit call open("temp","ie:prefs/vepreserve.cfg","W") res=writeln("temp",values) call close("temp") Select = '' if R then Select = Select||'R' else Select = Select||'-' if Y then Select = Select||'Y' else Select = Select||'-' if G then Select = Select||'G' else Select = Select||'-' if C then Select = Select||'C' else Select = Select||'-' if B then Select = Select||'B' else Select = Select||'-' if M then Select = Select||'M' else Select = Select||'-' /* Process */ 'BRIGHTNESS' arg(1) '-255' AlphaImage = Result do i = 0 to 5 /* alpha add-loop */ if substr(Select,i+1,1) ~= '-' then do 'HUE_MASK' arg(1) Fix_Hue((i*42.667)+get_HueTol('L')) Fix_Hue((i*42.667)+get_HueTol('R')) MaskImage = Result 'MARK' AlphaImage 'SECONDARY' 'MARK' MaskImage 'PRIMARY' 'COMPOSITE' 0 0 'MAX' NewAlpha = Result 'CLOSE' AlphaImage 'CLOSE' MaskImage AlphaImage = NewAlpha end end 'CONVERT_TO_GREY' arg(1) GreyImage = Result 'MARK' AlphaImage 'ALPHA' 'MARK' arg(1) 'PRIMARY' 'MARK' GreyImage 'SECONDARY' 'COMPOSITE' 0 0 'ALPHA' OutputImage = Result 'CLOSE' GreyImage 'CLOSE' AlphaImage exit /* Procedures */ Fix_Hue: parse arg Tol if Tol < 0 then Back = 255 + trunc(Tol) else if Tol > 255 then Back = trunc(Tol) - 255 else Back = trunc(Tol) return Back Get_HueTol: parse arg Type if Type = 'L' then do if WorkType = 0 then Back = LHueTol else do newi = i if newi=0 then newi = 6 if substr(Select,newi,1) ~= '-' then Back = -21 else Back = LHueTol end end else do if WorkType = 0 then Back = RHueTol else do newi = i+2 if newi=7 then newi = 1 if substr(Select,newi,1) ~= '-' then Back = 21 else Back = RHueTol end end return Back /*******************************************************************/ /* 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||'"' exit 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||'"' ' OK ' exit end