00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef IMAGE_MODULE_H
00031 #define IMAGE_MODULE_H
00032
00033 #include "FsfCell.h"
00034 #include "FsfTypeCellBase.h"
00035
00036 #include "FsfCharBuffer.h"
00037
00038
00039 namespace image{
00042
00045
00049
00050 const int IMAGE_DEPTH_1U=0;
00051 const int IMAGE_DEPTH_8U=1;
00052 const int IMAGE_DEPTH_8S=2;
00053 const int IMAGE_DEPTH_16U=3;
00054 const int IMAGE_DEPTH_16S=4;
00055 const int IMAGE_DEPTH_32S=5;
00056 const int IMAGE_DEPTH_32F=6;
00057
00059 const int IMAGE_DEPTH_BIT[10] = { 1,8,8,16,16,32,32,0,0,0 };
00061 const bool IMAGE_FLOATING[10] = { false,false,false,false,false,false,true,false,false,false };
00062
00063 const unsigned char RGB_BLACK[3] = {0,0,0};
00064 const unsigned char RGB_GREY63[3] = {63,63,63};
00065 const unsigned char RGB_GREY127[3] = {127,127,127};
00066 const unsigned char RGB_WHITE[3] = {255,255,255};
00067 const unsigned char RGB_RED[3] = {255,0,0};
00068 const unsigned char RGB_GREEN[3] = {0,255,0};
00069 const unsigned char RGB_BLUE[3] = {0,0,255};
00070 const unsigned char RGB_CYAN[3] = {0,255,255};
00071 const unsigned char RGB_YELLOW[3] = {255,255,0};
00072 const unsigned char RGB_MAGENTA[3] ={255,0,255};
00073
00074
00077 void registerFactories();
00078
00079 using namespace std;
00080
00083 class CImage : public fsf::CCharBuffer {
00084 private:
00085 int m_nNbChannels;
00086 int m_nDepth;
00087
00088 int m_nWidth;
00089 int m_nHeight;
00090 int m_nWidthStep;
00091
00094 int computeWidthStep(bool bNoAlign=false);
00095
00096 public:
00098
00099
00100 CImage() : CCharBuffer(), m_nNbChannels(3), m_nDepth(IMAGE_DEPTH_8U),
00101 m_nWidth(0), m_nHeight(0), m_nWidthStep(0) {}
00103 CImage(fsf::CNode *pParent, fsf::Time tTime=0)
00104 : CCharBuffer(pParent,tTime), m_nNbChannels(3), m_nDepth(IMAGE_DEPTH_8U),
00105 m_nWidth(0), m_nHeight(0), m_nWidthStep(0) {}
00107 CImage(const string &strName, fsf::CNode *pParent=NULL, fsf::Time tTime=0)
00108 : CCharBuffer(strName,pParent,tTime), m_nNbChannels(3), m_nDepth(IMAGE_DEPTH_8U),
00109 m_nWidth(0), m_nHeight(0), m_nWidthStep(0) {}
00112 CImage(int nWidth, int nHeight, int nNbChannels=3, int nDepth=IMAGE_DEPTH_8U,
00113 fsf::CNode *pParent=NULL, fsf::Time tTime=0)
00114 : CCharBuffer(pParent,tTime), m_nNbChannels(nNbChannels), m_nDepth(nDepth),
00115 m_nWidth(nWidth), m_nHeight(nHeight), m_nWidthStep(0) {}
00119 CImage(const string &strName, int nWidth, int nHeight, int nNbChannels=3, int nDepth=IMAGE_DEPTH_8U,
00120 fsf::CNode *pParent=NULL, fsf::Time tTime=0)
00121 : CCharBuffer(strName,pParent,tTime), m_nNbChannels(nNbChannels), m_nDepth(nDepth),
00122 m_nWidth(nWidth), m_nHeight(nHeight), m_nWidthStep(0) {}
00123 CImage(const CImage&);
00124
00126 virtual fsf::CNode *clone() const { return new CImage(*this); }
00128
00130
00131
00132 CImage& operator=(const CImage&);
00133
00136 void allocateImageBuffer(bool bNoAlign=false);
00137
00139 void copyParameters(const CImage&);
00141 void copyImageData(const CImage&);
00142
00144 void setWidth(int nWidth) { m_nWidth=nWidth; }
00146 void setHeight(int nHeight) { m_nHeight=nHeight; }
00148 void setNbChannels(int nNbChannels) { m_nNbChannels=nNbChannels; }
00150 void setPixelDepth(int nDepth) { m_nDepth=nDepth; }
00152 void setWidthStep(int nWidthStep) { m_nWidthStep=nWidthStep; }
00153
00154
00156 void setBytes(int val) { memset(data(),val,getSize()); }
00158
00160
00161
00163 virtual void getTypeID(string &str) const { str.assign("IMAGE_IMAGE"); }
00164
00165
00166 int getWidth() const { return m_nWidth; }
00167 int getHeight() const { return m_nHeight; }
00168 int getNbChannels() const { return m_nNbChannels; }
00169 int getPixelDepth() const { return m_nDepth; }
00170 int getWidthStep() const { return m_nWidthStep; }
00171
00173
00176
00177
00178 void drawPoint(int x, int y, const unsigned char *col);
00181 void drawLine(int xo, int yo, int xd, int yd, const unsigned char *col);
00183 void drawRectangle(int x, int y, int w, int h, const unsigned char *col);
00185 void fillRectangle(int x, int y, int w, int h, const unsigned char *col);
00187 };
00188
00191 class CWidth : public fsf::CTypeCellBase {
00192 public:
00194 CWidth();
00196 virtual void getTypeID(std::string &str) const { str.assign("IMAGE_WIDTH"); }
00198 virtual void process(fsf::CPassiveHandle *pPassiveHandle, fsf::CActiveHandle *pActiveHandle, fsf::CActivePulse *pActivePulse);
00199 };
00200
00203 class CHeight : public fsf::CTypeCellBase {
00204 public:
00206 CHeight();
00208 virtual void getTypeID(std::string &str) const { str.assign("IMAGE_HEIGHT"); }
00210 virtual void process(fsf::CPassiveHandle *pPassiveHandle, fsf::CActiveHandle *pActiveHandle, fsf::CActivePulse *pActivePulse);
00211 };
00212
00215 class CNbChannels : public fsf::CTypeCellBase {
00216 public:
00218 CNbChannels();
00220 virtual void getTypeID(std::string &str) const { str.assign("IMAGE_NB_CHANNELS"); }
00222 virtual void process(fsf::CPassiveHandle *pPassiveHandle, fsf::CActiveHandle *pActiveHandle, fsf::CActivePulse *pActivePulse);
00223 };
00224
00227 class CPixelDepth : public fsf::CTypeCellBase {
00228 public:
00230 CPixelDepth();
00232 virtual void getTypeID(std::string &str) const { str.assign("IMAGE_PIXEL_DEPTH"); }
00234 virtual void process(fsf::CPassiveHandle *pPassiveHandle, fsf::CActiveHandle *pActiveHandle, fsf::CActivePulse *pActivePulse);
00235 };
00236
00237 }
00238
00239 #endif