/*
 * $VER: ColorToCMAP.ifx.pre (AutoFX Arexx script) 1.0 (07.11.99) ® 1999 by Przemyslaw 'SENSEI' Gruchala
 *
 * Arexx script for AutoFX. Made for the REDFiX modules package.
 *
 * Based on the Render_Foreign.ifx.pre written by Thomas Krehbiel
 *
 * Convert main buffer to a CMAP.
 *
 * Inputs:
 *    Word(Arg(1),1) = Sequence number
 *    Word(Arg(1),2) = Total number of frames (N)
 *
 * Returns:
 *    0 if successful, non-zero on failure
 *
 */

OPTIONS RESULTS

base = 'Autofx_ColorToCMAP_'

dithtype = GETCLIP(base||'DithType')
dithdir  = GETCLIP(base||'DithDir')
ditherr  = GETCLIP(base||'DithErr')
colors   = GETCLIP(base||'Colors')

IF dithtype = "" THEN dithtype = 1
IF dithdir  = "" THEN dithdir  = 2
IF ditherr  = "" THEN ditherr  = 0
IF colors   = "" THEN colors   = 7

Gadget.1 = 'CYCLE 100  5 90 12 "Dither:"' dithtype '"None/Floyd/FloydR/EDD/Order"'
Gadget.2 = 'CYCLE 200  5 90 12 " "' dithdir '"L-to-R/R-to-L/ZigZag"'
Gadget.3 = 'CYCLE 300  5 90 12 " "' ditherr '"None/Low/Medium/High"'
Gadget.4 = 'CYCLE 300 20 90 12 "Colors:"' colors '"2/4/8/16/32/64/128/256"'
Gadget.5 = 'END'

NewComplexRequest '"ColorToCMAP Settings"' Gadget 410 40
IF rc ~= 0 THEN EXIT rc

dithtype = result.1
dithdir  = result.2
ditherr  = result.3
colors   = result.4

colorarray.0 = 2
colorarray.1 = 4
colorarray.2 = 8
colorarray.3 = 16
colorarray.4 = 32
colorarray.5 = 64
colorarray.6 = 128
colorarray.7 = 256

colors = colorarray.colors

CALL SETCLIP(base||'DithType', dithtype)
CALL SETCLIP(base||'DithDir', dithdir)
CALL SETCLIP(base||'DithErr', ditherr)
CALL SETCLIP(base||'Colors', colors)

EXIT
