home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / pal8.zip / PALETTE8.DOC next >
Text File  |  1994-12-01  |  3KB  |  72 lines

  1.  
  2.    Palette8 converts a 24-bpp bitmap to 8-bpp.  It is invoked by:
  3.  
  4.       palette8 <infile> [<outfile>]
  5.  
  6.    If no output file is given, the input file is replaced. In any case, the
  7. output file is not written until the process is complete. The program can be
  8. aborted, if necessary, to avoid overwriting an existing file.
  9.    The input file may be a Windows or OS/2 bitmap. The output file is an OS/2
  10. bitmap.
  11.    During processing, the screen is updated to show its progress. (It may take a
  12. minute or two for the first update while the program reads the input bitmap 
  13. and counts colors.)
  14.  
  15.                      -----------------------------
  16.  
  17.    The algorithm selects pairs of colors from the image and substitutes one for 
  18. the other. The substituted color is discarded. This process continues until
  19. there are 256 colors remaining.
  20.  
  21.    The difference between the input and output images is measured by:
  22.       1. the number of pels whose color is changed, and
  23.       2. the amount of change in the color.
  24.    The goal is to minimize the difference.
  25.  
  26.    To implement this, a color is selected and the number of times it occurs in
  27. the image is examined. A second color is compared to the first and the
  28. difference in colors calculated.
  29.    The error in changing the first color to the second is measured as the
  30. difference between the colors weighted by the number of pels that would change.
  31. If this is acceptable, all pels of the first color are changed to the second.
  32. The first color is eliminated.
  33.  
  34.    The "acceptable error" is, at first, chosen to be small. Within this
  35. tolerance, as many colors as possible are eliminated. If there are still excess
  36. colors, then the tolerance is increased and the process is repeated until only
  37. 256 colors remain.
  38.  
  39.    The algorithm produces images which contain only the colors from the original.
  40. This differs from other algorithms which match image colors to a predetermined 
  41. color table which may have few appropriate colors and many extraneous colors.
  42.    The algorithm also tends to preserve details in the image where just a few
  43. pels of one color might otherwise be overwhelmed by other, more popular, colors.
  44.  
  45.    The process is not fast. While there are excess colors, each is compared to
  46. every other color (unless it is eliminated early). In raytraced images, for
  47. example, it is not uncommon to have tens of thousands of colors which take 
  48. longer to reduce than the time it took to render the original image!
  49.  
  50.                      ---------------------------------
  51.  
  52.    This program is provided as shareware. A $10.00 registration donation would
  53. be appreciated. $15.00 will also get you the application source code. $25.00 will
  54. get you all the above plus the source code for the Bitmap class library. (The Bitmap
  55. class DLL, HPP, and INF files are available in OS2DF1 section 5.)
  56.  
  57.    Please remit to:
  58.  
  59.    William A. Leonard
  60.    29 Bow Street
  61.    Jamestown, RI 02835
  62.  
  63.    The author will support the application via CompuServe: 70252,3144.
  64.  
  65.    The author will not be liable for any bug, error, omission,
  66.    defect, deficiency, or nonconformity in this software. The author
  67.    also disclaims all implied warranties, including without limitation
  68.    warranties of merchantability, performance, and fitness for a
  69.    particular purpose. This software is provided "as is" and the user
  70.    assumes the entire risk as to its quality and performance.
  71.  
  72.