成年大片免费视频播放二级_早上躁晚上躁天天躁8090_新金瓶梅2下载_欧美国产一卡二在线播放_国产在线精品欧美日韩电影

您的位置:首頁技術(shù)文章
文章詳情頁

Android 如何在攝像頭預(yù)覽的背景上加上一個手指可拖動的調(diào)節(jié)框?

【字號: 日期:2024-09-12 13:14:28瀏覽:80作者:豬豬

問題描述

請問調(diào)節(jié)框該如何繪制?是在SufaceView 中繪制么?手指拖動如何實現(xiàn)?

啟動拍照功能后,下面是攝像頭預(yù)覽的背景(模擬器的),在這個背景上加上一個調(diào)節(jié)框Android 如何在攝像頭預(yù)覽的背景上加上一個手指可拖動的調(diào)節(jié)框?

Activity代碼

public class PickActivity extends AppCompatActivity { private Button mBtnPick; private SurfaceView mSvView; private SurfaceHolder.Callback mCallback; private Camera mCamera; @Override protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_pick);initView();mCallback = new SurfaceHolder.Callback() { @Override public void surfaceCreated(SurfaceHolder holder) {startCamera(); } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } @Override public void surfaceDestroyed(SurfaceHolder holder) {stopCamera(); }};mSvView.getHolder().addCallback(mCallback);mBtnPick.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {mCamera.takePicture(null, null, new Camera.PictureCallback() { @Override public void onPictureTaken(byte[] data, Camera camera) {File path = new File(Environment.getExternalStorageDirectory(), 'test');if (!path.exists()) { path.mkdirs();}File fileName = new File(path, 'test.jpg');try { FileOutputStream fos = new FileOutputStream(fileName); fos.write(data); fos.flush(); fos.close();} catch (IOException e) { e.printStackTrace();} }}); }}); } private void stopCamera() {mCamera.stopPreview();mCamera.release();mCamera = null; } private void startCamera() {mCamera = Camera.open();try { mCamera.setPreviewDisplay(mSvView.getHolder()); mCamera.setDisplayOrientation(90); mCamera.startPreview();} catch (IOException e) { e.printStackTrace();} } private void initView() {mBtnPick = (Button) findViewById(R.id.id_btn_pick);mSvView = (SurfaceView) findViewById(R.id.id_sv_camera); }}

問題解答

回答1:

添加seekBar

相關(guān)文章: