HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMG_FileTypes.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: IMG_Types.h ( IMG Library, C++)
7  *
8  * COMMENTS: IMG data types
9  */
10 
11 #ifndef __IMG_FILE_TYPES__
12 #define __IMG_FILE_TYPES__
13 
14 #include "IMG_API.h"
15 #include <PXL/PXL_Common.h>
16 
18 {
20 
21  // Allow bit masking of types so formats can specify which types they
22  // support.
23  IMG_DT_ANY = 0x00,
24 
25  // All integer data types are unsigned.
26  IMG_UCHAR = 0x01, IMG_INT8 = 0x01,
27  IMG_USHORT = 0x02, IMG_INT16 = 0x02,
28  IMG_UINT = 0x04, IMG_INT32 = 0x04,
29 
30  IMG_FLOAT = 0x08, IMG_FLOAT32 = 0x08,
31  IMG_HALF = 0x10, IMG_FLOAT16 = 0x10
32 };
33 
36 
37 
38 /// How the channel data should be interpreted.
40 {
46  IMG_TI_SAMPLE_COUNT // Deep sample count pseudo-plane
47 };
48 
49 IMG_API const char *IMGgetNameFromTypeInfo(IMG_TypeInfo type_info);
51 
52 
54 {
56 
58 
59  // basic channel configurations
60  IMG_1CHAN = 0x01,
61  IMG_2CHAN = 0x02,
62  IMG_RGB = 0x04,
63  IMG_RGBA = 0x08,
64 
65  // extension bits
67 
68  // commonly reversed formats
71 };
72 
73 IMG_API const char *IMGgetNameFromColorModel(IMG_ColorModel type_info);
75 
76 
78 {
82 };
83 
85 {
89 };
90 
91 #define IMG_DT_ALL ((IMG_DataType)0x1F)
92 
93 static inline int IMGbyteSize(IMG_DataType dt)
94  {
95  if(dt == IMG_INT16 || dt == IMG_FLOAT16)
96  return 2;
97  else if(dt == IMG_FLOAT32 || dt == IMG_INT32)
98  return 4;
99  return 1;
100  }
101 
102 static inline PXL_DataFormat IMGformatToPXL(IMG_DataType dt)
103 {
104  switch(dt)
105  {
106  case IMG_INT8: return PXL_INT8;
107  case IMG_INT16: return PXL_INT16;
108  case IMG_INT32: return PXL_INT32;
109  case IMG_FLOAT32: return PXL_FLOAT32;
110  case IMG_FLOAT16: return PXL_FLOAT16;
111  default: return PXL_MAX_DATA_FORMAT;
112  }
113  // unknown format.
114  return PXL_MAX_DATA_FORMAT;
115 }
116 
117 static inline IMG_DataType IMGformatFromPXL(PXL_DataFormat dt)
118 {
119  switch(dt)
120  {
121  case PXL_INT8: return IMG_INT8;
122  case PXL_INT16: return IMG_INT16;
123  case PXL_INT32: return IMG_INT32;
124  case PXL_FLOAT32: return IMG_FLOAT32;
125  case PXL_FLOAT16: return IMG_FLOAT16;
126  default: return IMG_DT_ANY;
127  }
128  // unknown format.
129  return IMG_DT_ANY;
130 }
131 
132 static inline IMG_ColorModel IMGcolorModelFromPXL(PXL_Packing pack)
133 {
134  switch(pack)
135  {
136  case PACK_SINGLE: return IMG_1CHAN;
137  case PACK_DUAL:
138  case PACK_DUAL_NI: return IMG_2CHAN;
139  case PACK_RGB:
140  case PACK_RGB_NI: return IMG_RGB;
141  case PACK_RGBA:
142  case PACK_RGBA_NI: return IMG_RGBA;
143  default: return IMG_CM_ANY;
144  }
145 }
146 
147 static inline PXL_Packing IMGcolorModelToPXL(IMG_ColorModel cm,
148  bool interleave = true)
149 {
150  switch(cm)
151  {
152  case IMG_1CHAN: return PACK_SINGLE;
153  case IMG_2CHAN: return interleave ? PACK_DUAL : PACK_DUAL_NI;
154  case IMG_RGB: return interleave ? PACK_RGB : PACK_RGB_NI;
155  case IMG_RGBA: return interleave ? PACK_RGBA : PACK_RGBA_NI;
156  default: return PACK_UNKNOWN;
157  }
158 }
159 
160 static inline IMG_Interleave IMGinterleaveFromPXL(PXL_Packing pack)
161 {
162  switch(pack)
163  {
164  case PACK_DUAL:
165  case PACK_RGB:
166  case PACK_RGBA: return IMG_INTERLEAVED;
167  case PACK_DUAL_NI:
168  case PACK_RGB_NI:
169  case PACK_RGBA_NI: return IMG_NON_INTERLEAVED;
170  default: return IMG_INTERLEAVE_AS_IS;
171  }
172 }
173 
174 //
175 // ------------------------------------------------------------------------
176 //
177 
178 // size mask
179 #define IMG_CM_SIZE 0x0F
180 #define IMG_CM_ALL ((IMG_ColorModel)0x0F)
181 
182 static inline int IMGvectorSize(IMG_ColorModel cm)
183  {
184  int num;
185  int sb = (cm & IMG_CM_SIZE);
186 
187  if(sb == IMG_1CHAN)
188  num=1;
189  else if(sb == IMG_2CHAN)
190  num=2;
191  else if(sb == IMG_RGB)
192  num=3;
193  else if(sb == IMG_RGBA)
194  num=4;
195  else
196  num=0;
197  return num;
198  }
199 
200 static inline bool IMGisReversed(IMG_ColorModel cm)
201  { return ((bool)(cm & IMG_CM_REVERSED)); }
202 
203 static inline IMG_ColorModel
204 IMGcolorModelFromVectorSize(int vsize)
205 {
206  switch(vsize)
207  {
208  case 1: return IMG_1CHAN;
209  case 2: return IMG_2CHAN;
210  case 3: return IMG_RGB;
211  case 4: return IMG_RGBA;
212  }
213  return IMG_CM_UNDEFINED;
214 }
215 
216 //
217 // ------------------------------------------------------------------------
218 //
219 
220 // Image Orientation enums.
222 {
226 };
227 
229 {
233 };
234 
235 // Deep Raster RGBA preference
237 {
241 };
242 
243 // return enum for the IMG_File::getAlphaInfo() method, triggered by
244 // IMG_FileParms::detectTrivialAlpha()
246 {
247  IMG_ALPHA_OPAQUE, // constant 1
248  IMG_ALPHA_CONSTANT, // constant valued
249  IMG_ALPHA_CUTOUT, // either 1.0 or 0.0
251  IMG_ALPHA_OUT_OF_BOUNDS, // < 0.0 or > 1.0
252  IMG_ALPHA_NONE // no alpha channel
253 };
254 
255 /// Type of image we want to create or have opened.
257 {
258  IMG_TYPE_2D = 1 << 0, ///> The image is a 2D image.
259  IMG_TYPE_DEEP_PIXEL = 1 << 1 ///> The image is a deep pixel image.
260 };
261 
262 
263 // Depth interpolation settings for deep pixel images.
265 {
269 };
270 
273 
274 
275 #endif
276 
IMG_ImageType
Type of image we want to create or have opened.
IMG_XOrientation
#define IMG_CM_SIZE
IMG_API IMG_DataType IMGgetDataTypeFromName(const char *name)
IMG_DeepRasterColor
IMG_TypeInfo
How the channel data should be interpreted.
Definition: IMG_FileTypes.h:39
IMG_API const char * IMGgetNameFromColorModel(IMG_ColorModel type_info)
IMG_API IMG_TypeInfo IMGgetTypeInfoFromName(const char *name)
#define IMG_API
Definition: IMG_API.h:10
IMG_DataType
Definition: IMG_FileTypes.h:17
IMG_API IMG_ColorModel IMGgetColorModelFromName(const char *name)
PXL_Packing
Definition: PXL_Common.h:29
GLuint const GLchar * name
Definition: glcorearb.h:785
PXL_DataFormat
Definition: PXL_Common.h:19
IMG_FileAlphaInfo
IMG_YOrientation
IMG_API const char * IMGgetNameFromDataType(IMG_DataType type)
IMG_DepthInterp
The image is a 2D image.
IMG_Interleave
Definition: IMG_FileTypes.h:77
IMG_ColorModel
Definition: IMG_FileTypes.h:53
IMG_API IMG_DepthInterp IMGgetDepthInterpFromName(const char *name)
IMG_ComponentOrder
Definition: IMG_FileTypes.h:84
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
png_infop png_uint_32 int num
Definition: png.h:2158
IMG_API const char * IMGgetNameFromTypeInfo(IMG_TypeInfo type_info)
IMG_API const char * IMGgetNameFromDepthInterp(IMG_DepthInterp type)