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

  1. /************************************************************************
  2.  *                                                                      *
  3.  * colours.h                                                            *
  4.  * =========                                                            *
  5.  *                                                                      *
  6.  * RISCOS sprite style bitmap colour matching library                   *
  7.  * Uses spr_info generic bitmap interface from sprite.c library         *
  8.  *                                                                      *
  9.  * Version 1.10 (05-May-1994)                                           *
  10.  *                                                                      *
  11.  * (C) 1994 DEEJ Technology PLC                                         *
  12.  *                                                                      *
  13.  ************************************************************************/
  14.  
  15. #ifndef __colours_h
  16. #define __colours_h
  17.  
  18. #include "sprite.h"
  19.  
  20. /*************************** Machine configuration ***************************/
  21.  
  22. #ifdef RISCOS
  23. #define REGISTER
  24. #else
  25. /* Sun & HP compilers */
  26. #define REGISTER register
  27. #define SQR_TABLE
  28. #endif
  29. #ifdef M68K
  30. #define MULT
  31. #endif
  32.  
  33. /*
  34. #define CACHE_STAT
  35. */
  36.  
  37. /********************************* Constants *********************************/
  38.  
  39. /* COLOUR weights designed to give a 16 bit intensity */
  40. #define RED_WEIGHT      19595           /* 0.299 */
  41. #define GREEN_WEIGHT    38469           /* 0.587 */
  42. #define BLUE_WEIGHT     7472            /* 0.114 */
  43. #define GREY_WEIGHT     65536           /* 1.000 */
  44. #define GREY_SHIFT      16
  45.  
  46. /* closest_rgb cache table size & hashing algorithm */
  47.  
  48. #define CACHE_SIZE    (255*21+1)
  49. #define HASH(r,g,b)    (((r & 255)<<2) + ((g & 255)<<4) + (b & 255))
  50.  
  51. /*
  52. #define CACHE_SIZE    4096
  53. #define HASH(r,g,b)    ((r & 0xC3) | ((g & 0xC3)<<2) | ((b & 0xC3)<<4))
  54.  
  55. #define CACHE_SIZE    4096
  56. #define HASH(r,g,b)     (((r & 0xF0)>>4) | (g & 0xF0) | ((b & 0xF0)<<4))
  57. */
  58.  
  59. /********************************** Macros **********************************/
  60.  
  61. /* RGB macros, for uint r,g,b - value must also be uint */
  62.  
  63. #define SPLIT_RGB(value) r = (value >>  8) & 0xFF; \
  64.                          g = (value >> 16) & 0xFF; \
  65.                          b = (value >> 24) & 0xFF;
  66.  
  67. #define JOIN_RGB(value) value = ((r<<8)+(g<<16)+(b<<24));
  68.  
  69. /* RGB range rounding for signed integer components */
  70.  
  71. #define RANGE_RGB(value) if(value<0) value=0; if(value>255) value=255
  72.  
  73. /* maximum positive integer difference */
  74. #define MAX_DIFF        0x7FFFFFFF
  75.  
  76.  
  77. /**************************** Function prototypes ****************************/
  78.  
  79. extern void     closest_rgb_func(spr_info_str*);
  80. extern pix_str *closest_rgb(spr_info_str*, pix_str*);
  81.  
  82. #endif
  83.