MRaster lib 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
MRcolor.hpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file MRcolor.hpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief User include file for color types@EOL
7 @copyright
8 @parblock
9 Copyright (c) 1988-2015, Mitchell Jay Richling <https://www.mitchr.me> All rights reserved.
10
11 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
14
15 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17
18 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software
19 without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 DAMAGE.
27 @endparblock
28*/
29/*******************************************************************************************************************************************************.H.E.**/
30
31#ifndef MJR_INCLUDE_MRcolor
32
33#include <cstdint> /* std:: C stdint.h C++11 */
34#include <limits> /* C++ Numeric limits C++11 */
35
36#include "MRcolorTpl.hpp"
37
38// Put everything in the mjr namespace
39namespace mjr {
40
41 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
42 /** @name Channel Types */
43 //@{
44 typedef uint8_t colChanI8; //!< Type suitable for 8-bit unsigned color channels
45 typedef uint16_t colChanI16; //!< Type suitable for 16-bit unsigned color channels
46 typedef uint32_t colChanI32; //!< Type suitable for 32-bit unsigned color channels
47 typedef uint64_t colChanI64; //!< Type suitable for 64-bit unsigned color channels
48#ifdef MJR_HAVE_128_BIT_TYPES
49 typedef mjr_uint128_t colChanI128; //!< Type suitable for 128-bit unsigned color channels
50#endif
51
52 typedef float colChanF32; //!< Type suitable for 32-bit floating point color channels
53 typedef double colChanF64; //!< Type suitable for 64-bit floating point color channels
54 //@}
55
56 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
57 /** @name Complete Color Types@EOL
58 The following types define the most commonly used color/pixel combinations. */
59 //@{
60 typedef colorTpl<colChanI8, 1> color1c8b; //!< colorTpl: 1 Channel @ 8-bit unsigned int 8 -- 8-bit Greyscale
61 typedef colorTpl<colChanI8, 2> color2c8b; //!< colorTpl: 2 Channel @ 8-bit unsigned int 16
62 typedef colorTpl<colChanI8, 3> color3c8b; //!< colorTpl: 3 Channel @ 8-bit unsigned int 24 -- 24-bit RGB (truecolor)
63 typedef colorTpl<colChanI8, 4> color4c8b; //!< colorTpl: 4 Channel @ 8-bit unsigned int 32 -- 24-bit RGBA (truecolor)
64 typedef colorTpl<colChanI8, 5> color5c8b; //!< colorTpl: 5 Channel @ 8-bit unsigned int 40
65 typedef colorTpl<colChanI8, 6> color6c8b; //!< colorTpl: 6 Channel @ 8-bit unsigned int 48
66 typedef colorTpl<colChanI8, 7> color7c8b; //!< colorTpl: 7 Channel @ 8-bit unsigned int 56
67 typedef colorTpl<colChanI8, 8> color8c8b; //!< colorTpl: 8 Channel @ 8-bit unsigned int 64
68 typedef colorTpl<colChanI8, 16> color16c8b; //!< colorTpl: 16 Channel @ 8-bit unsigned int 128
69 typedef colorTpl<colChanI8, 32> color32c8b; //!< colorTpl: 32 Channel @ 8-bit unsigned int 256
70 typedef colorTpl<colChanI8, 64> color64c8b; //!< colorTpl: 64 Channel @ 8-bit unsigned int 512
71
72 typedef colorTpl<colChanI16, 1> color1c16b; //!< colorTpl: 1 Channel @ 16-bit unsigned int 16 -- 16-bit Greyscale
73 typedef colorTpl<colChanI16, 2> color2c16b; //!< colorTpl: 2 Channel @ 16-bit unsigned int 32
74 typedef colorTpl<colChanI16, 3> color3c16b; //!< colorTpl: 3 Channel @ 16-bit unsigned int 48 -- 48-bit RGB
75 typedef colorTpl<colChanI16, 4> color4c16b; //!< colorTpl: 4 Channel @ 16-bit unsigned int 64 -- 48-bit RGBA
76 typedef colorTpl<colChanI16, 8> color8c16b; //!< colorTpl: 8 Channel @ 16-bit unsigned int 128
77 typedef colorTpl<colChanI16, 16> color16c16b; //!< colorTpl: 16 Channel @ 16-bit unsigned int 256
78 typedef colorTpl<colChanI16, 32> color32c16b; //!< colorTpl: 32 Channel @ 16-bit unsigned int 512
79
80 typedef colorTpl<colChanI32, 1> color1c32b; //!< colorTpl: 1 Channel @ 32-bit unsigned int 32 -- 32-bit Greyscale
81 typedef colorTpl<colChanI32, 2> color2c32b; //!< colorTpl: 2 Channel @ 32-bit unsigned int 64
82 typedef colorTpl<colChanI32, 3> color3c32b; //!< colorTpl: 3 Channel @ 32-bit unsigned int 96 -- 96-bit RGB
83 typedef colorTpl<colChanI32, 4> color4c32b; //!< colorTpl: 4 Channel @ 32-bit unsigned int 128 -- 96-bit RGBA
84 typedef colorTpl<colChanI32, 8> color8c32b; //!< colorTpl: 8 Channel @ 32-bit unsigned int 256
85 typedef colorTpl<colChanI32, 16> color16c32b; //!< colorTpl: 16 Channel @ 32-bit unsigned int 512
86
87 typedef colorTpl<colChanI64, 1> color1c64b; //!< colorTpl: 1 Channel @ 64-bit unsigned int 64 -- 64-bit Greyscale
88 typedef colorTpl<colChanI64, 2> color2c64b; //!< colorTpl: 2 Channel @ 64-bit unsigned int 128
89 typedef colorTpl<colChanI64, 3> color3c64b; //!< colorTpl: 3 Channel @ 64-bit unsigned int 192 -- 192-bit RGB
90 typedef colorTpl<colChanI64, 4> color4c64b; //!< colorTpl: 4 Channel @ 64-bit unsigned int 256 -- 192-bit RGBA
91 typedef colorTpl<colChanI64, 8> color8c64b; //!< colorTpl: 8 Channel @ 64-bit unsigned int 512
92
93#ifdef MJR_HAVE_128_BIT_TYPES
94 typedef colorTpl<colChanI128, 1> color1c128b; //!< colorTpl: 1 Channel @ 128-bit unsigned int 128 -- 128-bit Greyscale
95 typedef colorTpl<colChanI128, 2> color2c128b; //!< colorTpl: 2 Channel @ 128-bit unsigned int 256
96 typedef colorTpl<colChanI128, 3> color3c128b; //!< colorTpl: 3 Channel @ 128-bit unsigned int 384 -- 384-bit RGB
97 typedef colorTpl<colChanI128, 4> color4c128b; //!< colorTpl: 4 Channel @ 128-bit unsigned int 512 -- 192-bit RGBA
98#endif
99
100 typedef colorTpl<colChanF32, 1> color1c32F; //!< colorTpl: 1 Channel @ 32-bit floating point 32 -- 32-bit Floating Greyscale
101 typedef colorTpl<colChanF32, 2> color2c32F; //!< colorTpl: 2 Channel @ 32-bit floating point 64
102 typedef colorTpl<colChanF32, 3> color3c32F; //!< colorTpl: 3 Channel @ 32-bit floating point 96 -- 96-bit Floating RGB
103 typedef colorTpl<colChanF32, 4> color4c32F; //!< colorTpl: 4 Channel @ 32-bit floating point 128 -- 96-bit Floating RGBA
104 typedef colorTpl<colChanF32, 8> color8c32F; //!< colorTpl: 8 Channel @ 32-bit floating point 256
105 typedef colorTpl<colChanF32, 16> color16c32F; //!< colorTpl: 16 Channel @ 32-bit floating point 512
106
107 typedef colorTpl<colChanF64, 1> color1c64F; //!< colorTpl: 1 Channel @ 64-bit floating point 64 -- 64-bit Floating Greyscale
108 typedef colorTpl<colChanF64, 2> color2c64F; //!< colorTpl: 2 Channel @ 64-bit floating point 128
109 typedef colorTpl<colChanF64, 3> color3c64F; //!< colorTpl: 3 Channel @ 64-bit floating point 192 -- 192-bit Floating RGB
110 typedef colorTpl<colChanF64, 4> color4c64F; //!< colorTpl: 4 Channel @ 64-bit floating point 256 -- 256-bit Floating RGBA
111 typedef colorTpl<colChanF64, 8> color8c64F; //!< colorTpl: 8 Channel @ 64-bit floating point 512
112 //@}
113
114 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
115 /** @name Complete Color Types with Traditional Names@EOL
116 Many people prefere to use tranditional, RGB/greyscale names for color types. */
117 //@{
118 typedef color4c8b colorRGBA8b; //!< colorTpl: RGBA (8-bit int/channel) (truecolor)
119 typedef color4c16b colorRGBA16b; //!< colorTpl: RGBA (16-bit int/channel)
120 typedef color4c32b colorRGBA32b; //!< colorTpl: RGBA (32-bit int/channel)
121 typedef color4c64b colorRGBA64b; //!< colorTpl: RGBA (64-bit int/channel)
122
123 typedef color4c32F colorRGBA32F; //!< colorTpl: RGBA (32-bit float/channel)
124 typedef color4c64F colorRGBA64F; //!< colorTpl: RGBA (64-bit float/channel)
125
126 typedef color3c8b colorRGB8b; //!< colorTpl: RGB (8-bit int/channel) (truecolor)
127 typedef color3c16b colorRGB16b; //!< colorTpl: RGB (16-bit int/channel)
128 typedef color3c32b colorRGB32b; //!< colorTpl: RGB (32-bit int/channel)
129 typedef color3c64b colorRGB64b; //!< colorTpl: RGB (64-bit int/channel)
130
131 typedef color3c32F colorRGB32F; //!< colorTpl: RGB (32-bit float/channel)
132 typedef color3c64F colorRGB64F; //!< colorTpl: RGB (64-bit float/channel)
133
134 typedef color1c8b colorGrey8b; //!< colorTpl: 8-bit int Greyscale
135 typedef color1c16b colorGrey16b; //!< colorTpl: 16-bit int Greyscale
136 typedef color1c32b colorGrey32b; //!< colorTpl: 32-bit int Greyscale
137 typedef color1c64b colorGrey64b; //!< colorTpl: 64-bit int Greyscale
138#ifdef MJR_HAVE_128_BIT_TYPES
139 typedef color1c128b colorGrey128b; //!< colorTpl: 128-bit int Greyscale
140#endif
141
142 typedef color1c32F colorGrey32F; //!< colorTpl: 32-bit float Greyscale
143 typedef color1c64F colorGrey64F; //!< colorTpl: 64-bit float Greyscale
144 //@}
145
146 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
147 /** @name Complete Color Types with 8-bit channels and commonly used orderings for R, G, B, & A@EOL
148 These are commonly used by libraries like Cairo, Open GL, SDL, etc... */
149 //@{
150 typedef colorTpl<colChanI8, 3, 2, 1, 0> colorBGR8b; //!< colorTpl: 3 Channel @ 8-bit unsigned int 24
151
152 typedef colorTpl<colChanI8, 4, 1, 2, 3, 0> colorARGB8b; //!< colorTpl: 4 Channel @ 8-bit unsigned int 32
153 typedef colorTpl<colChanI8, 4, 2, 1, 0, 3> colorBGRA8b; //!< colorTpl: 4 Channel @ 8-bit unsigned int 32
154 typedef colorTpl<colChanI8, 4, 3, 2, 1, 0> colorABGR8b; //!< colorTpl: 4 Channel @ 8-bit unsigned int 32
155 //@}
156
157} // end namespace mjr
158
159#define MJR_INCLUDE_MRcolor
160#endif
Header for the ramColor class.
Template Class used to house colors for ramCanvas objects.
colorTpl< colChanF32, 3 > color3c32F
colorTpl: 3 Channel @ 32-bit floating point 96 – 96-bit Floating RGB
Definition MRcolor.hpp:102
colorTpl< colChanI64, 8 > color8c64b
colorTpl: 8 Channel @ 64-bit unsigned int 512
Definition MRcolor.hpp:91
double colChanF64
Type suitable for 64-bit floating point color channels.
Definition MRcolor.hpp:53
colorTpl< colChanI32, 8 > color8c32b
colorTpl: 8 Channel @ 32-bit unsigned int 256
Definition MRcolor.hpp:84
colorTpl< colChanI8, 3 > color3c8b
colorTpl: 3 Channel @ 8-bit unsigned int 24 – 24-bit RGB (truecolor)
Definition MRcolor.hpp:62
colorTpl< colChanI16, 32 > color32c16b
colorTpl: 32 Channel @ 16-bit unsigned int 512
Definition MRcolor.hpp:78
colorTpl< colChanI8, 2 > color2c8b
colorTpl: 2 Channel @ 8-bit unsigned int 16
Definition MRcolor.hpp:61
colorTpl< colChanF64, 1 > color1c64F
colorTpl: 1 Channel @ 64-bit floating point 64 – 64-bit Floating Greyscale
Definition MRcolor.hpp:107
colorTpl< colChanI8, 4, 1, 2, 3, 0 > colorARGB8b
colorTpl: 4 Channel @ 8-bit unsigned int 32
Definition MRcolor.hpp:152
color1c64b colorGrey64b
colorTpl: 64-bit int Greyscale
Definition MRcolor.hpp:137
color4c32b colorRGBA32b
colorTpl: RGBA (32-bit int/channel)
Definition MRcolor.hpp:120
colorTpl< colChanI32, 3 > color3c32b
colorTpl: 3 Channel @ 32-bit unsigned int 96 – 96-bit RGB
Definition MRcolor.hpp:82
colorTpl< colChanI16, 1 > color1c16b
colorTpl: 1 Channel @ 16-bit unsigned int 16 – 16-bit Greyscale
Definition MRcolor.hpp:72
colorTpl< colChanF64, 8 > color8c64F
colorTpl: 8 Channel @ 64-bit floating point 512
Definition MRcolor.hpp:111
color4c32F colorRGBA32F
colorTpl: RGBA (32-bit float/channel)
Definition MRcolor.hpp:123
colorTpl< colChanF32, 4 > color4c32F
colorTpl: 4 Channel @ 32-bit floating point 128 – 96-bit Floating RGBA
Definition MRcolor.hpp:103
colorTpl< colChanF64, 4 > color4c64F
colorTpl: 4 Channel @ 64-bit floating point 256 – 256-bit Floating RGBA
Definition MRcolor.hpp:110
color3c16b colorRGB16b
colorTpl: RGB (16-bit int/channel)
Definition MRcolor.hpp:127
colorTpl< colChanI32, 4 > color4c32b
colorTpl: 4 Channel @ 32-bit unsigned int 128 – 96-bit RGBA
Definition MRcolor.hpp:83
colorTpl< colChanI8, 16 > color16c8b
colorTpl: 16 Channel @ 8-bit unsigned int 128
Definition MRcolor.hpp:68
color4c8b colorRGBA8b
colorTpl: RGBA (8-bit int/channel) (truecolor)
Definition MRcolor.hpp:118
color1c32b colorGrey32b
colorTpl: 32-bit int Greyscale
Definition MRcolor.hpp:136
colorTpl< colChanI16, 8 > color8c16b
colorTpl: 8 Channel @ 16-bit unsigned int 128
Definition MRcolor.hpp:76
colorTpl< colChanI16, 2 > color2c16b
colorTpl: 2 Channel @ 16-bit unsigned int 32
Definition MRcolor.hpp:73
color3c32b colorRGB32b
colorTpl: RGB (32-bit int/channel)
Definition MRcolor.hpp:128
colorTpl< colChanF32, 2 > color2c32F
colorTpl: 2 Channel @ 32-bit floating point 64
Definition MRcolor.hpp:101
colorTpl< colChanI32, 1 > color1c32b
colorTpl: 1 Channel @ 32-bit unsigned int 32 – 32-bit Greyscale
Definition MRcolor.hpp:80
uint64_t colChanI64
Type suitable for 64-bit unsigned color channels.
Definition MRcolor.hpp:47
color1c8b colorGrey8b
colorTpl: 8-bit int Greyscale
Definition MRcolor.hpp:134
colorTpl< colChanI16, 16 > color16c16b
colorTpl: 16 Channel @ 16-bit unsigned int 256
Definition MRcolor.hpp:77
float colChanF32
Type suitable for 32-bit floating point color channels.
Definition MRcolor.hpp:52
colorTpl< colChanI64, 2 > color2c64b
colorTpl: 2 Channel @ 64-bit unsigned int 128
Definition MRcolor.hpp:88
uint16_t colChanI16
Type suitable for 16-bit unsigned color channels.
Definition MRcolor.hpp:45
colorTpl< colChanI8, 6 > color6c8b
colorTpl: 6 Channel @ 8-bit unsigned int 48
Definition MRcolor.hpp:65
color1c64F colorGrey64F
colorTpl: 64-bit float Greyscale
Definition MRcolor.hpp:143
colorTpl< colChanI64, 3 > color3c64b
colorTpl: 3 Channel @ 64-bit unsigned int 192 – 192-bit RGB
Definition MRcolor.hpp:89
color3c64b colorRGB64b
colorTpl: RGB (64-bit int/channel)
Definition MRcolor.hpp:129
colorTpl< colChanI16, 4 > color4c16b
colorTpl: 4 Channel @ 16-bit unsigned int 64 – 48-bit RGBA
Definition MRcolor.hpp:75
color4c16b colorRGBA16b
colorTpl: RGBA (16-bit int/channel)
Definition MRcolor.hpp:119
colorTpl< colChanI8, 4, 3, 2, 1, 0 > colorABGR8b
colorTpl: 4 Channel @ 8-bit unsigned int 32
Definition MRcolor.hpp:154
colorTpl< colChanI8, 4 > color4c8b
colorTpl: 4 Channel @ 8-bit unsigned int 32 – 24-bit RGBA (truecolor)
Definition MRcolor.hpp:63
colorTpl< colChanI64, 4 > color4c64b
colorTpl: 4 Channel @ 64-bit unsigned int 256 – 192-bit RGBA
Definition MRcolor.hpp:90
uint8_t colChanI8
Type suitable for 8-bit unsigned color channels.
Definition MRcolor.hpp:44
colorTpl< colChanI8, 64 > color64c8b
colorTpl: 64 Channel @ 8-bit unsigned int 512
Definition MRcolor.hpp:70
colorTpl< colChanI8, 4, 2, 1, 0, 3 > colorBGRA8b
colorTpl: 4 Channel @ 8-bit unsigned int 32
Definition MRcolor.hpp:153
colorTpl< colChanI8, 7 > color7c8b
colorTpl: 7 Channel @ 8-bit unsigned int 56
Definition MRcolor.hpp:66
colorTpl< colChanI8, 32 > color32c8b
colorTpl: 32 Channel @ 8-bit unsigned int 256
Definition MRcolor.hpp:69
colorTpl< colChanI8, 3, 2, 1, 0 > colorBGR8b
colorTpl: 3 Channel @ 8-bit unsigned int 24
Definition MRcolor.hpp:150
color3c32F colorRGB32F
colorTpl: RGB (32-bit float/channel)
Definition MRcolor.hpp:131
color4c64F colorRGBA64F
colorTpl: RGBA (64-bit float/channel)
Definition MRcolor.hpp:124
colorTpl< colChanI8, 8 > color8c8b
colorTpl: 8 Channel @ 8-bit unsigned int 64
Definition MRcolor.hpp:67
colorTpl< colChanF32, 1 > color1c32F
colorTpl: 1 Channel @ 32-bit floating point 32 – 32-bit Floating Greyscale
Definition MRcolor.hpp:100
color4c64b colorRGBA64b
colorTpl: RGBA (64-bit int/channel)
Definition MRcolor.hpp:121
colorTpl< colChanF32, 16 > color16c32F
colorTpl: 16 Channel @ 32-bit floating point 512
Definition MRcolor.hpp:105
colorTpl< colChanF32, 8 > color8c32F
colorTpl: 8 Channel @ 32-bit floating point 256
Definition MRcolor.hpp:104
colorTpl< colChanI32, 16 > color16c32b
colorTpl: 16 Channel @ 32-bit unsigned int 512
Definition MRcolor.hpp:85
colorTpl< colChanI32, 2 > color2c32b
colorTpl: 2 Channel @ 32-bit unsigned int 64
Definition MRcolor.hpp:81
colorTpl< colChanI16, 3 > color3c16b
colorTpl: 3 Channel @ 16-bit unsigned int 48 – 48-bit RGB
Definition MRcolor.hpp:74
colorTpl< colChanI8, 5 > color5c8b
colorTpl: 5 Channel @ 8-bit unsigned int 40
Definition MRcolor.hpp:64
color1c32F colorGrey32F
colorTpl: 32-bit float Greyscale
Definition MRcolor.hpp:142
color3c8b colorRGB8b
colorTpl: RGB (8-bit int/channel) (truecolor)
Definition MRcolor.hpp:126
colorTpl< colChanI8, 1 > color1c8b
colorTpl: 1 Channel @ 8-bit unsigned int 8 – 8-bit Greyscale
Definition MRcolor.hpp:60
color3c64F colorRGB64F
colorTpl: RGB (64-bit float/channel)
Definition MRcolor.hpp:132
color1c16b colorGrey16b
colorTpl: 16-bit int Greyscale
Definition MRcolor.hpp:135
colorTpl< colChanI64, 1 > color1c64b
colorTpl: 1 Channel @ 64-bit unsigned int 64 – 64-bit Greyscale
Definition MRcolor.hpp:87
colorTpl< colChanF64, 3 > color3c64F
colorTpl: 3 Channel @ 64-bit floating point 192 – 192-bit Floating RGB
Definition MRcolor.hpp:109
uint32_t colChanI32
Type suitable for 32-bit unsigned color channels.
Definition MRcolor.hpp:46
colorTpl< colChanF64, 2 > color2c64F
colorTpl: 2 Channel @ 64-bit floating point 128
Definition MRcolor.hpp:108