Choreonoid  1.5
Image.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_UTIL_IMAGE_H
7 #define CNOID_UTIL_IMAGE_H
8 
9 #include <string>
10 #include <vector>
11 #include "exportdecl.h"
12 
13 namespace cnoid {
14 
16 {
17 public:
18  Image();
19  Image(const Image& org);
20  virtual ~Image();
21 
22  Image& operator=(const Image& rhs);
23 
24  void reset();
25  bool empty() const { return pixels_.empty(); }
26 
27  unsigned char* pixels() { return &pixels_.front(); }
28  const unsigned char* pixels() const { return &pixels_.front(); }
29 
30  int width() const { return width_; }
31  int height() const { return height_; }
32  int numComponents() const { return numComponents_; }
33  bool hasAlphaComponent() const { return (numComponents() % 2) == 0; }
34 
35  void setSize(int width, int height, int nComponents);
36  void setSize(int width, int height);
37 
38  void clear();
39  void applyVerticalFlip();
40 
41  void load(const std::string& filename);
42  void save(const std::string& filename) const;
43 
44 private:
45  std::vector<unsigned char> pixels_;
46  int width_;
47  int height_;
48  int numComponents_;
49 };
50 
51 }
52 
53 #endif
bool hasAlphaComponent() const
Definition: Image.h:33
int width() const
Definition: Image.h:30
Definition: Image.h:15
bool empty() const
Definition: Image.h:25
Defines the minimum processing for performing pasing file for STL.
Definition: AbstractSceneLoader.h:9
const unsigned char * pixels() const
Definition: Image.h:28
int numComponents() const
Definition: Image.h:32
unsigned char * pixels()
Definition: Image.h:27
#define CNOID_EXPORT
Definition: Util/exportdecl.h:37
int height() const
Definition: Image.h:31