home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Assembler / dse-src3.dms / in.adf / Source / Vectors / Dithering / Quantize.lha / std.h < prev   
Encoding:
C/C++ Source or Header  |  1993-01-06  |  1.6 KB  |  41 lines

  1. /*----------------------------------------------------------------------
  2.  * header file for color-quantizer
  3.  * by Gary Oberbrunner  1/5/88
  4.  *----------------------------------------------------------------------
  5.  */
  6.  
  7. #define HIST_QUANT_BITS 5    /* Histogram clump quantization */
  8. #define HIST_SHIFT (8 - HIST_QUANT_BITS)
  9. #define HIST_SIZE (1 << (HIST_QUANT_BITS * 3))
  10.  
  11. #define RGB_BYTES 4        /* Bytes per rgb pixel (4 for alpha channel) */
  12.  
  13. /* We need the next definition to reference a variable-size array */
  14. /* NCOLS is the number of columns in the array */
  15. /* Each pixel is stored as an rgb byte triplet */
  16.  
  17. /* This is the address of the pixel triplet: */
  18. #define RCPIX(array, row, col)    (array + RGB_BYTES * (row * NCOLS + col))
  19. #define PIXPIX(array, pixel)    (array + RGB_BYTES * (pixel))
  20. /* These are the pixel components: */
  21. #define RED(array, row, col)    (*(RCPIX(array, row, col)))
  22. #define GREEN(array, row, col)    (*(RCPIX(array, row, col) + 1))
  23. #define BLUE(array, row, col)    (*(RCPIX(array, row, col) + 2))
  24. #define PIXRED(array, pix)    (*(PIXPIX(array, pix)))
  25. #define PIXGREEN(array, pix)    (*(PIXPIX(array, pix) + 1))
  26. #define PIXBLUE(array, pix)    (*(PIXPIX(array, pix) + 2))
  27.  
  28. /* Here is the rgb-space distance metric: */
  29. #define DIST(r1,g1,b1,r2,g2,b2) \
  30.        (int) \
  31.        (3 * ((r1)-(r2)) * ((r1)-(r2)) + \
  32.     4 * ((g1)-(g2)) * ((g1)-(g2)) + \
  33.     2 * ((b1)-(b2)) * ((b1)-(b2)))
  34. #define BIG_DISTANCE 1000000    /* bigger than any real distance */
  35.  
  36. typedef unsigned char cmap_t;
  37. typedef unsigned char rgb_pix_t;
  38. typedef unsigned char out_pix_t;
  39.  
  40. extern out_pix_t  *quant_image;    /* the quantized image - cmap indices */
  41. extern int debug;