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
This commit is contained in:
@@ -22,6 +22,21 @@
|
|||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
|
struct Size {
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
|
||||||
|
Size() {
|
||||||
|
width = 0;
|
||||||
|
height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Size(int w, int h) {
|
||||||
|
width = w;
|
||||||
|
height = h;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class CameraParameters
|
class CameraParameters
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -49,6 +64,7 @@ public:
|
|||||||
const char *getPreviewFormat() const;
|
const char *getPreviewFormat() const;
|
||||||
void setPictureSize(int width, int height);
|
void setPictureSize(int width, int height);
|
||||||
void getPictureSize(int *width, int *height) const;
|
void getPictureSize(int *width, int *height) const;
|
||||||
|
void getSupportedPictureSizes(Vector<Size> &sizes) const;
|
||||||
void setPictureFormat(const char *format);
|
void setPictureFormat(const char *format);
|
||||||
const char *getPictureFormat() const;
|
const char *getPictureFormat() const;
|
||||||
|
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ void CameraParameters::remove(const char *key)
|
|||||||
mMap.removeItem(String8(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.
|
// Find the width.
|
||||||
char *end;
|
char *end;
|
||||||
@@ -279,11 +279,15 @@ static int parse_size(const char *str, int &width, int &height)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// Find the height, immediately after the 'x'.
|
// 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;
|
width = w;
|
||||||
height = h;
|
height = h;
|
||||||
|
|
||||||
|
if (endptr) {
|
||||||
|
*endptr = end;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,6 +342,31 @@ void CameraParameters::setPictureSize(int width, int height)
|
|||||||
set(KEY_PICTURE_SIZE, str);
|
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
|
void CameraParameters::getPictureSize(int *width, int *height) const
|
||||||
{
|
{
|
||||||
*width = -1;
|
*width = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user