diff options
author | Nipun Kwatra <nkwatra@google.com> | 2010-07-30 13:40:14 -0700 |
---|---|---|
committer | Nipun Kwatra <nkwatra@google.com> | 2010-07-30 17:51:59 -0700 |
commit | 99b4de92430fe42f9d1493c8a4c3d27de89d3549 (patch) | |
tree | bb5f2173d414cddcb6f2d6c3d8868aae498c1ee5 | |
parent | 484c146281e39a04e32f4f13775210ab2a248c57 (diff) | |
download | frameworks_av-99b4de92430fe42f9d1493c8a4c3d27de89d3549.zip frameworks_av-99b4de92430fe42f9d1493c8a4c3d27de89d3549.tar.gz frameworks_av-99b4de92430fe42f9d1493c8a4c3d27de89d3549.tar.bz2 |
Adding getSupportedPictureSizes which returns a Vector of supported Sizes.
Also added a struct 'Size' containing a width and a height field.
Modified parse_size to optionally set an end pointer pointing to the
character after the found size.
Change-Id: I51a56bbf2cb7c91d7b80a28e6bd6a559f40a1333
-rw-r--r-- | camera/CameraParameters.cpp | 33 | ||||
-rw-r--r-- | include/camera/CameraParameters.h | 16 |
2 files changed, 47 insertions, 2 deletions
diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp index 1415493..1cf19a0 100644 --- a/camera/CameraParameters.cpp +++ b/camera/CameraParameters.cpp @@ -269,7 +269,7 @@ void CameraParameters::remove(const char *key) mMap.removeItem(String8(key)); } -static int parse_size(const char *str, int &width, int &height) +static int parse_size(const char *str, int &width, int &height, char **endptr = NULL) { // Find the width. char *end; @@ -279,11 +279,15 @@ static int parse_size(const char *str, int &width, int &height) return -1; // Find the height, immediately after the 'x'. - int h = (int)strtol(end+1, 0, 10); + int h = (int)strtol(end+1, &end, 10); width = w; height = h; + if (endptr) { + *endptr = end; + } + return 0; } @@ -338,6 +342,31 @@ void CameraParameters::setPictureSize(int width, int height) set(KEY_PICTURE_SIZE, str); } +void CameraParameters::getSupportedPictureSizes(Vector<Size> &sizes) const +{ + const char *pictureSizesStr = get(KEY_SUPPORTED_PICTURE_SIZES); + if (pictureSizesStr == 0) { + return; + } + + char *sizeStartPtr = (char *)pictureSizesStr; + + while (true) { + int width, height; + int success = parse_size(sizeStartPtr, width, height, &sizeStartPtr); + if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\0')) { + LOGE("Picture sizes string \"%s\" contains invalid character.", pictureSizesStr); + return; + } + sizes.push(Size(width, height)); + + if (*sizeStartPtr == '\0') { + return; + } + sizeStartPtr++; + } +} + void CameraParameters::getPictureSize(int *width, int *height) const { *width = -1; diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h index e12a694..5211c95 100644 --- a/include/camera/CameraParameters.h +++ b/include/camera/CameraParameters.h @@ -22,6 +22,21 @@ namespace android { +struct Size { + int width; + int height; + + Size() { + width = 0; + height = 0; + } + + Size(int w, int h) { + width = w; + height = h; + } +}; + class CameraParameters { public: @@ -49,6 +64,7 @@ public: const char *getPreviewFormat() const; void setPictureSize(int width, int height); void getPictureSize(int *width, int *height) const; + void getSupportedPictureSizes(Vector<Size> &sizes) const; void setPictureFormat(const char *format); const char *getPictureFormat() const; |