home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Web / Utilities / wwwcount-2.3 / combine / modulate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-02  |  2.1 KB  |  101 lines

  1. /*
  2.  *  Modulate ()
  3.  *
  4.  *  RCS:
  5.  *      $Revision: 2.3 $
  6.  *      $Date: 1996/05/03 02:21:34 $
  7.  *
  8.  *  Security:
  9.  *      Unclassified
  10.  *
  11.  *  Description:
  12.  *      From ImageMagick 
  13.  *
  14.  *  Input Parameters:
  15.  *      type    identifier  description
  16.  *
  17.  *      text
  18.  *
  19.  *  Output Parameters:
  20.  *      type    identifier  description
  21.  *
  22.  *      text
  23.  *
  24.  *  Return Values:
  25.  *      value   description
  26.  *
  27.  *  Side Effects:
  28.  *      text
  29.  *
  30.  *  Limitations and Comments:
  31.  *      text
  32.  *
  33.  *  Development History:
  34.  *      who                 when        why
  35.  *      muquit@semcor.com   18-Aug-95   first cut
  36.  */
  37.  
  38. #include "combine.h"
  39. #include "defines.h"
  40.  
  41. #if __STDC__ || defined(sgi) || defined(_AIX)
  42. void XModulate (RGB *color,unsigned char red,unsigned char green,
  43.     unsigned char blue,int modulate)
  44. #else
  45. void XModulate (color,red,green,blue,modulate)
  46. RGB
  47.     *color;
  48. unsigned char
  49.     red,
  50.     green,
  51.     blue;
  52. int
  53.     modulate;
  54. #endif
  55. {
  56.     switch (modulate)
  57.     {
  58.         case HighlightModulate:
  59.         {        
  60.             color->red=(red*HighlightModulate+
  61.                 (unsigned int) (MaxRGB-HighlightModulate)*65535)/MaxRGB;
  62.             color->green=(green*HighlightModulate+
  63.                 (unsigned int) (MaxRGB-HighlightModulate)*65535)/MaxRGB;
  64.             color->blue=(blue*HighlightModulate+
  65.                 (unsigned int) (MaxRGB-HighlightModulate)*65535)/MaxRGB;
  66.             break;
  67.         }
  68.  
  69.         case ShadowModulate:
  70.         {
  71.             color->red=(red*ShadowModulate)/MaxRGB;
  72.             color->green=(green*ShadowModulate)/MaxRGB;
  73.             color->blue=(blue*ShadowModulate)/MaxRGB;
  74.             break;
  75.         }
  76.     }   /*switch*/
  77. }
  78.  
  79. #ifdef TEST
  80. void main(argc,argv)
  81. int
  82.     argc;
  83. char
  84.     **argv;
  85. {
  86.     RGB
  87.         color;
  88.  
  89.     color.red=69;
  90.     color.green=139;
  91.     color.blue=116;
  92.  
  93.     Modulate(&color,69,139,116,HighlightModulate);
  94.     (void) fprintf (stderr," R,G,B: %d,%d,%d\n",
  95.         color.red, color.green, color.blue);
  96.     Modulate(&color,69,139,116,ShadowModulate);
  97.     (void) fprintf (stderr," R,G,B: %d,%d,%d\n",
  98.         color.red, color.green, color.blue);
  99. }
  100. #endif
  101.