Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. template <typename T>
  2. class Image : public Eigen::Matrix <T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
  3.  
  4. Image<RGB<unisgned char>> or Image<RGBA<float>>
  5.  
  6. Image<unisgned char> image = ReadImage(const char* const filename);
  7.  
  8. Image<unisgned char> image;
  9. bool b = ReadImage(const char* const filename, Image<unisgned char>& image)
  10.  
  11. class BaseImage
  12. {
  13. public:
  14. inline BaseImage() {};
  15. virtual inline ~BaseImage() {};
  16.  
  17. virtual inline int Width() const = 0;
  18. virtual inline int Height() const = 0;
  19. virtual inline int Depth() const = 0;
  20. etc...
  21. };
  22.  
  23. template <typename T>
  24. class Image : public BaseImage, public Eigen::Matrix <T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
  25.  
  26. class ImageFactory
  27. {
  28. typename <T>
  29. static BaseImage* createImage(const T* const src, const int& width, const int& height, const int& depth)
  30. {
  31. if (depth == 1)
  32. {
  33. return new Image<T>();
  34. }
  35. else if (depth == 3)
  36. {
  37. return new Image<RGB<T>>();
  38. }
  39. etc...
  40. }
  41. }
  42.  
  43. class Image2
  44. {
  45. public:
  46. Image2(const char* const path)
  47. {
  48. // where ReadImage and external function that will call ImageFactory
  49. pBaseImage = ReadImage(path);
  50. }
  51. ~Image2();
  52.  
  53. private:
  54. BaseImage* pBaseImage;
  55. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement