00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef TIL_RASTER_H
00021 #define TIL_RASTER_H
00022
00023 #include "TIL_API.h"
00024 #include <PXL/PXL_Raster.h>
00025 #include <IMG/IMG_RasterFilter.h>
00026
00027 #include "TIL_Defines.h"
00028
00029 class UT_Vector2;
00030 class IMG_Raster;
00031 class UT_TokenString;
00032
00033 #define TIL_RASTER_COMPLETE 0
00034 #define TIL_RASTER_INCOMPLETE 1
00035 #define TIL_RASTER_CORRUPT -1
00036
00037 class TIL_API TIL_Raster : public PXL_Raster
00038 {
00039 public:
00040 TIL_Raster();
00041 TIL_Raster(const TIL_Raster &);
00042 TIL_Raster(const PXL_Raster &);
00043 TIL_Raster(const IMG_Raster &, bool copy = true);
00044 TIL_Raster(const TIL_Raster &,
00045 int x1, int y1, int x2, int y2);
00046 TIL_Raster(TIL_Packing p, TIL_DataFormat f,
00047 int xres = 0, int yres = 0, int clear = 0,
00048 int alloc = 1);
00049 virtual ~TIL_Raster();
00050
00051
00052 void setID(UT_TokenString *token);
00053 const UT_TokenString *getID() const { return myID; }
00054
00055 virtual void copy(const PXL_Raster &src);
00056
00057
00058
00059 virtual void reset(int full = 0);
00060
00061
00062
00063 void scaleFromRaster(TIL_Raster *scaled,int xres,int yres,
00064 UT_FilterType flt=UT_FILTER_BOX) const;
00065
00066 void scaleFromRaster(TIL_Raster *scaled,float xsc,float ysc,
00067 UT_FilterType flt=UT_FILTER_BOX) const;
00068
00069 static void scaleRaster(PXL_Raster *scaled,
00070 const PXL_Raster *source,
00071 int xres, int yres,
00072 UT_FilterType flt=UT_FILTER_BOX);
00073 static void scaleRaster(PXL_Raster *scaled,
00074 const PXL_Raster *source,
00075 float xsc, float ysc,
00076 UT_FilterType flt=UT_FILTER_BOX);
00077
00078
00079
00080
00081
00082
00083
00084 void applyEmulation(const TIL_Raster *src,
00085 float black, float white,
00086 float scale, float shift,
00087 float gamma, int comp = -1);
00088
00089 void adjustGamma(float gamma,
00090 bool red = true,
00091 bool green = true,
00092 bool blue = true,
00093 bool alpha = false);
00094
00095
00096
00097 void splitHRaster(const TIL_Raster *r1,
00098 const TIL_Raster *r2, float fract);
00099 void splitVRaster(const TIL_Raster *r1,
00100 const TIL_Raster *r2, float fract);
00101 void blendRaster(const TIL_Raster *r1,
00102 const TIL_Raster *r2, float fract);
00103 void diffRaster(const TIL_Raster *r1,const TIL_Raster *r2);
00104 void subRaster(const TIL_Raster *r1,const TIL_Raster *r2);
00105 void highlightRaster(const TIL_Raster *r1,
00106 const TIL_Raster *r2, float threshold);
00107
00108 void setUserData(void *data) { myUserData = data; }
00109 void *getUserData() { return myUserData; }
00110
00111
00112
00113
00114 bool getClosestEdge(int &x, int &y, int distance,
00115 float tolerance = 0.1f,
00116 UT_Vector2 *pos = 0,
00117 UT_Vector2 *dir = 0);
00118
00119
00120
00121
00122 void setIncomplete(int inc = 1);
00123 int isIncomplete() const { return myIncompleteState; }
00124
00125 protected:
00126 virtual void attemptRealloc(int64 size);
00127
00128 virtual void initialize();
00129
00130 private:
00131
00132 UT_TokenString *myID;
00133 void *myUserData;
00134 int myIncompleteState;
00135 };
00136
00137 #endif