home *** CD-ROM | disk | FTP | other *** search
- /* AutoScan.agaiff */
-
- address agaiff_rexx
- options results
-
- call close 'STDOUT'
- call close 'STDIN'
- call open 'STDIN','CON:20/20/500/120/AGAiff - AutoScanning picture..'
- call pragma '*','STDIN'
- call open 'STDOUT','*'
-
- status 0
- if result == "" then do
- say "No picture loaded.."
- address command wait 1
- exit
- end
-
- say "AutoScanning" result || ":"
- say "Enter border color please."
- pull colnum
-
- requestfile "AutoScan - SaveFilename"
- filename = result
- if filename == "" then exit
-
- status 1
- parse var result sizex sizey
-
- showgui
- typetext "AutoScanning picture sized" sizex sizey
-
- startx = 0
- numranges = 0
- do actline=0 for sizey
- do until startx = 0
- searchpixel startx actline colnum
- if rc=0 then do
- actx1 = result
- do xloop=actx1+1 until result ~= colnum
- getpixel xloop actline
- if rc = 1 then leave
- end
- if xloop-actx1 > 2 then do
- do yloop=actline+1 until result ~= colnum
- getpixel actx1 yloop
- if rc = 1 then leave
- end
- if yloop-actline > 2 then do
- typetext "Found range at" actx1+1 actline+1 "w/h" xloop-actx1-2 yloop-actline-2
- ranges.numranges.x1 = actx1+1
- ranges.numranges.y1 = actline+1
- ranges.numranges.x2 = xloop-2
- ranges.numranges.y2 = yloop-2
- numranges = numranges + 1
- end
- end
- startx = xloop+1
- end
- else startx = 0
- end
- end
-
- if numranges = 0 then do
- typetext "No range found."
- exit
- end
-
- typetext "No more ranges found. Saving.."
- address command wait 1
-
- showpic
- do abc = 0 for numranges
- range ranges.abc.x1 ranges.abc.y1 ranges.abc.x2 ranges.abc.y2
- typetext abc
- save filename||"."||abc
- end
-
- showgui
- typetext numranges "ranges saved as" filename||".%d !!"
-