00001 #ifndef XDKWRL_SFIMAGE_H
00002 #define XDKWRL_SFIMAGE_H
00003
00004 #include <xdkwrl/config.h>
00005 #include <xdkwrl/fieldtypes.h>
00006 #include <iostream>
00007 #include <iomanip>
00008
00009 namespace wrl
00010 {
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 class XDKWRL_EXPORT SFImage
00021 {
00022 public:
00023 inline SFImage();
00024 inline SFImage(unsigned int w,
00025 unsigned int h,
00026 unsigned int n);
00027 SFImage(const SFImage& i);
00028 SFImage& operator=(const SFImage&);
00029 inline ~SFImage();
00030 inline void setDimensions(unsigned int w,
00031 unsigned int h,
00032 unsigned int n);
00033 inline unsigned int width() const;
00034 inline unsigned int height() const;
00035 inline unsigned int numComponents() const;
00036 inline unsigned char* pixels() const;
00037 inline unsigned char* pixels();
00038 static inline const char* typeName();
00039 static inline FieldTypeId typeId();
00040 inline bool operator==(const SFImage& i) const;
00041 friend std::ostream& operator<<(std::ostream& s,const SFImage& f);
00042 protected:
00043 public:
00044 unsigned int width_;
00045 unsigned int height_;
00046 unsigned int numComponents_;
00047 unsigned char* pixels_;
00048 };
00049
00050
00051
00052
00053 inline
00054 SFImage::SFImage()
00055 : width_(0),height_(0),numComponents_(0),pixels_(NULL)
00056 {
00057 }
00058 inline void
00059 SFImage::setDimensions(unsigned int w,
00060 unsigned int h,
00061 unsigned int n)
00062 {
00063 if (pixels_ != NULL)
00064 {
00065 delete [] pixels_;
00066 }
00067 width_ = w;
00068 height_ = h;
00069 numComponents_ = n;
00070 pixels_ = new unsigned char[w*h*n];
00071 }
00072 inline
00073 SFImage::SFImage(unsigned int w,
00074 unsigned int h,
00075 unsigned int n)
00076 : width_(w),height_(h),numComponents_(n)
00077 {
00078 pixels_ = new unsigned char[w*h*n];
00079 }
00080 inline
00081 SFImage::~SFImage()
00082 {
00083 if (pixels_ != NULL)
00084 {
00085 delete [] pixels_;
00086 }
00087 }
00088 inline unsigned int
00089 SFImage::width() const
00090 {
00091 return width_;
00092 }
00093 inline unsigned int
00094 SFImage::height() const
00095 {
00096 return height_;
00097 }
00098 inline unsigned int
00099 SFImage::numComponents() const
00100 {
00101 return numComponents_;
00102 }
00103 inline unsigned char*
00104 SFImage::pixels() const
00105 {
00106 return pixels_;
00107 }
00108 inline unsigned char*
00109 SFImage::pixels()
00110 {
00111 return pixels_;
00112 }
00113 inline const char*
00114 SFImage::typeName()
00115 {
00116 return "SFImage";
00117 }
00118 inline FieldTypeId
00119 SFImage::typeId()
00120 {
00121 return sfImage;
00122 }
00123 inline bool
00124 SFImage::operator==(const SFImage&) const
00125 {
00126 return false;
00127 }
00128 }
00129
00130 #endif // XDKWRL_SFIMAGE_H