home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / utilities / utilss / sprtools / h / palette < prev    next >
Text File  |  1994-07-18  |  3KB  |  98 lines

  1. /************************************************************************
  2.  *                                                                      *
  3.  * process.h                                                            *
  4.  * =========                                                            *
  5.  *                                                                      *
  6.  * Palette optimization function library                                * 
  7.  *                                                                      *
  8.  * Version 0.30 (20-Oct-1993)                                           *
  9.  *                                                                      *
  10.  * (C) 1993 DEEJ Technology PLC                                         *
  11.  *                                                                      *
  12.  ************************************************************************/
  13.  
  14. #ifndef __palette_h
  15. #define __palette_h
  16.  
  17. #include "sprite.h"
  18.  
  19. /*
  20. #define HASH_STAT
  21. */
  22. #define COLOUR_STAT
  23.  
  24. /* Constants */
  25.  
  26. /*
  27. #define HASH_SIZE       (21*255+1)
  28. #define HASH_ALG(r,g,b) (((b & 255)<<2) + ((g & 255)<<4) + (r & 255))
  29. */
  30.  
  31. #define HASH_SIZE       (73*255+1)
  32. #define HASH_ALG(r,g,b) (((b & 255)<<3) + ((g & 255)<<6) + (r & 255))
  33.  
  34. /*
  35. #define HASH_SIZE       (273*255+1)
  36. #define HASH_ALG(r,g,b) (((b & 255)<<4) + ((g & 255)<<8) + (r & 255))
  37. */
  38. /*
  39. #define HASH_SIZE       65527
  40. #define HASH_ALG(r,g,b) (rgb % HASH_SIZE)
  41. */
  42.  
  43. /* fraction of image area to use as pixel usage filter */
  44. #define FILTER_FRAC     10000
  45.  
  46. /* sugested maximum size of optimization table */
  47. #define TABLE_MAX       2048
  48.  
  49.  
  50. /* Structures */
  51.  
  52. typedef struct _hist_entry
  53. {
  54.         struct  _hist_entry *next;
  55.         uint    value;
  56.         int     count;
  57. } hist_entry;
  58.  
  59. typedef struct 
  60. {
  61.         uint    value;
  62.         int     count;
  63.         int     closest[2];
  64.         int     diff[2];
  65. } opt_table_entry;
  66.  
  67. typedef struct
  68. {
  69.         /* information fields from histogram */
  70.         hist_entry *list_head;
  71.         int         colours;
  72.         int         more1;
  73.         int         more10;
  74.         int         more100;
  75.         int         more_frac;
  76.         int         fraction;
  77.         int         max_use;
  78.         int         avg_use;
  79.         /* info on hash table used in making histogram */
  80.         int         hash_size;
  81.         int         hash_used;
  82.         int         hash_hits;
  83.         int         hash_miss;
  84.         int         hash_chain;
  85. } hist_info;
  86.  
  87. typedef hist_entry*      hist_entry_ptr;
  88. typedef opt_table_entry* opt_table_entry_ptr;
  89.  
  90. /* Function prototypes */
  91.  
  92. void optimize_palette(spr_info_str*, spr_info_str*);
  93. hist_info *build_histogram(spr_info_str*);
  94.  
  95. #endif
  96.  
  97.  
  98.