diff options
| author | Wu-cheng Li <wuchengli@google.com> | 2010-08-19 11:10:40 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2010-08-19 11:10:40 -0700 |
| commit | 9ba1ed6a8fe9a79d147d50abb03f5e22d27766b9 (patch) | |
| tree | 12accfad4bc3fc0b0d9d477b450dd580474a8d08 /libs | |
| parent | b29ebd397e25a7176bcc1c81980f17b0190ebe7f (diff) | |
| parent | ccb915963e70c9b4e8fc47b5af97ab37b979195a (diff) | |
| download | frameworks_base-9ba1ed6a8fe9a79d147d50abb03f5e22d27766b9.zip frameworks_base-9ba1ed6a8fe9a79d147d50abb03f5e22d27766b9.tar.gz frameworks_base-9ba1ed6a8fe9a79d147d50abb03f5e22d27766b9.tar.bz2 | |
am ccb91596: Merge "Adding getSupportedPictureSizes to CameraParameters.DO NOT MERGE" into gingerbread
Merge commit 'ccb915963e70c9b4e8fc47b5af97ab37b979195a' into gingerbread-plus-aosp
* commit 'ccb915963e70c9b4e8fc47b5af97ab37b979195a':
Adding getSupportedPictureSizes to CameraParameters.DO NOT MERGE
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/camera/CameraParameters.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/libs/camera/CameraParameters.cpp b/libs/camera/CameraParameters.cpp index 1415493..1cf19a0 100644 --- a/libs/camera/CameraParameters.cpp +++ b/libs/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; |
