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
50typedef enum {
53 /* Add here for format addition like CMYKA, HSV, others */
55
56typedef enum {
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
67struct icv_image {
68 uint32_t magic;
70 double *data;
73 uint16_t flags;
74};
75
76
77typedef 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 */
Header file for the BRL-CAD common definitions.
ICV_COLOR_SPACE
Definition: defines.h:50
ICV_DATA
Definition: defines.h:56
@ ICV_COLOR_SPACE_GRAY
Definition: defines.h:52
@ ICV_COLOR_SPACE_RGB
Definition: defines.h:51
@ ICV_DATA_DOUBLE
Definition: defines.h:57
@ ICV_DATA_UCHAR
Definition: defines.h:58
size_t height
Definition: defines.h:72
size_t width
Definition: defines.h:72
uint16_t flags
Definition: defines.h:73
double * data
Definition: defines.h:70
uint32_t magic
Definition: defines.h:68
float gamma_corr
Definition: defines.h:71
ICV_COLOR_SPACE color_space
Definition: defines.h:69
size_t alpha_channel
Definition: defines.h:72
size_t channels
Definition: defines.h:72