1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Add (interpolate) three additional colors.
11
(1) The first input color.
12
(2) The second input color.
13
(3) Pointer to GUIS structure.
14
(4) Pointer to the first output color.
15
(5) Pointer to the second output color.
16
(6) Pointer to the third output color.
19
(1) The first output color prepared.
20
(2) The second output color prepared.
21
(3) The third output color prepared.
26
=============================================================================*/
31
#include <X11/Xutil.h>
33
#include <X11/Xatom.h>
38
/*======add (interpolate) three colors:======================================*/
40
void AddThreeColors_ (unsigned long input_color1ID,
41
unsigned long input_color2ID,
43
unsigned long *output_color1IDP,
44
unsigned long *output_color2IDP,
45
unsigned long *output_color3IDP)
47
unsigned long red_mask, green_mask, blue_mask;
48
unsigned long red1, red2, red;
49
unsigned long green1, green2, green;
50
unsigned long blue1, blue2, blue;
51
double r1, r2, g1, g2, b1, b2;
52
static double w1 = 0.75, w2 = 0.25, w3 = 0.50;
56
red_mask = guiSP->visual_infoS.red_mask;
57
green_mask = guiSP->visual_infoS.green_mask;
58
blue_mask = guiSP->visual_infoS.blue_mask;
60
/* Extract input color components: */
61
red1 = input_color1ID & red_mask;
62
red2 = input_color2ID & red_mask;
63
green1 = input_color1ID & green_mask;
64
green2 = input_color2ID & green_mask;
65
blue1 = input_color1ID & blue_mask;
66
blue2 = input_color2ID & blue_mask;
68
/* Convert to doubles: */
76
/* The first output color (components): */
77
r = w1 * r1 + w2 * r2;
78
g = w1 * g1 + w2 * g2;
79
b = w1 * b1 + w2 * b2;
80
red = ((unsigned long) r) & red_mask;
81
green = ((unsigned long) g) & green_mask;
82
blue = ((unsigned long) b) & blue_mask;
84
/* The first output color (value): */
85
*output_color1IDP = red | green | blue;
87
/* The second output color (components): */
91
red = ((unsigned long) r) & red_mask;
92
green = ((unsigned long) g) & green_mask;
93
blue = ((unsigned long) b) & blue_mask;
95
/* The second output color (value): */
96
*output_color2IDP = red | green | blue;
98
/* The third output color (components): */
99
r = w2 * r1 + w1 * r2;
100
g = w2 * g1 + w1 * g2;
101
b = w2 * b1 + w1 * b2;
102
red = ((unsigned long) r) & red_mask;
103
green = ((unsigned long) g) & green_mask;
104
blue = ((unsigned long) b) & blue_mask;
106
/* The third output color (value): */
107
*output_color3IDP = red | green | blue;
111
/*===========================================================================*/