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
|
/* ----------------------------------------------------------------------------
@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_rgba_Colour
@INPUT : r
g
b
a
@OUTPUT :
@RETURNS : Colour
@DESCRIPTION: Packs the four components into a colour. Each component must
be in the range 0 to 255. Depending on what graphics library
is being linked with, if any, for instance, GL or OpenGL,
this library function may be overridden by another to define
the correct method of packing bytes into a colour. If no
graphics are involved, then the byte order does not matter
and the code here can be used.
@METHOD :
@GLOBALS :
@CALLS :
@CREATED : May 10, 1995 David MacDonald
@MODIFIED :
---------------------------------------------------------------------------- */
VIOAPI Colour make_rgba_Colour(
int r,
int g,
int b,
int a )
{
Colour c;
unsigned char *byte_ptr;
c = 0; /* to avoid used-before-set compiler messages */
ASSIGN_PTR(byte_ptr) = (void *) &c;
byte_ptr[0] = (unsigned char) a;
byte_ptr[1] = (unsigned char) b;
byte_ptr[2] = (unsigned char) g;
byte_ptr[3] = (unsigned char) r;
return( c );
}
/* ----------------------------- MNI Header -----------------------------------
@NAME : get_Colour_r
@INPUT : colour
@OUTPUT :
@RETURNS : red component
@DESCRIPTION: Returns the red component of the colour in the range 0 to 255.
@METHOD :
@GLOBALS :
@CALLS :
@CREATED : May 10, 1995 David MacDonald
@MODIFIED :
---------------------------------------------------------------------------- */
VIOAPI int get_Colour_r(
Colour colour )
{
unsigned char *b;
ASSIGN_PTR(b) = (void *) &colour;
return( (int) b[3] );
}
/* ----------------------------- MNI Header -----------------------------------
@NAME : get_Colour_g
@INPUT : colour
@OUTPUT :
@RETURNS : green component
@DESCRIPTION: Returns the green component of the colour in the range 0 to 255.
@METHOD :
@GLOBALS :
@CALLS :
@CREATED : May 10, 1995 David MacDonald
@MODIFIED :
---------------------------------------------------------------------------- */
VIOAPI int get_Colour_g(
Colour colour )
{
unsigned char *b;
ASSIGN_PTR(b) = (void *) &colour;
return( (int) b[2] );
}
/* ----------------------------- MNI Header -----------------------------------
@NAME : get_Colour_b
@INPUT : colour
@OUTPUT :
@RETURNS : blue component
@DESCRIPTION: Returns the blue component of the colour in the range 0 to 255.
@METHOD :
@GLOBALS :
@CALLS :
@CREATED : May 10, 1995 David MacDonald
@MODIFIED :
---------------------------------------------------------------------------- */
VIOAPI int get_Colour_b(
Colour colour )
{
unsigned char *b;
ASSIGN_PTR(b) = (void *) &colour;
return( (int) b[1] );
}
/* ----------------------------- MNI Header -----------------------------------
@NAME : get_Colour_a
@INPUT : colour
@OUTPUT :
@RETURNS : alpha component
@DESCRIPTION: Returns the alpha (opacity) component of the colour in the
range 0 to 255.
@METHOD :
@GLOBALS :
@CALLS :
@CREATED : May 10, 1995 David MacDonald
@MODIFIED :
---------------------------------------------------------------------------- */
VIOAPI int get_Colour_a(
Colour colour )
{
unsigned char *b;
ASSIGN_PTR(b) = (void *) &colour;
return( (int) b[0] );
}
|