Возможно, эта ссылка поможет вам.
http://adblogcat.com/a-camera-preview-with-a-bounding-box-like-google-goggles/
Вот метод onSurfaceChange, который устанавливает правильную ориентацию
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
//Log.i(TAG, "Preview: surfaceChanged() - size now " + w + "x" + h);
// Now that the size is known, set up the camera parameters and begin
// the preview.
try {
mParameters = mCamera.getParameters();
mParameters.set("orientation","landscape");
for (Integer i : mParameters.getSupportedPreviewFormats()) {
//Log.i(TAG, "supported preview format: " + i);
}
List<Size> sizes = mParameters.getSupportedPreviewSizes();
for (Size size : sizes) {
//Log.i(TAG, "supported preview size: " + size.width + "x" + size.height);
}
mCamera.setParameters(mParameters); // apply the changes
} catch (Exception e) {
// older phone - doesn't support these calls
}
//updateBufferSize(); // then use them to calculate
Size p = mCamera.getParameters().getPreviewSize();
//Log.i(TAG, "Preview: checking it was set: " + p.width + "x" + p.height); // DEBUG
mCamera.startPreview();
}
public Parameters getCameraParameters(){
return mCamera.getParameters();
}
В статье для параметров задается значениепейзаж.Я вижу, у вас этого нет в вашем коде.
Кроме того, для сохранения изображений я вижу два метода:
private boolean savePhoto(Bitmap bm) {
FileOutputStream image = null;
try {
image = new FileOutputStream(mLocation);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
bm.compress(CompressFormat.JPEG, 100, image);
if (bm != null) {
int h = bm.getHeight();
int w = bm.getWidth();
//Log.i(TAG, "savePhoto(): Bitmap WxH is " + w + "x" + h);
} else {
//Log.i(TAG, "savePhoto(): Bitmap is null..");
return false;
}
return true;
}
и
public Bitmap getPic(int x, int y, int width, int height) {
System.gc();
Bitmap b = null;
Size s = mParameters.getPreviewSize();
YuvImage yuvimage = new YuvImage(mBuffer, ImageFormat.NV21, s.width, s.height, null);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
yuvimage.compressToJpeg(new Rect(x, y, width, height), 100, outStream); // make JPG
b = BitmapFactory.decodeByteArray(outStream.toByteArray(), 0, outStream.size());
if (b != null) {
//Log.i(TAG, "getPic() WxH:" + b.getWidth() + "x" + b.getHeight());
} else {
//Log.i(TAG, "getPic(): Bitmap is null..");
}
yuvimage = null;
outStream = null;
System.gc();
return b;
}
А вам нужно использовать android 2.2