Skip to content

Commit

Permalink
Android camera fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
florinleu committed Feb 8, 2013
1 parent a6dc5d6 commit ecf5003
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/cpp/CameraDemo/main.cpp
Expand Up @@ -257,8 +257,8 @@ class AppScreen : public ButtonListener, public StackScreenListener
*/
void setupCameraProperties()
{
setupCameraSize();
maCameraSelect(mSettingsScreen->getCurrentCamera());
setupCameraSize();
mCameraPreview->bindToCurrentCamera();
maCameraSetProperty(
MA_CAMERA_FLASH_MODE,
Expand Down
Expand Up @@ -198,15 +198,12 @@ public int numberOfCameras()
}
try
{
if(mCamera == null)
{
tempCamera = Camera.open();
}
else
{
mCamera.release();
tempCamera = Camera.open(mCurrentCameraIndex);
}
if (mCamera == null) {
tempCamera = Camera.open();
} else {
mCamera.release();
tempCamera = Camera.open(mCurrentCameraIndex);
}

//We have to use and static instance of the camera in the reflection here
mGetNumberofCameras = tempCamera.getClass().getMethod(
Expand Down Expand Up @@ -350,6 +347,7 @@ public int setActiveCamera(int CameraNumber)
mPreview.mCameraIndex = mCurrentCameraIndex;
mCamera.setParameters(getCurrentParameters());
} catch (Exception e) {
SYSLOG("cannot open camera " + e);
}
}

Expand Down Expand Up @@ -437,6 +435,7 @@ public int cameraSnapshot(int formatIndex, int placeHolder)
}
resourceIndex = placeHolder;

// mPreview.mCamera.cancelAutoFocus();
mPreview.mCamera.takePicture(null, rawCallback, jpegCallback);

lock.lock();
Expand Down Expand Up @@ -636,7 +635,11 @@ public void acquireCamera()
{
try
{
mCamera = Camera.open();
if (mNumCameras <= 1) {
mCamera = Camera.open();
} else {
mCamera = Camera.open(mCurrentCameraIndex);
}
//mPreview.mCamera = mCamera;
}
catch (RuntimeException re)
Expand Down Expand Up @@ -664,8 +667,14 @@ private void setNewSize(int formatIndex)
{
Camera.Parameters parameters = getCurrentParameters();
List <Camera.Size> supportedSizes = parameters.getSupportedPictureSizes();
Camera.Size optimalPictureSize = supportedSizes.get(formatIndex);
parameters.setPictureSize(optimalPictureSize.width,optimalPictureSize.height);
try {
Camera.Size optimalPictureSize = supportedSizes
.get(formatIndex);
parameters.setPictureSize(optimalPictureSize.width,
optimalPictureSize.height);
} catch (IndexOutOfBoundsException e) {
SYSLOG("Size not supported " + formatIndex);
}
if (mCamera != null)
mCamera.setParameters(parameters);
}
Expand Down

0 comments on commit ecf5003

Please sign in to comment.