00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __IMG_Stat__
00023 #define __IMG_Stat__
00024
00025 #include "IMG_API.h"
00026 #include <iostream.h>
00027
00028 #include "IMG_FileTypes.h"
00029 #include "IMG_Plane.h"
00030
00031 #include <UT/UT_String.h>
00032 #include <UT/UT_Rect.h>
00033 #include <UT/UT_PtrArray.h>
00034 #include <UT/UT_IntArray.h>
00035
00036
00037 class IMG_Format;
00038 class IMG_Plane;
00039
00040
00041
00042
00043
00044
00045
00046
00047 class IMG_API IMG_Stat
00048 {
00049 public:
00050 IMG_Stat();
00051
00052
00053 IMG_Stat(unsigned xres, unsigned yres);
00054
00055
00056
00057 IMG_Stat(unsigned xres, unsigned yres,
00058 IMG_DataType dt, IMG_ColorModel cm);
00059
00060 ~IMG_Stat();
00061
00062 IMG_Stat(const IMG_Stat &s)
00063 {
00064 copy(s);
00065 }
00066 IMG_Stat &operator=(const IMG_Stat &s)
00067 {
00068 copy(s);
00069 return *this;
00070 }
00071 void copy(const IMG_Stat &src);
00072
00073
00074
00075
00076 void setResolution(unsigned xres, unsigned yres)
00077 {
00078 myXres = xres;
00079 myYres = yres;
00080 recomputeOffsets();
00081 }
00082 unsigned getXres() const { return myXres; }
00083 unsigned getYres() const { return myYres; }
00084
00085
00086
00087
00088 void setAspectRatio(fpreal aspect) { myAspectRatio=aspect; }
00089 fpreal getAspectRatio() const { return myAspectRatio; }
00090
00091
00092
00093
00094
00095
00096 void setFilename(const char *name){ myName.harden(name); }
00097 const UT_String &getFilename() const { return myName; }
00098
00099
00100
00101
00102
00103
00104 int getNumPlanes() const;
00105
00106 IMG_Plane *getPlane(int i = 0) const;
00107
00108
00109
00110
00111 IMG_Plane *getPlaneName(const char *name) const;
00112
00113
00114
00115 int getPlaneIndex(const char *name) const;
00116
00117
00118
00119
00120
00121
00122
00123 IMG_Plane *addPlane(const char *name,
00124 IMG_DataType d,
00125 IMG_ColorModel cm,
00126 const char *c0name = 0,
00127 const char *c1name = 0,
00128 const char *c2name = 0,
00129 const char *c3name = 0);
00130
00131 IMG_Plane *addPlane(const IMG_Plane &pi);
00132
00133 IMG_Plane *addDefaultPlane()
00134 { return addPlane("C", IMG_UCHAR, IMG_RGBA, "r","g","b","a"); }
00135
00136
00137
00138
00139 void addEnvMapPlanes(IMG_DataType dt, IMG_ColorModel cm);
00140
00141
00142 bool isEnvMap() const { return myEnvMapPlanes; }
00143
00144
00145
00146
00147
00148 bool setEnvMap();
00149
00150
00151 void insertPlane(IMG_Plane *plane, int beforeindex);
00152
00153
00154
00155 void removePlane(int pindex);
00156
00157 void removePlane(const char *name);
00158
00159 void removeAllPlanes();
00160
00161
00162
00163 void reorderPlane(IMG_Plane *plane, int beforeindex);
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 void setDataWindow(const UT_DimRect &win);
00174 void setDataWindow(int x1, int y1, int x2, int y2);
00175 void clearDataWindow();
00176
00177
00178 void getDataWindow(UT_DimRect &r) const;
00179
00180 void getDataWindow(int &x1, int &y1,
00181 int &x2, int &y2) const;
00182
00183 bool hasDataWindow() const;
00184
00185
00186
00187
00188
00189 void setBackgroundColor(fpreal col[4]);
00190 void getBackgroundColor(fpreal col[4]) const;
00191
00192 void setBackgroundStreak(bool streak)
00193 { myDataStreakFlag = streak; }
00194 bool getBackgroundStreak() const {return myDataStreakFlag;}
00195
00196
00197
00198
00199
00200 int getDataWidth() const;
00201
00202
00203
00204 int getDataHeight() const;
00205
00206
00207
00208 int getNumFrames() const { return myNumFrames; }
00209
00210
00211 void setNumFrames(int nf) { myNumFrames = nf; }
00212
00213
00214 fpreal getFPS() const { return myFPS; }
00215
00216 void setFPS(fpreal fps) { myFPS = fps; }
00217
00218
00219 static const char *getColorModel(IMG_ColorModel cm);
00220 static const char *getDataType(IMG_DataType dt);
00221
00222
00223 int bytesPerPixel() const;
00224 int bytesPerImage() const;
00225 int bytesPerScanline() const;
00226 int bytesPerPlaneScan(const IMG_Plane &pi) const;
00227 int bytesPerPlaneScan(int i) const;
00228 int planeOffset(const IMG_Plane &pi) const;
00229 int planeOffset(int i) const;
00230
00231
00232 void recomputeOffsets();
00233 private:
00234 void init(int xres, int yres);
00235
00236 UT_String myName;
00237 UT_PtrArray<IMG_Plane *> myPlanes;
00238 UT_IntArray myPlaneOffset;
00239 fpreal myDataWindowColor[4];
00240 UT_DimRect myDataWindow;
00241 fpreal myAspectRatio;
00242 fpreal myFPS;
00243 unsigned myXres, myYres;
00244 int myNumFrames;
00245 int myScanlineSize;
00246 bool myDataStreakFlag;
00247 bool myHasDataWindow;
00248 bool myEnvMapPlanes;
00249 };
00250
00251 #endif
00252