home *** CD-ROM | disk | FTP | other *** search
- /* Scales the current page proportionally.
- AREXX script by Greg Niles, Centaur Development.
- Version 1.0 - initial version
- Version 1.1 - added scale to larger size capability
- Version 1.2 - added percentage width and height scaling
- Version 2.0 - revamped interface for OpalPaint v2.3
- - much smarter about changing screen resolution
- - online help (in an AREXX script??? weird...)
- */
-
- address 'OpalPaint_Rexx'
-
- options Results
-
- SaveSetUp
-
- /* get current page size & initialize variables */
- PageSize
- parse var result Width Height
- Width = compress(Width)
- Height = compress(Height)
- MaxScale = 32767
- NewWidth = Width
- NewHeight = Height
- SliderAmt = 100
- ScaleMethod = BothGad
-
- call OptionsRequester
-
- RestoreSetUp
- EXIT
-
-
- OptionsRequester:
- /* Scaling requester */
- ReqBuild '450 250 "Scale Image v2.0"'
-
- AddGadget 'Toggle WidthGad 35 55 Medium "Width"'
- AddGadget 'Toggle HeightGad Below WidthGad 0 10 Medium "Height"'
- AddGadget 'Toggle BothGad Below HeightGad 0 10 Medium "Both"'
- AddGadget 'VProp ScaleSlider Right WidthGad 30 0 Medium 0 200 1 Percent'
- AddGadget 'Integer WidthString Right ScaleSlider 60 10 Medium 1 'MaxScale''
- AddGadget 'Integer HeightString Below WidthString 0 20 Medium 1 'MaxScale''
- AddGadget 'Toggle LockToWidth Below HeightString 0 20 80 25 "Width"'
- AddGadget 'Toggle LockToHeight Right LockToWidth 10 0 80 25 "Height"'
- AddGadget 'Button Recalculate Below LockToHeight CenterX 44 Large "Recalculate size"'
- AddGadget 'Button HelpGad 416 5 20 20 "?"'
-
- AddText 'Above WidthString 0 -3 "Enter new width:"'
- AddText 'Above HeightString 0 -3 "Enter new height:"'
- AddText 'Above LockToWidth 5 -3 "Lock aspect ratio to:"'
- AddHeading 'Above Recalculate CenterX -20 "Old image size: 'Width' x 'Height'"'
- AddHeading 'Above Recalculate CenterX -7 "New image size: 'NewWidth' x 'NewHeight'"'
-
- MutualEx WidthGad HeightGad BothGad LockToWidth LockToHeight
- InitGadget ''ScaleMethod' Selected'
- InitGadget 'ScaleSlider 'SliderAmt''
- InitGadget 'WidthString 'NewWidth''
- InitGadget 'HeightString 'NewHeight''
- AddHeading 'Above WidthGad 10 -10 "Percentage Scaling"'
- AddHeading 'Above WidthString 30 -20 "Numeric Scaling"'
- AddBox 'Above WidthGad -20 -25 200 150'
- AddBox 'Above ScaleSlider 70 -25 200 150'
-
- Request
-
- GadgetStatus Cancel
- if Result=1 Then do
- Exit
- END
-
- GadgetStatus WidthGad
- if Result=1 then do
- GadgetStatus ScaleSlider
- ScaleFactor = (Result/100) /* Set scale percentage */
- NewWidth = Trunc(Width*ScaleFactor)
- NewHeight = Height
- SliderAmt = (ScaleFactor*100)
- ScaleMethod = WidthGad
- END
-
- GadgetStatus HeightGad
- if Result=1 then do
- GadgetStatus ScaleSlider
- ScaleFactor = (Result/100) /* Set scale percentage */
- NewWidth = Width
- NewHeight = Trunc(Height*ScaleFactor)
- SliderAmt = (ScaleFactor*100)
- ScaleMethod = HeightGad
- END
-
- GadgetStatus BothGad
- if Result=1 then do
- GadgetStatus ScaleSlider
- ScaleFactor = (Result/100) /* Set scale percentage */
- NewWidth = Trunc(Width*ScaleFactor)
- NewHeight = Trunc(Height*ScaleFactor)
- SliderAmt = (ScaleFactor*100)
- ScaleMethod = BothGad
- END
-
- GadgetStatus LockToWidth
- if Result=1 then do
- GadgetStatus WidthString
- ScaleFactor = (Result/Width)
- NewWidth = Result
- NewHeight = Trunc(Height*ScaleFactor)
- SliderAmt = (ScaleFactor*100)
- ScaleMethod = LockToWidth
- END
-
- GadgetStatus LockToHeight
- if Result=1 then do
- GadgetStatus HeightString
- ScaleFactor = (Result/Height)
- NewHeight = Result
- NewWidth = Trunc(Width*ScaleFactor)
- SliderAmt = (ScaleFactor*100)
- ScaleMethod = LockToHeight
- END
-
- GadgetStatus Recalculate
- if Result=1 then do
- call OptionsRequester
- Return
- END
-
- GadgetStatus HelpGad
- if Result=1 then do
- call Help
- call OptionsRequester
- Return
- END
-
- GadgetStatus Okay
-
- HorizRes=''
- VertRes=''
- Scan=''
- if Result=1 then do
- if NewWidth>640 then do
- HorizRes=HIRES
- Scan=OVERSCAN
- end
- else if NewWidth>370 then
- HorizRes=HIRES
- else if NewWidth>320 then
- Scan=OVERSCAN
-
- VideoMode
- if Result=PAL then do
- if NewHeight>512 then do
- VertRes=INTERLACE
- Scan=OVERSCAN
- end
- else if NewHeight>286 then
- VertRes=INTERLACE
- else if NewHeight>256 then
- Scan=OVERSCAN
- end
- else do
- if NewHeight>400 then do
- VertRes=INTERLACE
- Scan=OVERSCAN
- end
- else if NewHeight>236 then
- VertRes=INTERLACE
- else if NewHeight>200 then
- Scan=OVERSCAN
- end
-
- PageSize NewWidth NewHeight HorizRes VertRes Scan
- END
- Return
-
-
- Help:
- ReqBuild '640 310 "Help for Scale Image v2.0"'
- AddBox '15 30 610 235'
- AddGadget 'Button ExitHelp CenterX 275 Medium "Exit Help"'
-
- AddHeading 'CenterX 40 "Percentage Scaling"'
- AddText '25 55 "The slider allows you to set the percentage for scaling the image."'
- AddText '25 65 "Normally, the BOTH button is selected, which scales both width and height"'
- AddText '25 75 "proportionally, but selecting either the WIDTH or HEIGHT buttons will"'
- AddText '25 85 "scale ONLY the width or height of the image by the specified percentage."'
- AddText '25 95 "For all three methods, the width and height strings are ignored."'
-
- AddHeading 'CenterX 110 "Numeric Scaling"'
- AddText '25 125 "The width and height strings allow you to type in a size directly. To"'
- AddText '25 135 "activate these gadgets, however, you must click on either of the two LOCK"'
- AddText '25 145 "ASPECT RATIO TO: buttons. Selecting WIDTH will scale the image to the"'
- AddText '25 155 "specified pixel width, while the height will be scaled by the same"'
- AddText '25 165 "proportion automatically. The opposite applies when HEIGHT is selected."'
- AddText '25 175 "In either case, the percentage slider setting is ignored."'
-
- AddHeading 'CenterX 190 "Viewing / performing your changes"'
- AddText '25 205 "The current image size is shown at the bottom of the requester. Click"'
- AddText '25 215 "the RECALCULATE SIZE button to update the new page size values to reflect"'
- AddText '25 225 "the changes you have made. This also updates the slider to reflect any"'
- AddText '25 235 "width or height reference scaling. Click OK to accept all settings and"'
- AddText '25 245 "scale the image to the new size, or CANCEL to abort."'
-
- Request NoOk NoCancel
- Return
-
- EXIT
-
-
-