Android camera 使用过程中的小知识

mac2022-06-30  111

一、两个SurfaceView层叠显示

创建SurfaceView对象之后,将尺寸较小的SurfaceView设置背景透明,顶层显示。

1 mySurfaceView.setZOrderOnTop(true); //设置画布背景透明 2 mySurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);

二、调用camera时可能需要设置preview的角度,注意setDisplayOrientation(90)方法应改在unlock( )方法之前调用

1 camera = Camera.open(cameraId); 2 camera.setDisplayOrientation(90); 3 camera.unlock();

三、利用Matrix类对Bitmap进行旋转和缩放

Matrix方法中的setRotate()方法会先清除该矩阵,即设为单位矩阵。之后设置旋转操作的,同样,setTranslate()等方法也是一样的。

所以是不能叠加各种效果在一起的。

如果是想多种效果同时使用的话,应该使用postRotate(), postTranslate()等类似的矩阵变换方法。

1 Matrix matrix = new Matrix(); 2 matrix.setRotate(-90); 3 matrix.postScale(scaleX, scaleY); 4 Bitmap bmp = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);

 

转载于:https://www.cnblogs.com/QuentinYo/p/3439457.html

最新回复(0)