home *** CD-ROM | disk | FTP | other *** search
- /*
- -----------------------------------------------------------------------------
- This AREXX-Script will scale any image to any size, specified by the user
- in the arguments.
- The size argument allows percents!
-
- Host address: ADPro (Art Department Professional ®ASDG)
- Written by Jan Van Overbeke, 3-DEE, ©1993.
- Read the AREXX-Scripti doc, for info about operation and rights!
- -----------------------------------------------------------------------------
- */
-
- arg filename SpecX SpecY
- if ~exists(filename)|filename='' then do
- say 'Unable to find the image !!'
- say 'See Ya...'
- say ''
- exit
- end
-
- address 'ADPro'
- options results
- say 'Scale: Written by JAN VAN OVERBEKE, 3-DEE, ©1993'
- say 'Image: 'filename
- say 'SAVE: IFF Original Colors.'
- say ''
-
- LFORMAT "UNIVERSAL"
- if RC ~=0 then do
- say 'Unable to select the UNIVERSAL loader.'
- say 'See Ya...'
- say ''
- exit
- end
-
- say 'Loading.........'
- LOAD filename
- if RC ~=0 then do
- say 'Had some problems while loading.'
- say 'See Ya...'
- say ''
- exit
- end
-
- /* ---- Let's see if it is 24Bit ---- */
- /* ---------------------------------- */
- IMAGE
- help=ADPRO_RESULT
- dontrender='ok'
- if pos('RENDERED',help)>0|pos('BITPLANE',help)>0 then dontrender='nok'
-
- say 'Converting......'
- XSIZE
- w=ADPRO_RESULT
- YSIZE
- h=ADPRO_RESULT
- say 'Scaling from: 'w'x'h'.......'
-
- /* ---- This is were we are going to scale..... ---- */
- /* ------------------------------------------------- */
- done='no'
- /* ---- Just halve it ---- */
- /* ----------------------- */
- if SpecX='50%' & SpecY='50%' then do
- operator Halve
- done='yes'
- end
-
- /* ---- Just testing if we could do ABS_SCALE ---- */
- /* ----------------------------------------------- */
- if datatype(SpecX)='NUM' & datatype(SpecY)='NUM' & done='no' then do
- call Sizenmr SpecX SpecY
- done='yes'
- end
-
- /* ---- Just testing if we could do PCT_SCALE ---- */
- /* ----------------------------------------------- */
- if datatype(SpecX)='CHAR' & datatype(SpecY)='CHAR' & done='no' then do
- call Percent delstr(SpecX,length(SpecX)) delstr(SpecY,length(SpecY))
- done='yes'
- end
-
- /* ---- Mixed use of ABS_SCALE and PCT_SCALE ---- */
- /* ---------------------------------------------- */
- if datatype(SpecX)='NUM' & done='no' then do
- call Sizenmr SpecX h
- call percent 100 specY
- done='yes'
- end
- if datatype(SpecX)='CHAR' & done='no' then do
- call Percent delstr(SpecX,length(SpecX)) 100
- XSIZE
- w=ADPRO_RESULT
- call Sizenmr w SpecY
- done='yes'
- end
-
- XSIZE
- w=ADPRO_RESULT
- YSIZE
- h=ADPRO_RESULT
- say 'Scaled to: 'w'x'h'........'
-
- SFORMAT "IFF"
- if RC ~=0 then do
- say 'Unable to select the IFF Saver.'
- say 'See Ya...'
- say ''
- exit
- end
-
- /* ---- If the loaded image was not 24Bit, ---- */
- /* ---- we'll have to adjust he palette to the colors, ---- */
- /* ---- and then render a new image ---- */
- /* -------------------------------------------------------- */
- if dontrender='nok' then do
- palette=0
- render_type
- colors=ADPRO_RESULT
- if colors='HAM' then palette=16
- if colors='HAM8' then palette=64
- if palette=0 then palette=colors
- ptotal palette
- pused palette
- EXECUTE
- if RC~=0 then do
- say 'Execute failed.'
- say 'See Ya.......'
- say ''
- exit
- end
- savemode='IMAGE'
- say 'Saving IMAGE 'colors'......'
- end
- else do
- savemode='RAW'
- say 'Saving RAW......'
- end
-
- filename=filename'.new'
- SAVE filename savemode
- if RC~=0 then do
- say 'Problems while saving: NOT SAVED.'
- say 'See Ya...'
- end
- say ''
- exit
-
-
- /* ---- This is a little procedure for ABS_SCALE ---- */
- /* -------------------------------------------------- */
- SizeNmr:
- parse arg SizeX SizeY
- ABS_SCALE SizeX SizeY
- if RC~=0 then do
- say 'SCALE failed!'
- say 'See Ya.....'
- say ''
- exit
- end
- return SizeX SizeY
-
- /* ---- This is a little procedure for PCT_SCALE ---- */
- /* -------------------------------------------------- */
- Percent:
- parse arg PercX PercY
- PCT_SCALE PercX PercY
- if RC~=0 then do
- say 'SCALE failed!'
- say 'See Ya.....'
- say ''
- exit
- end
- return PercX PercY
-