我成功地使用SonyEricsson的相机拍照。拍摄的照片看起来不错,通常情况下,我使用了风景来观看我的活动。
问题是拍摄的照片不是全屏的......它只占我屏幕的50%,我无法让它变得更大。 我是这样做的:
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Log.e(TAG, "onCreate");
Bundle extras = getIntent().getExtras();
getWindow().setFormat(PixelFormat.TRANSLUCENT);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.editphoto);
mSurfaceView = (SurfaceView) findViewById(R.id.surface_camera);
mSurfaceView.setOnClickListener(this);
mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mSurfaceHolder.setFixedSize(getWindow().getWindowManager()
.getDefaultDisplay().getWidth(), getWindow().getWindowManager()
.getDefaultDisplay().getHeight());
}
这是我的surfaceChanged()
方法:
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
Log.e(TAG, "surfaceChanged");
if (mPreviewRunning) {
mCamera.stopPreview();
}
Camera.Parameters p = mCamera.getParameters();
List<Size> sizes = p.getSupportedPictureSizes();
System.out.println("Lista de parametrii este urmatoarea:"+sizes);
Size size = sizes.get(0);
p.setPreviewSize(640, 480);
p.setPictureSize(size.width,size.height);
mCamera.setParameters(p);
try {
mCamera.setPreviewDisplay(holder);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mCamera.startPreview();
mPreviewRunning = true;
}
我正在尝试使用此方法获取包含所有支持的大小图片的列表:
List<Size> sizes = p.getSupportedPictureSizes();
返回以下内容:
[android.hardware.Camera$Size@65d4c50, android.hardware.Camera$Size@65d49ec, android.hardware.Camera$Size@50ddab8, android.hardware.Camera$Size@3fe4e00, android.hardware.Camera$Size@32ea628, android.hardware.Camera$Size@3be67b8, android.hardware.Camera$Size@27ef0c0, android.hardware.Camera$Size@27eefd0, android.hardware.Camera$Size@13f7860, android.hardware.Camera$Size@ef9a20]
我所做的是循环此列表并设置我的图片大小以获得更大的尺寸:
Size size = sizes.get(0);
p.setPictureSize(size.width,size.height);
我也完成了:sizes.get(1)
,sizes.get(2)
,sizes.get(3)
..... sizes.get(8)
。
现在的问题是,当我这样做时:
Size size = sizes.get(0);
p.setPictureSize(size.width,size.height);
我的屏幕变黑了一段时间后我在logcat中收到了这个错误:
WIN DEATH: null
Failed looking up window
java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@2b40d510 does not exist
at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:8180)
at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:8171)
at com.android.server.WindowManagerService$WindowState$DeathRecipient.binderDied(WindowManagerService.java:7029)
at android.os.BinderProxy.sendDeathNotice(Binder.java:389)
at dalvik.system.NativeStart.run(Native Method)
当我尝试:sizes.get(1)
,sizes.get(2)
,sizes.get(3)
..... sizes.get(8)
它有效但我的照片看起来像这样:
http://i53.tinypic.com/2ib2crn.png
那么我该怎么做才能获得全屏图片?谢谢
答案 0 :(得分:0)
我必须设置ImageView,我将照片设置为width=fill_parent
和height=fill_parent
!