diff options
-rw-r--r-- | include/ui/CameraParameters.h | 2 | ||||
-rw-r--r-- | libs/ui/CameraParameters.cpp | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/include/ui/CameraParameters.h b/include/ui/CameraParameters.h index b9c2bbe..2c29bfb 100644 --- a/include/ui/CameraParameters.h +++ b/include/ui/CameraParameters.h @@ -34,8 +34,10 @@ public: void set(const char *key, const char *value); void set(const char *key, int value); + void setFloat(const char *key, float value); const char *get(const char *key) const; int getInt(const char *key) const; + float getFloat(const char *key) const; /* preview-size=176x144 */ void setPreviewSize(int width, int height); diff --git a/libs/ui/CameraParameters.cpp b/libs/ui/CameraParameters.cpp index 495e164..c4958a0 100644 --- a/libs/ui/CameraParameters.cpp +++ b/libs/ui/CameraParameters.cpp @@ -209,6 +209,13 @@ void CameraParameters::set(const char *key, int value) set(key, str); } +void CameraParameters::setFloat(const char *key, float value) +{ + char str[16]; // 14 should be enough. We overestimate to be safe. + snprintf(str, sizeof(str), "%g", value); + set(key, str); +} + const char *CameraParameters::get(const char *key) const { String8 v = mMap.valueFor(String8(key)); @@ -225,6 +232,13 @@ int CameraParameters::getInt(const char *key) const return strtol(v, 0, 0); } +float CameraParameters::getFloat(const char *key) const +{ + const char *v = get(key); + if (v == 0) return -1; + return strtof(v, 0); +} + static int parse_size(const char *str, int &width, int &height) { // Find the width. |