home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 13
/
AACD13.ISO
/
AACD
/
Graphics
/
PPT
/
rexx
/
ConvertFileFormat.prx
< prev
next >
Wrap
Text File
|
1998-11-07
|
5KB
|
184 lines
/*
This script loads a file and converts it to any format PPT supports.
Known bugs:
- Works only on AGA or CyberGfx.
$Id: ConvertFileFormat.prx,v 1.1 1998/11/08 00:22:28 nobody Exp nobody $
*/
OPTIONS RESULTS
SIGNAL ON ERROR
IF ADDRESS() = REXX THEN DO
startedfromcli = 1
ADDRESS PPT
END
ELSE DO
startedfromcli = 0
ADDRESS PPT
END
RESULT = 'no result'
/*---------------------------------------------------------------------*/
PPT_TO_FRONT
/*
* Open file
*/
ASKFILE '"Open file to convert"' POS "Open"
loadfile = RESULT
LOADFRAME loadfile
myframe = RESULT
/*
* Gather a list of I/O modules and ask the user
* which format he wishes to use for output.
*/
LISTIOMODULES STEM iomodlist ONLYSAVERS
iocyc.type=CYCLE
iocyc.popup=1
iocyc.labels=""
DO i = 1 to iomodlist.0
IF i = 1 THEN
iocyc.labels=iomodlist.i
ELSE
iocyc.labels=iocyc.labels || "|" || iomodlist.i
END
ASKREQ '"Please choose the output format"' iocyc
IF RESULT = 0 THEN
DO
iomodnum = iocyc.value + 1
IOMODULEINFO iomodlist.iomodnum STEM modinfo
ASKFILE '"Save file"' POS "Save!" ID "T:" SAVE
savefile = RESULT
/*
* Do generic checks on how to convert the file before
* saving. This does a couple of assumptions, such as
* the RGB model is always supported if ARGB is, etc.
*
* This script always tries to keep the colorspace
* the same, then it will lose first the transparency
* information. It will try to keep color available
* as long as possible.
*/
FRAMEINFO myframe STEM imginfo
render = 0
IF imginfo.colorspace = "RGB" THEN
DO
IF POS("RGB",modinfo.saveformats) = 0 THEN
DO
IF POS("Colormapped",modinfo.saveformats) = 0 THEN
DO
IF POS("Greyscale",modinfo.saveformats) = 0 THEN
DO
SHOWERROR '"Cannot convert to this format"'
EXIT 10
END
ELSE DO
PROCESS myframe "Greyscale"
END
END
ELSE DO
render = 1
END
END
ELSE SAY 'Using RGB'
END
ELSE IF imginfo.colorspace = "ARGB" THEN
DO
IF POS("ARGB",modinfo.saveformats) = 0 THEN
DO
IF POS("RGB",modinfo.saveformats) = 0 THEN
DO
IF POS("Colormapped",modinfo.saveformats) = 0 THEN
DO
IF POS("Greyscale",modinfo.saveformats) = 0 THEN
DO
SHOWERROR '"Cannot convert to this format"'
EXIT 10
END
ELSE DO
PROCESS myframe "Greyscale"
END
END
ELSE DO
render = 1
END
END
ELSE DO
PROCESS myframe "TrueColor"
END
END
ELSE SAY 'Using ARGB: ' modinfo.saveformats
END
ELSE IF imginfo.colorspace = "Greyscale" THEN
DO
IF POS("Greyscale",modinfo.saveformats) = 0 THEN
DO
IF POS("RGB",modinfo.saveformats) = 0 THEN
DO
IF POS("Colormapped",modinfo.saveformats) = 0 THEN
DO
SHOWERROR '"Cannot convert to this format"'
EXIT 10
END
ELSE DO
render = 1
END
END
ELSE DO
PROCESS myframe "Truecolor"
END
END
ELSE SAY 'using Grey'
END
/*
* If we need to save a colormapped image, we do it here.
* BUG: I probably should offer the user a possibility to
* determine the number of colors and the dither mode.
*/
IF render = 1 THEN
DO
SETRENDERPREFS myframe NCOLORS 256 MODE Color DITHER "Floyd-Steinberg"
'RENDER' myframe
SAVEFRAMEAS myframe savefile FORMAT iomodlist.iomodnum COLORMAPPED
CLOSERENDER myframe
END
ELSE DO
SAVEFRAMEAS myframe savefile FORMAT iomodlist.iomodnum
END
DELETEFRAME myframe FORCE
END
EXIT 0
/*-------------------------------------------------------------------*/
/* Again, keep this part intact. This is the error handler. */
ERROR :
returncode = RC
IF startedfromcli = 1 THEN DO
SAY 'ERROR ' returncode ' on line ' SIGL ': ' RC2
PPT_TO_BACK
END
ELSE
SHOWERROR '"'RC2'"' SIGL
EXIT returncode