MCPcopy Create free account
hub / github.com/android/ndk-samples / DisplayDimension

Class DisplayDimension

camera/basic/src/main/cpp/camera_manager.cpp:105–157  ·  view source on GitHub ↗

* A helper class to assist image size comparison, by comparing the absolute * size * regardless of the portrait or landscape mode. */

Source from the content-addressed store, hash-verified

103 * regardless of the portrait or landscape mode.
104 */
105class DisplayDimension {
106 public:
107 DisplayDimension(int32_t w, int32_t h) : w_(w), h_(h), portrait_(false) {
108 if (h > w) {
109 // make it landscape
110 w_ = h;
111 h_ = w;
112 portrait_ = true;
113 }
114 }
115 DisplayDimension(const DisplayDimension& other) {
116 w_ = other.w_;
117 h_ = other.h_;
118 portrait_ = other.portrait_;
119 }
120
121 DisplayDimension(void) {
122 w_ = 0;
123 h_ = 0;
124 portrait_ = false;
125 }
126 DisplayDimension& operator=(const DisplayDimension& other) {
127 w_ = other.w_;
128 h_ = other.h_;
129 portrait_ = other.portrait_;
130
131 return (*this);
132 }
133
134 bool IsSameRatio(DisplayDimension& other) {
135 return (w_ * other.h_ == h_ * other.w_);
136 }
137 bool operator>(DisplayDimension& other) {
138 return (w_ >= other.w_ & h_ >= other.h_);
139 }
140 bool operator==(DisplayDimension& other) {
141 return (w_ == other.w_ && h_ == other.h_ && portrait_ == other.portrait_);
142 }
143 DisplayDimension operator-(DisplayDimension& other) {
144 DisplayDimension delta(w_ - other.w_, h_ - other.h_);
145 return delta;
146 }
147 void Flip(void) { portrait_ = !portrait_; }
148 bool IsPortrait(void) { return portrait_; }
149 int32_t width(void) { return w_; }
150 int32_t height(void) { return h_; }
151 int32_t org_width(void) { return (portrait_ ? h_ : w_); }
152 int32_t org_height(void) { return (portrait_ ? w_ : h_); }
153
154 private:
155 int32_t w_, h_;
156 bool portrait_;
157};
158
159/**
160 * Find a compatible camera modes:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected