Merge "Add float support for set and get in CameraParameters."
This commit is contained in:
commit
fdef2fb051
@ -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);
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user