home *** CD-ROM | disk | FTP | other *** search
/ TopWare 18: Liquid / Image.iso / liquid / top1057 / dyeworks.doc next >
Text File  |  1994-03-24  |  17KB  |  427 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.        DYEWORKS Version 1.31 - Color Reduction/Promotion/Manipulation
  9.        =============================================================
  10.  
  11.        The author's address:
  12.  
  13.               Stefan Reich
  14.               Bjoernsonweg 12e
  15.               22587 Hamburg
  16.               Germany
  17.               Tel/Fax: 0049 40 86 31 62 (if you happen to speak German)
  18.               CIS: [100117,1415]
  19.  
  20.        "Dyeworks 1.31" software is freely distributable as long as this
  21.        document accompanies the executable DYEWORKS.EXE and both files
  22.        remain unchanged. However, the program may not be included in a
  23.        commercial product without written permission from the author.
  24.        The GIF encoder/decoder implemented in Dyeworks 1.31 is based on
  25.        C routines from "Fractint" which are copyrighted (c) 1987 by
  26.        Steven A. Bennett.
  27.  
  28.  
  29.        What is it?
  30.        -----------
  31.  
  32.        Dyeworks       - reads and writes GIF, PCX, Targa, BMP and POV-Ray (DKBTrace)
  33.           dump format
  34.        - converts between color depths: grayscale, 256 colors, HiColor,
  35.           TrueColor 24, TrueColor 32
  36.        - reduces true color bitmaps to VGA-suited 256 colors or to any
  37.           given number of colors
  38.        - shrinks pictures with anti-aliasing; adjusts contrast,
  39.           brightness and gamma
  40.        - is F A S T!
  41.        - offers a variety of dithering processes for optimal results
  42.        - requires (almost) constant amounts of memory and time,
  43.           regardless of image size and contents
  44.          (well, ok, time is size-depending)
  45.  
  46.  
  47.        How you use it
  48.        --------------
  49.  
  50.        Dyeworks is batch-driven. That is, all parameters needed are
  51.        supplied on the DOS command line. This makes it possible to
  52.        process many files in a row without further user interaction.
  53.  
  54.        The usage is:
  55.  
  56.                DYEWORKS <option> <option> <option> ...
  57.  
  58.        Options are:
  59.  
  60.        *General Options
  61.  
  62.        -h,-? or no option
  63.        Displays a help screen showing available options.
  64.  
  65.        -i<file>
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.        Specifies the input file. Currently supported are CompuServe's
  73.        Graphics Interchange Format (GIF), PC Paintbrush (PCX), Targa,
  74.        Windows Bitmap (BMP) and POV-Ray dump format.
  75.  
  76.        Syntax 1: -o<file>
  77.        Syntax 2: -o(type)<file>
  78.        Specifies the output file. Its file type may be different from
  79.        the input file's type; if necessary, conversion is done.
  80.        If no output file is given, Dyeworks just reads and displays.
  81.        *Input and output file may not be identical!*
  82.  
  83.        File types:
  84.  
  85.        (g)  Grayscale        (8 Bits)
  86.        (8)  256 color palette (out of 256K colors)
  87.        (16) HiColor          (3*5 Bits)
  88.        (24) TrueColor        (3*8 Bits)
  89.        (32) TrueColor+Alpha  (3*8+8 Bits)
  90.  
  91.        Note: "Alpha" is an 8 bit wide field to store additional
  92.        information for each pixel (e.g. a transparency value). Dyeworks
  93.        ignores it when reading. When writing, all alpha values are set
  94.        to zero.
  95.  
  96.        These are all the possible combinations of file types and
  97.        formats (R=readable, W=writable, Default=default output file
  98.        type when none is specified):
  99.  
  100.                            (g)    (8)   (16)   (24)   (32)   Default
  101.        TGA Uncompressed    RW     RW     RW     RW     RW     (24)
  102.        TGA Compressed      R      R             R      R
  103.        GIF87a                     RW                           (8)
  104.        GIF89a                     R
  105.        PCX                        RW            RW             (8)
  106.        BMP Uncompressed    R      R      R      R      R
  107.        DIS (POV-Ray)                            RW            (24)
  108.  
  109.        Another note: The GIF encoder attaches greater weight to speed
  110.        than to compression efficiency. In other words, there are
  111.        programs that make GIFs around 1% smaller than Dyeworks does;
  112.        however, there is no program that produces GIFs as fast as
  113.        Dyeworks does (as far as I know).
  114.  
  115.        *Wildcards*
  116.  
  117.        Both input and output file name may contain wildcards. The input
  118.        file name follows the usual DOS wildcard conventions (allowing
  119.        '?' and '*'). Dyeworks will process all files that match the
  120.        input file name. If an output file name with wildcards is given,
  121.        it will be used as a mask to convert the name of the current
  122.        input file. Here, extended wildcards are allowed:
  123.  
  124.        Modifier   Function
  125.        ----------------------------------------
  126.            ?      copy one character             \
  127.            *      copy all remaining characters  | as understood by DOS
  128.            a      replace one character with 'a' /
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.            #      delete one character           \ unique to
  136.            ^a     insert character 'a'           / Dyeworks
  137.  
  138.        See examples.
  139.  
  140.        +o
  141.        Tells Dyeworks to <o>verwrite the output file(s) in case it/they
  142.        already exist(s). Without this option, Dyeworks will not change
  143.        an existing file.
  144.  
  145.        +d (the default)
  146.        Displays picture while converting, in case the following
  147.        conditions are met:
  148.        - a VGA adapter is detected,
  149.        - the picture is less or equal to 320 (width) * 200 (height)
  150.          pixels in size (no SVGA support so far, sorry), and
  151.        - there is no output file or it is of format '256 colors'.
  152.        As soon as the picture is complete, Dyeworks waits for a key to
  153.        be pressed. So if you want to convert multiple files
  154.        continuously, make sure to specify "-d"!
  155.  
  156.        -d
  157.        Disables graphical display.
  158.  
  159.        +q (quiet mode)
  160.        Disables text display. This option does NOT imply "-d".
  161.  
  162.        *Histograms*
  163.  
  164.        Syntax 1: -hn<file>   (New histogram file)
  165.        Syntax 2: -ha<file>   (Add histogram to file)
  166.  
  167.        These options scan the image and build up a histogram that
  168.        stores detailed information about the colors used in the image;
  169.        then, the histogram is saved into a file. "-hn<file>" starts
  170.        with an empty histogram; "-ha<file>" reads the histogram from
  171.        the file (that must exist), adds the new colors to it, and saves
  172.        it again.
  173.        You need such an on-disk-histogram when a palette is supposed to
  174.        fit multiple images. In this case, you would first scan all the
  175.        images with "-ha<file>", then convert the pictures down to 256
  176.        colors using "-hr<file>".
  177.  
  178.  
  179.        *True color manipulations
  180.  
  181.        Any image data read by Dyeworks (regardless of the format) is
  182.        first converted into true color. Now the manipulations listed
  183.        below may be executed. The last step is either saving the true
  184.        color data, or creating a palette for 256 color output.
  185.  
  186.        -s<factor> (factor=1-100)
  187.        Shrinks the picture isometrically:
  188.  
  189.            new width = old width / factor
  190.            new height = old height / factor
  191.  
  192.        The shrinking process doesn't just remove pixels from the
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.        picture: any program could give you that! No, it performs anti-
  200.        aliasing by averaging each square that will be deflated to one
  201.        pixel of the final image.
  202.        One application of this feature is to receive a kind of anti-
  203.        aliasing different from the one POV-Ray does, in terms of
  204.        smoothing without introducing noise. To obtain this effect,
  205.        render a picture at, let's say, 1280x800, and shrink it down to
  206.        320x200. I know, it's an immense size, and you will especially
  207.        get problems with your hard disk space (if you don't use
  208.        SuperStor(TM) :-). For the start, you could try a resolution of
  209.        640x400. Rendering this will take a time comparable to that a
  210.        320x200 raytracing with "anti-alias"-option on would need.
  211.        This option is also very useful for postprocessing the output of
  212.        (handy) scanners. Here, shrinking
  213.        a) anti-aliases, and
  214.        b) reduces irregularities of scanner and scanned image
  215.           (e.g., the moiré effect occuring when scanning an image that
  216.           was printed with a halftone pattern).
  217.  
  218.        +m
  219.        Mirrors picture = swaps left and right.
  220.  
  221.        +vd +vc
  222.        These options concern the reduction from the 16 Million color
  223.        range (e.g.) POV-Ray produces to the 256 thousand color range a
  224.        (standard) VGA adapter supports. This operation is supposed to
  225.        precede a VGA palette creation, but in the first step leaves a
  226.        true color image that could be saved as well (but who would want
  227.        to do so?). Anyway, here is how it works:
  228.        The option "+vc" simply cuts off the two least significant bits.
  229.        (A little bit of computer math: 16 Million = 3*8 Bits; 262,144 =
  230.        3*6 Bits.) To cut a long story short: "+vc" is bad for
  231.        gradients, but good for large areas of constant color, because
  232.        it prevents "-pd" dithering (if turned on) from trying to dither
  233.        a color a VGA card just isn't able to display.
  234.        "+vd" cuts off two bits also, but remembers the "error" it makes
  235.        by doing so, in order to correct this error with the next pixels
  236.        processed. (You have guessed it: This is known as "dithering"
  237.        :-)
  238.        Using "+vd" together with "-pd" (s.b., together they're
  239.        "DoubleDither") gives you the smoothest gradients you've ever
  240.        seen. Try it: Render POV-Ray's "LAMP.POV" (this will take some
  241.        hours), and display the output using Dyeworks (this will take
  242.        some seconds).
  243.  
  244.        Note: With HiColor output, there will be a reduction from 16
  245.        Million to 32,768 (rather than 262,144) colors. Apart from this
  246.        difference, the above said applies.
  247.  
  248.        -v (default)
  249.        No color range reduction takes place.
  250.        This can mean several things:
  251.        - The true color picture remains unchanged.
  252.        - If "-pd" option is turned on, it will do all the dithering
  253.        work - AFTER the palette is chosen. One reason for the
  254.        superiority of DoubleDither is the fact that palette creation
  255.        takes place when most (or all) of the dithering work is already
  256.        done. This makes it possible to design a palette more closely
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.        aligned to the picture's real needs.
  264.        - If "-pn" is turned on, the effect will be a cut-off similar to
  265.        the one "+vc" would do. The same thing happens in case of a
  266.        HiColor output.
  267.  
  268.  
  269.        *256 color output (and/or display)
  270.  
  271.        Syntax 1: -c<colors>
  272.        Syntax 2: -c<firstentry>,<colors>  (default: -c1,256)
  273.        Sets the maximum number of output colors. For example, if you
  274.        say "-c100", at least 156 palette entries will be left blank.
  275.        By the way, the palette will always be sorted by descending
  276.        frequency. (In other words: most popular colors first, least
  277.        popular colors last.) Thus, if a (Windows) graphics software
  278.        cuts off the last 16 or 20 entries it needs for itself, it won't
  279.        do much harm.
  280.        <firstentry> specifies the first palette entry to use (1-256).
  281.  
  282.        -pd -pl -pn (default: -pd)
  283.        These options influence the way the original picture's colors
  284.        are assigned to the new palette.
  285.        -pn seeks the "nearest" available color (in the RGB cube).
  286.        -pd does so, too, but superposes a full dither that does not
  287.        "forget" any error it has made (see "-pd" section above).
  288.        -pl dithers also, but in a much more "sloppy" way. Only great
  289.        errors will affect other pixels.
  290.  
  291.        -e<max> (1-256, default: -e12)
  292.        Limits the error that is saved and transported. This prevents
  293.        "-pd" dithering from making bad things worse: e.g., if a much
  294.        too bright color had to be chosen, the next pixel would be much
  295.        too dark instead in order to correct the error made. (Usually,
  296.        this doesn't occur unless you limit the number of colors
  297.        (s.a.).) "-e12" means that any error beyond a distance of 12
  298.        true color shades (=3 VGA shades, or three 64ths of the distance
  299.        between black and white) will be ignored.
  300.  
  301.        -hr<file>
  302.        Reads the histogram from a file, rather than building a
  303.        histogram from the image read. See "Histograms" section above.
  304.  
  305.  
  306.        Examples
  307.        --------
  308.  
  309.        C:>dyeworks -inicepic
  310.        Standard command to display true color pictures ("nicepic.tga"
  311.        in this case). Palette creation; single dither; no output file.
  312.  
  313.        C:>dyeworks -ilamp -olamp
  314.        Reads "lamp.tga", creates a palette, dithers, displays if
  315.        possible, and saves to "lamp.gif".
  316.  
  317.        C:>dyeworks -ibigpic.dis -s5 -o(16)smallpic.tga
  318.        Reads "bigpic.dis", shrinks it to a fifth (or a twentyfifth of
  319.        its surface), converts down to HiColor (without dithering), and
  320.        writes to "smallpic.tga". Displaying is not possible since no
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.        palette is generated.
  328.  
  329.        C:>for %p in (pic1 pic2 pic3) do dyeworks -i%p.dis -o%p.pcx +vd
  330.        -d -q
  331.        This call uses DOS "for" command to process three images in a
  332.        row. "pic1.dis", "pic2.dis" and "pic3.dis" will be converted to
  333.        "pic1.pcx", "pic2.pcx" and "pic3.pcx", respectively.
  334.        DoubleDither is turned on. Text and graphic display are
  335.        disabled.
  336.        In a batch file, the line would look slightly different:
  337.        for %%p in (pic1 pic2 pic3) do dyeworks -i%%p.dis -o%%p.pcx +vd
  338.        -d -q
  339.  
  340.        C:>dyeworks -ianim*.dis -o^_*.gif +vd -d -q
  341.        Converts all POV-Ray dump files beginning "anim" in the current
  342.        directory to files with "_" inserted at the front and GIF
  343.        extension. For example, "anim001.dis" would be converted to
  344.        "_anim001.gif".
  345.  
  346.        C:>dyeworks -imanycols.gif -c128 -olesscols.gif
  347.        Reads "manycols.gif", creates a new palette with up to 128
  348.        colors, and writes to "lesscols.gif". Note that if reading a 256
  349.        color file with no shrinking applied, "+vd" and "+vc" options
  350.        are ignored since color range already is 262,144.
  351.  
  352.  
  353.        Error Levels
  354.        ------------
  355.  
  356.        Dyeworks returns an error level depending on successful
  357.        completion or occurrence of errors. The error level can be
  358.        checked using DOS "if errorlevel" command. See MS-DOS user's
  359.        guide for details.
  360.        These are the codes:
  361.  
  362.         0  No Error
  363.         1  Help screen displayed
  364.         2  Could not understand command line
  365.         3  Out of memory
  366.         4  Input file is corrupt or does not exist
  367.         5  Could not write output file (bad directory, disk full?)
  368.         6  (At least one) output file exists, skipped
  369.         7  Histogram overflow
  370.  
  371.  
  372.        Warranty
  373.        --------
  374.  
  375.        I, the author, hereby guarantee that Dyeworks is the cheapest,
  376.        fastest and best VGA color reduction utility available. However,
  377.        if you find a program that produces better results in shorter
  378.        time, you will get your money back. Contact me, and I will send
  379.        you a cheque for 0.00 US-$ (or, if you like, 0.00 UK pounds, 0
  380.        Yen or any other currency :-). Joking apart, contact me, and I
  381.        will see what I can do for Dyeworks 2.0. If you want to include
  382.        Dyeworks in a commercial software or package: contact me also.
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.        Design Limits
  391.        -------------
  392.  
  393.        Minimum operating system:             MS-DOS 3.0
  394.        Minimum processor:                    80286 (Pentium is OK, too)
  395.        Minimum free DOS memory:              400,000-540,000 Bytes
  396.                                  (the latter may apply for GIF encoding)
  397.        Minimum graphics adapter for display: VGA
  398.        Maximum bitmap size before shrinking: 20480*infinite
  399.        Maximum bitmap size after shrinking:  1280*infinite
  400.                          (1280*1024 is guaranteed to fit into histogram)
  401.  
  402.  
  403.        Revision History (major versions only)
  404.        ----------------
  405.  
  406.        1.31 Bugfix, accelerations
  407.  
  408.        1.3  Multi-file (wildcard) support; histogram sharing
  409.             New effects (contrast, brightness, gamma)
  410.             New formats (Targa Compressed, BMP; HiColor, Grayscale)
  411.             EMS support for caching purposes
  412.             ...and various speed improvements
  413.  
  414.        1.2  Final GIF encoder/decoder: fast & stable
  415.  
  416.        1.0  First version; distributed in CompuServe's Graphics
  417.             Developers+ Forum
  418.  
  419.        Final note: There is a Protected Mode (DPMI) version of Dyeworks
  420.        available that consumes 400-600K of extended memory and very
  421.        little DOS memory (very useful when calling Dyeworks as a child
  422.        process). Contact me if you want to have it. I was not sure
  423.        whether anyone could need a DPMI Dyeworks, and considered the
  424.        package including both versions a bit too large to upload it in
  425.        CompuServe.
  426.  
  427.        Have fun!