Android游戏开发学习笔记(四):Camera图像采集(2)
来源:未知 责任编辑:责任编辑 发表时间:2014-01-25 11:34 点击:次
public class MainActivity extends Activity implements SurfaceHolder.Callback {
Camera myCamera;
SurfaceView mySurfaceView;
SurfaceHolder mySurfaceHolder;
Button btn1, btn2;
boolean isPreview = false;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mySurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
btn1 = (Button) findViewById(R.id.btn1);
btn2 = (Button) findViewById(R.id.btn2);
mySurfaceHolder = mySurfaceView.getHolder();
mySurfaceHolder.addCallback(this);
mySurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
btn1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
initCamera();
}
});
btn2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (myCamera != null && isPreview) {
myCamera.stopPreview();
myCamera.release();
myCamera = null;
isPreview = false;
}
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>