HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TIL_Raster.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: TIL_Raster.h (Tile Image Library, C++)
7  *
8  * COMMENTS:
9  * Defines a more generic raster for texture maps & display. This class
10  * is designed to be a raster container, not a raster manipulation class.
11  */
12 #ifndef TIL_RASTER_H
13 #define TIL_RASTER_H
14 
15 #include "TIL_API.h"
16 #include <PXL/PXL_Raster.h>
17 #include <UT/UT_VectorTypes.h>
18 #include <IMG/IMG_RasterFilter.h>
19 
20 #include "TIL_Defines.h"
21 
22 class IMG_Raster;
23 class UT_TokenString;
24 
25 #define TIL_RASTER_COMPLETE 0
26 #define TIL_RASTER_INCOMPLETE 1
27 #define TIL_RASTER_CORRUPT -1
28 
30 {
31 public:
32  TIL_Raster();
33  TIL_Raster(const TIL_Raster &);
34  TIL_Raster(const PXL_Raster &);
35  TIL_Raster(const IMG_Raster &, bool copy = true);
36  TIL_Raster(const TIL_Raster &,
37  exint x1, exint y1, exint x2, exint y2);
39  exint xres = 0, exint yres = 0, int clear = 0,
40  int alloc = 1);
41  virtual ~TIL_Raster();
42 
43  virtual int64 getMemoryUsage(bool inclusive) const;
44 
45  // takes ownership.
46  void setID(UT_TokenString *token);
47  const UT_TokenString *getID() const { return myID; }
48 
49  virtual void copy(const PXL_Raster &src);
50 
51  /// copies only the raster properties (res, type, etc), not the data, nor
52  /// does this method allocate memory for a raster.
53  virtual void copyProperties(const PXL_Raster &src);
54 
55  // deletes the image memory. If full = 1, everything is reset - xres/yres
56  // to 0, packing and format to invalid.
57  virtual void reset(int full = 0);
58 
59  // Scale this raster to another output raster.
60  // You can't do format conversions here.
61  void scaleFromRasterToSize(TIL_Raster *scaled,
62  exint xres,exint yres,
63  UT_FilterType flt=UT_FILTER_BOX) const;
64 
65  void scaleFromRasterToScale(TIL_Raster *scaled,
66  float xsc,float ysc,
67  UT_FilterType flt=UT_FILTER_BOX) const;
68 
69  static void scaleRasterToSize(PXL_Raster *scaled,
70  const PXL_Raster *source,
71  exint xres, exint yres,
73  static void scaleRasterToScale(PXL_Raster *scaled,
74  const PXL_Raster *source,
75  float xsc, float ysc,
77 
78 
79 
80  // applyEmulation is like applyLUT but does not use a look up table and
81  // instead performs the calculations on each pixel.
82  // It is currently only implemented for FLOAT32 rasters, for anything else
83  // you should use applyLUT.
84  void applyEmulation(const TIL_Raster *src,
85  float black, float white,
86  float scale, float shift,
87  float gamma, exint comp = -1);
88 
89  void adjustGamma(float gamma,
90  bool red = true,
91  bool green = true,
92  bool blue = true,
93  bool alpha = false);
94 
95  // Raster diff functions. Source rasters must be the same format, packing
96  // and size as this raster.
97  void splitHRaster(const TIL_Raster *r1,
98  const TIL_Raster *r2, float fract);
99  void splitVRaster(const TIL_Raster *r1,
100  const TIL_Raster *r2, float fract);
101  void blendRaster(const TIL_Raster *r1,
102  const TIL_Raster *r2, float fract);
103  void diffRaster(const TIL_Raster *r1,const TIL_Raster *r2);
104  void subRaster(const TIL_Raster *r1,const TIL_Raster *r2);
105  void highlightRaster(const TIL_Raster *r1,
106  const TIL_Raster *r2, float threshold);
107 
108  void setUserData(void *data) { myUserData = data; }
109  void *getUserData() { return myUserData; }
110 
111  // returns true if an edge > tolerance was found within distance pixels
112  // of (x,y). The location of the edge is returned in (x,y). If dir and
113  // pos are specified, points along the dir vector from pos are favoured.
114  bool getClosestEdge(exint &x, exint &y, exint distance,
115  float tolerance = 0.1f,
116  UT_Vector2 *pos = 0,
117  UT_Vector2 *dir = 0);
118 
119  // TIL_RASTER_COMPLETE - raster is filled & okay
120  // TIL_RASTER_INCOMPLETE- raster was user-interrupted during construction.
121  // TIL_RASTER_CORRUPT - an error occurred during construction.
122  void setIncomplete(int inc = 1);
123  int isIncomplete() const { return myIncompleteState; }
124 
125 protected:
126  virtual void attemptRealloc(int64 size);
127 
128  virtual void initialize();
129 
130 private:
131  // optional.
132  UT_TokenString *myID;
133  void *myUserData;
134  int myIncompleteState;
135 };
136 
137 #endif
virtual void reset(int full=0)
virtual void copy(const PXL_Raster &src)
virtual void attemptRealloc(int64 size)
GLint y
Definition: glcorearb.h:102
UT_FilterType
Definition: UT_FilterType.h:16
GLsizeiptr size
Definition: glcorearb.h:663
int isIncomplete() const
Definition: TIL_Raster.h:123
#define TIL_Packing
Definition: TIL_Defines.h:72
long long int64
Definition: SYS_Types.h:107
GA_API const UT_StringHolder scale
virtual void initialize()
GLfloat f
Definition: glcorearb.h:1925
#define TIL_DataFormat
Definition: TIL_Defines.h:64
T distance(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2)
Definition: UT_Vector4.h:698
int64 exint
Definition: SYS_Types.h:116
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
const UT_TokenString * getID() const
Definition: TIL_Raster.h:47
void * getUserData()
Definition: TIL_Raster.h:109
GLfloat GLfloat GLfloat alpha
Definition: glcorearb.h:111
GLboolean * data
Definition: glcorearb.h:130
virtual void copyProperties(const PXL_Raster &src)
GLfloat green
Definition: glcorearb.h:111
GLint GLenum GLint x
Definition: glcorearb.h:408
void setUserData(void *data)
Definition: TIL_Raster.h:108
GLfloat GLfloat blue
Definition: glcorearb.h:111
virtual int64 getMemoryUsage(bool inclusive) const
int double red
Definition: png.h:1705
#define TIL_API
Definition: TIL_API.h:10
GLenum src
Definition: glcorearb.h:1792