Atoms Crowd  7.0.0
Image.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 
11 #include <AtomsUtils/Globals.h>
12 #include <vector>
13 #include <string>
14 
15 namespace AtomsUtils
16 {
18 
21  class ATOMSUTILS_EXPORT Image
22  {
23  public:
24 
25  enum ImageType
26  {
27  kByte = 0,
28  kFloat,
29  };
30 
32  Image();
33 
35 
41  Image(unsigned int width, unsigned int height, unsigned int channel, unsigned short imgType);
42 
44 
51  Image(float* data, unsigned int width, unsigned int height, unsigned int channel);
52 
54 
61  Image(unsigned char* data, unsigned int width, unsigned int height, unsigned int channel);
62 
64 
71  Image(std::vector<float> data, unsigned int width, unsigned int height, unsigned int channel);
72 
74 
81  Image(std::vector<unsigned char> data, unsigned int width, unsigned int height, unsigned int channel);
82 
84  ~Image();
85 
87  Image(const Image& other);
88 
90  Image& operator=(const Image& other);
91 
93  inline unsigned short imageType() const;
94 
96  inline unsigned int width() const;
97 
99  inline unsigned int height() const;
100 
102  inline unsigned int channels() const;
103 
105  inline const float* pixelsFloat() const;
106 
108  inline float* pixelsFloat();
109 
111  inline const unsigned char* pixels() const;
112 
114  inline unsigned char* pixels();
115 
117  void clear();
118 
120  void loadFromFile(const std::string& fileName);
121 
123 
125  bool saveToFile(const std::string& fileName) const;
126 
128  void reverseV();
129 
130  private:
131 
133  union
134  {
135  float* m_pixelsFloat;
136  unsigned char* m_pixels;
137  };
138 
140  unsigned int m_width;
141 
143  unsigned int m_height;
144 
146  unsigned int m_channels;
147 
149  unsigned short m_type;
150  };
151 }
152 
153 #include "Image.impl.h"
154 
Image class.
Definition: Image.h:22
Image(unsigned char *data, unsigned int width, unsigned int height, unsigned int channel)
Constructor.
Image()
Constructor.
void clear()
Clear image.
Image(unsigned int width, unsigned int height, unsigned int channel, unsigned short imgType)
Constructor.
Image(float *data, unsigned int width, unsigned int height, unsigned int channel)
Constructor.
Image(std::vector< float > data, unsigned int width, unsigned int height, unsigned int channel)
Constructor.
Image(const Image &other)
Copy constructor.
void loadFromFile(const std::string &fileName)
Load form file.
Image(std::vector< unsigned char > data, unsigned int width, unsigned int height, unsigned int channel)
Constructor.
~Image()
Destructor.
Image & operator=(const Image &other)
Assign operator.
bool saveToFile(const std::string &fileName) const
Save to file.
void reverseV()
reverse v
AtomsCore namespace.
Definition: Base64.h:13