HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMG_Plane.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_Plane.h ( IMG Library, C++)
7  *
8  * COMMENTS:
9  * Description class of a single plane in a deep raster file.
10  * IMG_Stat contains a list of IMG_Plane structures.
11  */
12 #ifndef __IMG_PLANE_INFO_H__
13 #define __IMG_PLANE_INFO_H__
14 
15 #include "IMG_API.h"
16 
17 #include <SYS/SYS_Types.h>
18 #include <UT/UT_String.h>
19 #include <UT/UT_Rect.h>
20 #include <PXL/PXL_Common.h>
21 
22 #include "IMG_FileTypes.h"
23 
24 class IMG_Stat;
25 class UT_JSONWriter;
26 
27 /// @brief standard plane names.
29 {
30  static const char *Color; // "C"
31  static const char *Alpha; // "A"
32  static const char *Opacity; // "Of"
33  static const char *Depth; // "Pz"
34  static const char *Position; // "P"
35  static const char *Normal; // "N"
36 
37  /// For deep images, this plane contains the sample count for each pixel.
38  static const char *DepthComplexity; // "Depth-Complexity"
39 };
40 
41 /// @brief Describes the format and layout of a single plane in an image
42 /// The plane specifies the format and name of a single image plane in a deep
43 /// raster image. IMG_Stat contains a list of planes found in the image.
44 /// Non-deep raster formats only contain one plane.
46 {
47 public:
48  /// @{
49  /// Planes are generally not created by the user, but by
50  /// IMG_Stat::addPlane()
51  IMG_Plane();
52  IMG_Plane(const IMG_Plane &p);
53  IMG_Plane(const char *name, IMG_DataType dt, IMG_ColorModel cm,
54  int index);
55  /// @}
56 
57  /// Returns the amount of memory owned by this IMG_Plane object
58  int64 getMemoryUsage(bool inclusive) const;
59 
60  /// @{
61  /// plane name - must be unique in the list of planes found in IMG_Stat
62  void setName(const char *name);
63  const char *getName() const;
64  /// @}
65 
66  /// @{
67  /// data format of the individual pixel components (8bit - FP)
68  void setDataType(IMG_DataType dt);
69  IMG_DataType getDataType() const;
70  /// @}
71 
72  /// @{
73  /// color model of the pixel, which specifies the components per pixel.
74  /// (SINGLE_CHAN, RGB, RGBA)
75  void setColorModel(IMG_ColorModel cm);
76  IMG_ColorModel getColorModel() const;
77  /// @}
78 
79  /// @{
80  /// type info of the data contained in the plane. This is purely an
81  /// advisory indicator on how the data should be handled.
82  /// Note that this can affect the colorspace of the plane if not COLOR.
83  void setTypeInfo(IMG_TypeInfo ti);
84  IMG_TypeInfo getTypeInfo() const;
85  /// @}
86 
87  /// @{
88  /// colorspace of the image data in the plane. This helps determine how to
89  /// display the image data. If PXL_CS_UNKNOWN is returned, the format's
90  /// colorspace will be used instead. 'gamma' is only needed for
91  /// PXL_CS_CUSTOM_GAMMA.
92  void setColorSpace(PXL_ColorSpace cs, fpreal gamma = 0.0);
93  PXL_ColorSpace getColorSpace() const;
94  fpreal getColorSpaceGamma() const;
95  /// @}
96 
97  /// @{
98  /// Sets the individual component name(s) (default: r,g,b,a). Always call
99  /// after setColorModel().
100  void setComponentNames(const char *c1,
101  const char *c2=0,
102  const char *c3=0,
103  const char *c4=0);
104  void setComponentName(int comp, const char *name);
105 
106  /// Returns the name of the individual component of a pixel (r,g,b,a, x,y,z)
107  const char *getComponentName(int comp) const;
108  /// @}
109 
110 
111 
112  /// @{
113  /// Specifies black/white points for integer formats (not supported for FP)
114  /// always set the data type before setting the BW points.
115  /// The black and white points must be within the range of the intger data
116  /// format (ie, 8b - 0-255).
117  void setBlackWhitePoints(int64 b, int64 w);
118  bool hasBlackWhitePoints() const;
119  void getBlackWhitePoints(int64 &b, int64 &w) const;
120  /// @}
121 
122  /// the size of a single pixel, in bytes, including the data format and
123  /// the color model.
124  int getPixelSize() const;
125 
126  /// This is the index of this plane, in the list of planes found in
127  /// IMG_Stat (0 to getNumPlanes()-1).
128  int getPlaneIndex() const { return myIndex; }
129 
130  /// Returns the number of components this plane consists of.
131  int getComponentCount() const
132  { return IMGvectorSize(myColorModel); }
133 
134  void dump() const;
135  void dump(UT_JSONWriter &w) const;
136 
137 private:
138  // only used by IMG_Stat.
139  void setParentStat(IMG_Stat *stat) { myStat = stat; }
140  void setPlaneIndex(int index) { myIndex = index; }
141  void updateComponentNames();
142 
143  // data members
144  UT_String myName;
145  UT_String myComponentNames[4];
146  int myIndex;
147 
148  IMG_DataType myDataType;
149  IMG_ColorModel myColorModel;
150  PXL_ColorSpace myColorSpace;
151  fpreal myColorSpaceGamma;
152  IMG_TypeInfo myTypeInfo;
153  int64 myBlackPoint;
154  int64 myWhitePoint;
155  IMG_Stat *myStat;
156 
157  friend class IMG_Stat;
158 };
159 
160 
161 
162 #endif
GLuint const GLchar * name
Definition: glew.h:1814
GLuint index
Definition: glew.h:1814
IMG_TypeInfo
How the channel data should be interpreted.
Definition: IMG_FileTypes.h:39
int getComponentCount() const
Returns the number of components this plane consists of.
Definition: IMG_Plane.h:131
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:34
static const char * Opacity
Definition: IMG_Plane.h:32
Describes the format and layout of a single plane in an image The plane specifies the format and name...
Definition: IMG_Plane.h:45
static const char * DepthComplexity
For deep images, this plane contains the sample count for each pixel.
Definition: IMG_Plane.h:38
static const char * Depth
Definition: IMG_Plane.h:33
#define IMG_API
Definition: IMG_API.h:10
static const char * Normal
Definition: IMG_Plane.h:35
IMG_DataType
Definition: IMG_FileTypes.h:17
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
long long int64
Definition: SYS_Types.h:116
standard plane names.
Definition: IMG_Plane.h:28
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
GLfloat GLfloat p
Definition: glew.h:16321
fpreal64 fpreal
Definition: SYS_Types.h:277
PXL_ColorSpace
Definition: PXL_Common.h:68
IMG_ColorModel
Definition: IMG_FileTypes.h:53
static const char * Color
Definition: IMG_Plane.h:30
Contains the details of a specific image file, used by IMG_File. This class contains all the high-lev...
Definition: IMG_Stat.h:40
static const char * Alpha
Definition: IMG_Plane.h:31
int getPlaneIndex() const
Definition: IMG_Plane.h:128
static const char * Position
Definition: IMG_Plane.h:34