A couple small improvements to the CameraManager.

git-svn-id: https://zxing.googlecode.com/svn/trunk@361 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
dswitkin 2008-04-15 22:34:49 +00:00
parent 66ae9f7ed4
commit 5c496574a3

View file

@ -60,10 +60,8 @@ final class CameraManager {
usePreviewForDecode = true; usePreviewForDecode = true;
setUsePreviewForDecode(false); setUsePreviewForDecode(false);
camera = CameraDevice.open(); camera = null;
params = new CameraDevice.CaptureParams(); params = new CameraDevice.CaptureParams();
previewMode = false;
setPreviewMode(true);
} }
public void openDriver() { public void openDriver() {
@ -106,8 +104,8 @@ final class CameraManager {
screenResolution.y); screenResolution.y);
bitmap = Bitmap.createBitmap(screenResolution.x, screenResolution.y, false); bitmap = Bitmap.createBitmap(screenResolution.x, screenResolution.y, false);
} else { } else {
Log.v(TAG, "Creating bitmap at still resolution: " + screenResolution.x + "," + Log.v(TAG, "Creating bitmap at still resolution: " + stillResolution.x + "," +
screenResolution.y); stillResolution.y);
bitmap = Bitmap.createBitmap(stillResolution.x, stillResolution.y, false); bitmap = Bitmap.createBitmap(stillResolution.x, stillResolution.y, false);
} }
} }
@ -244,13 +242,15 @@ final class CameraManager {
} }
private void calculatePreviewResolution() { private void calculatePreviewResolution() {
int previewHeight = (int) (stillResolution.x * stillMultiplier * 1.4f); if (previewResolution == null) {
int previewWidth = previewHeight * screenResolution.x / screenResolution.y; int previewHeight = (int) (stillResolution.x * stillMultiplier * 1.4f);
previewWidth = ((previewWidth + 7) >> 3) << 3; int previewWidth = previewHeight * screenResolution.x / screenResolution.y;
if (previewWidth > cameraResolution.x) previewWidth = cameraResolution.x; previewWidth = ((previewWidth + 7) >> 3) << 3;
previewHeight = previewWidth * screenResolution.y / screenResolution.x; if (previewWidth > cameraResolution.x) previewWidth = cameraResolution.x;
previewResolution = new Point(previewWidth, previewHeight); previewHeight = previewWidth * screenResolution.y / screenResolution.x;
Log.v(TAG, "previewWidth " + previewWidth + " previewHeight " + previewHeight); previewResolution = new Point(previewWidth, previewHeight);
Log.v(TAG, "previewWidth " + previewWidth + " previewHeight " + previewHeight);
}
} }
// FIXME(dswitkin): These three methods have temporary constants until the new Camera API can // FIXME(dswitkin): These three methods have temporary constants until the new Camera API can