BRL-CAD
defines.h
Go to the documentation of this file.
1
/* D E F I N E S . H
2
* BRL-CAD
3
*
4
* Copyright (c) 2011-2023 United States Government as represented by
5
* the U.S. Army Research Laboratory.
6
*
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public License
9
* version 2.1 as published by the Free Software Foundation.
10
*
11
* This library is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this file; see the file named COPYING for more
18
* information.
19
*/
20
/** @addtogroup icv_defines
21
*
22
* @brief
23
* Definitions used in the LIBICV image processing library.
24
*
25
*/
26
27
#ifndef ICV_DEFINES_H
28
#define ICV_DEFINES_H
29
30
#include "
common.h
"
31
#include <stddef.h>
/* for size_t */
32
33
/** @{ */
34
/** @file icv/defines.h */
35
36
__BEGIN_DECLS
37
38
#ifndef ICV_EXPORT
39
# if defined(ICV_DLL_EXPORTS) && defined(ICV_DLL_IMPORTS)
40
# error "Only ICV_DLL_EXPORTS or ICV_DLL_IMPORTS can be defined, not both."
41
# elif defined(ICV_DLL_EXPORTS)
42
# define ICV_EXPORT COMPILER_DLLEXPORT
43
# elif defined(ICV_DLL_IMPORTS)
44
# define ICV_EXPORT COMPILER_DLLIMPORT
45
# else
46
# define ICV_EXPORT
47
# endif
48
#endif
49
50
typedef
enum
{
51
ICV_COLOR_SPACE_RGB
,
52
ICV_COLOR_SPACE_GRAY
53
/* Add here for format addition like CMYKA, HSV, others */
54
}
ICV_COLOR_SPACE
;
55
56
typedef
enum
{
57
ICV_DATA_DOUBLE
,
58
ICV_DATA_UCHAR
59
}
ICV_DATA
;
60
61
/* Define Various Flags */
62
#define ICV_NULL_IMAGE 0X0001
63
#define ICV_SANITIZED 0X0002
64
#define ICV_OPERATIONS_MODE 0x0004
65
#define ICV_UNDEFINED_1 0x0008
66
67
struct
icv_image
{
68
uint32_t
magic
;
69
ICV_COLOR_SPACE
color_space
;
70
double
*
data
;
71
float
gamma_corr
;
72
size_t
width
,
height
,
channels
,
alpha_channel
;
73
uint16_t
flags
;
74
};
75
76
77
typedef
struct
icv_image
icv_image_t
;
78
#define ICV_IMAGE_NULL ((struct icv_image *)0)
79
80
/**
81
* asserts the integrity of a icv_image_file struct.
82
*/
83
#define ICV_CK_IMAGE(_i) ICV_CKMAG(_i, ICV_IMAGE_MAGIC, "icv_image"
)
84
85
/**
86
* initializes a icv_image_file struct without allocating any memory.
87
*/
88
#define ICV_IMAGE_INIT(_i) { \
89
(_i)->magic = ICV_IMAGE_MAGIC; \
90
(_i)->width = (_i)->height = (_i)->channels = (_i)->alpha_channel = 0; \
91
(_i)->gamma_corr = 0.0; \
92
(_i)->data = NULL; \
93
}
94
95
/**
96
* returns truthfully whether a icv_image_file has been initialized.
97
*/
98
#define ICV_IMAGE_IS_INITIALIZED(_i) (((struct icv_image *)(_i) != ICV_IMAGE_NULL) && LIKELY((_i)->magic == ICV_IMAGE_MAGIC))
99
100
/* Validation Macros */
101
/**
102
* Validates input icv_struct, if failure (in validation) returns -1
103
*/
104
#define ICV_IMAGE_VAL_INT(_i) if (!ICV_IMAGE_IS_INITIALIZED(_i)) return -1
105
106
/**
107
* Validates input icv_struct, if failure (in validation) returns NULL
108
*/
109
#define ICV_IMAGE_VAL_PTR(_i) if (!ICV_IMAGE_IS_INITIALIZED(_i)) return NULL
110
111
112
/* Data conversion MACROS */
113
/**
114
* Converts to double (icv data) type from unsigned char(8bit).
115
*/
116
#define ICV_CONV_8BIT(data) ((double)(data))/255.0
117
118
__END_DECLS
119
120
/** @} */
121
122
#endif
/* ICV_DEFINES_H */
123
124
/*
125
* Local Variables:
126
* tab-width: 8
127
* mode: C
128
* indent-tabs-mode: t
129
* c-file-style: "stroustrup"
130
* End:
131
* ex: shiftwidth=4 tabstop=8
132
*/
common.h
Header file for the BRL-CAD common definitions.
ICV_COLOR_SPACE
ICV_COLOR_SPACE
Definition:
defines.h:50
ICV_DATA
ICV_DATA
Definition:
defines.h:56
ICV_COLOR_SPACE_GRAY
@ ICV_COLOR_SPACE_GRAY
Definition:
defines.h:52
ICV_COLOR_SPACE_RGB
@ ICV_COLOR_SPACE_RGB
Definition:
defines.h:51
ICV_DATA_DOUBLE
@ ICV_DATA_DOUBLE
Definition:
defines.h:57
ICV_DATA_UCHAR
@ ICV_DATA_UCHAR
Definition:
defines.h:58
icv_image
Definition:
defines.h:67
icv_image::height
size_t height
Definition:
defines.h:72
icv_image::width
size_t width
Definition:
defines.h:72
icv_image::flags
uint16_t flags
Definition:
defines.h:73
icv_image::data
double * data
Definition:
defines.h:70
icv_image::magic
uint32_t magic
Definition:
defines.h:68
icv_image::gamma_corr
float gamma_corr
Definition:
defines.h:71
icv_image::color_space
ICV_COLOR_SPACE color_space
Definition:
defines.h:69
icv_image::alpha_channel
size_t alpha_channel
Definition:
defines.h:72
icv_image::channels
size_t channels
Definition:
defines.h:72
include
icv
defines.h
Generated on Tue Mar 7 2023 23:41:50 for BRL-CAD by
1.9.3