File: colour.c

package info (click to toggle)
minc 2.1.10-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 8,160 kB
  • sloc: ansic: 82,507; sh: 10,666; yacc: 1,187; perl: 612; makefile: 586; lex: 319
file content (173 lines) | stat: -rw-r--r-- 5,346 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/* ----------------------------------------------------------------------------
@COPYRIGHT  :
              Copyright 1993,1994,1995 David MacDonald,
              McConnell Brain Imaging Centre,
              Montreal Neurological Institute, McGill University.
              Permission to use, copy, modify, and distribute this
              software and its documentation for any purpose and without
              fee is hereby granted, provided that the above copyright
              notice appear in all copies.  The author and McGill University
              make no representations about the suitability of this
              software for any purpose.  It is provided "as is" without
              express or implied warranty.
---------------------------------------------------------------------------- */

#include  <internal_volume_io.h>

/* ----------------------------- MNI Header -----------------------------------
@NAME       : make_Colour
@INPUT      : r
              g
              b
@OUTPUT     : 
@RETURNS    : Colour
@DESCRIPTION: Packs the three components, which are in the range 0 to 255,
              into a Colour type, unsigned long.
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : May 10, 1995        D. MacDonald
@MODIFIED   : 
---------------------------------------------------------------------------- */

VIOAPI  Colour  make_Colour(
    int   r,
    int   g,
    int   b )
{
    return( make_rgba_Colour( r, g, b, 255 ) );
}

/* ----------------------------- MNI Header -----------------------------------
@NAME       : get_Colour_r_0_1
@INPUT      : colour
@OUTPUT     : 
@RETURNS    : red component
@DESCRIPTION: Returns the red component of the colour in the range of 0.0 to 1.0
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : May 10, 1995        D. MacDonald
@MODIFIED   : 
---------------------------------------------------------------------------- */

VIOAPI  Real  get_Colour_r_0_1(
    Colour   colour )
{
    return( (Real) get_Colour_r(colour) / 255.0 );
}

/* ----------------------------- MNI Header -----------------------------------
@NAME       : get_Colour_g_0_1
@INPUT      : colour
@OUTPUT     : 
@RETURNS    : green component
@DESCRIPTION: Returns the green component of the colour in the range of
              0.0 to 1.0
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : May 10, 1995        D. MacDonald
@MODIFIED   : 
---------------------------------------------------------------------------- */

VIOAPI  Real  get_Colour_g_0_1(
    Colour   colour )
{
    return( (Real) get_Colour_g(colour) / 255.0 );
}

/* ----------------------------- MNI Header -----------------------------------
@NAME       : get_Colour_b_0_1
@INPUT      : colour
@OUTPUT     : 
@RETURNS    : blue component
@DESCRIPTION: Returns the blue component of the colour in the range of
              0.0 to 1.0
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : May 10, 1995        D. MacDonald
@MODIFIED   : 
---------------------------------------------------------------------------- */

VIOAPI  Real  get_Colour_b_0_1(
    Colour   colour )
{
    return( (Real) get_Colour_b(colour) / 255.0 );
}

/* ----------------------------- MNI Header -----------------------------------
@NAME       : get_Colour_a_0_1
@INPUT      : colour
@OUTPUT     : 
@RETURNS    : alpha component
@DESCRIPTION: Returns the alpha (opacity) component of the colour in the
              range of 0.0 to 1.0
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : May 10, 1995        D. MacDonald
@MODIFIED   : 
---------------------------------------------------------------------------- */

VIOAPI  Real  get_Colour_a_0_1(
    Colour   colour )
{
    return( (Real) get_Colour_a(colour) / 255.0 );
}

/* ----------------------------- MNI Header -----------------------------------
@NAME       : make_Colour_0_1
@INPUT      : r
              g
              b
@OUTPUT     : 
@RETURNS    : Colour
@DESCRIPTION: Takes the three components, each in the range of 0 to 1,
              and packs them into a colour.
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : May 10, 1995        D. MacDonald
@MODIFIED   : 
---------------------------------------------------------------------------- */

VIOAPI  Colour  make_Colour_0_1(
    Real   r,
    Real   g,
    Real   b )
{
    return( make_Colour( (int) (r * 255.0 + 0.5),
                         (int) (g * 255.0 + 0.5),
                         (int) (b * 255.0 + 0.5) ) );
}

/* ----------------------------- MNI Header -----------------------------------
@NAME       : make_rgba_Colour_0_1
@INPUT      : r
              g
              b
              a       - alpha (opacity)
@OUTPUT     : 
@RETURNS    : Colour
@DESCRIPTION: Takes the four components, each in the range of 0 to 1,
              and packs them into a colour.
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : May 10, 1995        D. MacDonald
@MODIFIED   : 
---------------------------------------------------------------------------- */

VIOAPI  Colour  make_rgba_Colour_0_1(
    Real   r,
    Real   g,
    Real   b,
    Real   a )
{
    return( make_rgba_Colour( (int) (r * 255.0 + 0.5),
                              (int) (g * 255.0 + 0.5),
                              (int) (b * 255.0 + 0.5),
                              (int) (a * 255.0 + 0.5) ) );
}