00001 #ifndef __INSTANTIO_IMAGE_H
00002 #define __INSTANTIO_IMAGE_H
00003
00004 #ifdef _MSC_VER
00005 # pragma once
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "InstantIODef.h"
00027 #include "TypeName.h"
00028 #include <string>
00029
00030
00031 namespace InstantIO
00032 {
00033
00034
00040 class INSTANTIO_DLLMAPPING Image
00041 {
00042 public:
00043
00048 typedef enum
00049 {
00050 FMT_NONE,
00051
00052
00053 FMT_BGR232,
00054 FMT_BGR555,
00055 FMT_BGR565,
00056 FMT_BGR24,
00057 FMT_RGB24,
00058 FMT_BGR32,
00059 FMT_RGB32,
00060
00061
00062 FMT_SHORT16,
00063 FMT_FLOAT16,
00064 FMT_FLOAT32,
00065
00066
00067 FMT_Y444,
00068 FMT_IYU2,
00069 FMT_I420,
00070 FMT_YVU9,
00071 FMT_YUV9,
00072 FMT_Y800,
00073 FMT_Y1600,
00074 FMT_Y422,
00075 FMT_Y411,
00076 FMT_Y41P,
00077 FMT_YV12,
00078 FMT_YUY2,
00079 FMT_YUV422P,
00080 FMT_YUV411P
00081 }
00082 Format;
00083
00085
00088 Image();
00089
00091 Image(const Image &image);
00092
00094 const Image &operator=(const Image &image);
00095
00097
00100 ~Image();
00101
00103
00109 void setParameters(unsigned int width, unsigned int height, Format format);
00110
00112
00116 inline unsigned int getWidth() const { return width_; }
00117
00119
00123 inline unsigned int getHeight() const { return height_; }
00124
00126
00130 inline Format getFormat() const { return format_; }
00131
00133
00138 inline char *getBuffer() const { return buffer_; }
00139
00141
00145 inline unsigned long getSize() const { return size_; }
00146
00153 static const char *format2String(Format format);
00154
00161 static Format string2Format(const std::string &str);
00162
00169 void convertFormat(Format format, Image &image) const;
00170
00177 friend bool operator==(const Image &i1, const Image &i2);
00178
00185 friend inline bool operator!=(const Image &i1, const Image &i2)
00186 {
00187 return !(i1 == i2);
00188 }
00189
00190 private:
00191
00193 char *buffer_;
00194
00196 unsigned long bufferSize_;
00197
00199 unsigned long size_;
00200
00202 unsigned int width_;
00203
00205 unsigned int height_;
00206
00208 Format format_;
00209
00210 void convert_BGR232_to_RGB24(Image &image) const;
00211
00212 void convert_BGR555_to_RGB24(Image &image) const;
00213
00214 void convert_BGR565_to_RGB24(Image &image) const;
00215
00216 void convert_BGR32_to_RGB24(Image &image) const;
00217
00218 void convert_BGR24_to_RGB24(Image &image) const;
00219
00220 void convert_RGB24_to_Y800(Image &image) const;
00221
00222 void convert_BGR24_to_Y800(Image &image) const;
00223
00224 void convert_IYU2_to_Y444(Image &image) const;
00225
00226 void convert_Y422_to_Y444(Image &image) const;
00227
00228 void convert_Y422_to_Y800(Image &image) const;
00229
00230 void convert_Y444_to_Y800(Image &image) const;
00231
00232 void convert_Y411_to_Y444(Image &image) const;
00233
00234 void convert_Y411_to_Y800(Image &image) const;
00235
00236 void convert_Y41P_to_Y444(Image &image) const;
00237
00238 void convert_Y800_to_Y444(Image &image) const;
00239
00240 void convert_Y1600_to_Y444(Image &image) const;
00241
00242 void convert_I420_to_Y444(Image &image) const;
00243
00244 void convert_I420_to_Y800(Image &image) const;
00245
00246 void convert_YVU9_to_Y444(Image &image) const;
00247
00248 void convert_YV12_to_Y444(Image &image) const;
00249
00250 void convert_YUY2_to_Y444(Image &image) const;
00251
00252 };
00253
00254
00255 template <class T> class SmartPtr;
00256
00257
00258 typedef SmartPtr<Image> ImagePtr;
00259
00260
00267 template <>
00268 class INSTANTIO_DLLMAPPING TypeName<ImagePtr>
00269 {
00270 public:
00271
00276 static const char *getName();
00277
00278 private:
00279
00281 TypeName();
00282
00284 TypeName(const TypeName &);
00285
00287 const TypeName &operator=(const TypeName &);
00288 };
00289
00290
00291 }
00292
00293
00294 #endif // __INSTANTIO_IMAGE_H