2024年3月12日发(作者:)
Android 放大镜效果实现
放大镜就是直接调用相机,使用放大缩小的功能实现,
调用相机有两种方式,一种是直接调用系统的;另一种是自
定义相机,需要自定义一个预览界面,下面简单介绍自定义
相机方式:
参
考:/guide/topics/media/camer
首先我们需要申请权限:
1、获取需要的权限,检测手机是否有相机。
//manifest里添加使用相机的权限
//使用相机属性
//相机自动对焦
567
然后再判断是否有相机存在:
/** Check if this device has a camera */
private boolean checkCameraHardware(Context context) {
if
(kageManager().hasSystemFeature(Packa
E_CAMERA)){
// this device has a camera
return true;
} else {
// no camera on this device
return false;
}
}1234567891
2.打开相机,官网实现的安全方式打开相机
/** A safe way to get an instance of the Camera object. */
public static Camera getCameraInstance(){
Camera c = null;
try {
c = (); // attempt to get a Camera
instance
}
catch (Exception e){
// Camera is not available (in use or does not


发布评论