当前位置: 首页>>代码示例>>Java>>正文


Java Parameters.setFlashMode方法代码示例

本文整理汇总了Java中android.hardware.Camera.Parameters.setFlashMode方法的典型用法代码示例。如果您正苦于以下问题:Java Parameters.setFlashMode方法的具体用法?Java Parameters.setFlashMode怎么用?Java Parameters.setFlashMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.hardware.Camera.Parameters的用法示例。


在下文中一共展示了Parameters.setFlashMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: turnLightOff

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/**
 * 通过设置Camera关闭闪光灯
 * 
 * @param mCamera
 */
public void turnLightOff() {
	if (camera == null) {
		return;
	}
	Parameters parameters = camera.getParameters();
	if (parameters == null) {
		return;
	}
	List<String> flashModes = parameters.getSupportedFlashModes();
	String flashMode = parameters.getFlashMode();
	// Check if camera flash exists
	if (flashModes == null) {
		return;
	}
	// 闪光灯打开状态
	if (!Parameters.FLASH_MODE_OFF.equals(flashMode)) {
		// Turn off the flash
		if (flashModes.contains(Parameters.FLASH_MODE_OFF)) {
			parameters.setFlashMode(Parameters.FLASH_MODE_OFF);
			camera.setParameters(parameters);
		} else {
			Log.e(TAG, "FLASH_MODE_OFF not supported");
		}
	}
}
 
开发者ID:guzhigang001,项目名称:Zxing,代码行数:31,代码来源:CameraManager.java

示例2: setFlash

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public void setFlash(boolean flag) {
    if (this.mCamera != null && CameraUtils.isFlashSupported(this.mCamera)) {
        Parameters parameters = this.mCamera.getParameters();
        if (flag) {
            if (!parameters.getFlashMode().equals("torch")) {
                parameters.setFlashMode("torch");
            } else {
                return;
            }
        } else if (!parameters.getFlashMode().equals("off")) {
            parameters.setFlashMode("off");
        } else {
            return;
        }
        this.mCamera.setParameters(parameters);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:BarcodeScannerView.java

示例3: setFlashState

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/** Turns the LED on or off if phone has one. */
public synchronized void setFlashState(boolean state) {
	Log.d("flash", "flash called");
	// If the camera has already been opened, we apply the change immediately
	if (mCamera != null) {
		Log.d("flash", "camera not null");
		if (mStreaming && mMode == MODE_MEDIARECORDER_API) {
			lockCamera();
		}
		Parameters parameters = mCamera.getParameters();

		// We test if the phone has a flash
		if (parameters.getFlashMode()==null) {
			// The phone has no flash or the choosen camera can not toggle the flash
			throw new RuntimeException("Can't turn the flash on !");
		} else {
			parameters.setFlashMode(state?Parameters.FLASH_MODE_TORCH:Parameters.FLASH_MODE_OFF);
			try {
				mCamera.setParameters(parameters);
				mFlashEnabled = state;
			} catch (RuntimeException e) {
				mFlashEnabled = false;
				throw new RuntimeException("Can't turn the flash on !");
			} finally {
				if (mStreaming && mMode == MODE_MEDIARECORDER_API) {
					unlockCamera();
				}
			}
		}
	} else {
		mFlashEnabled = state;
	}
}
 
开发者ID:galme,项目名称:ROLF-EV3,代码行数:34,代码来源:VideoStream.java

示例4: setFlashMode

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/**
 *  设置闪光灯类型
 *  @param flashMode
 */
@Override
public void setFlashMode(FlashMode flashMode) {
	if(mCamera==null) return;
	mFlashMode = flashMode;
	Parameters parameters=mCamera.getParameters();
	switch (flashMode) {
	case ON:
		parameters.setFlashMode(Parameters.FLASH_MODE_ON);
		break;
	case AUTO:
		parameters.setFlashMode(Parameters.FLASH_MODE_AUTO);
		break;
	case TORCH:
		parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
		break;
	default:
		parameters.setFlashMode(Parameters.FLASH_MODE_OFF);
		break;
	}
	mCamera.setParameters(parameters);
}
 
开发者ID:Alex-Jerry,项目名称:LLApp,代码行数:26,代码来源:CameraView.java

示例5: setFlashLightNormal

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static void setFlashLightNormal(boolean active) {

        if (camera == null)
            camera = getCamera();


        Parameters params = camera.getParameters();
        if (active) {
            params.setFlashMode(Parameters.FLASH_MODE_TORCH);
            camera.setParameters(params);
            camera.startPreview(); // 开始亮灯;
        } else {
            params.setFlashMode(Parameters.FLASH_MODE_OFF);
            camera.stopPreview(); // 关掉亮灯
            camera.release(); // 关掉照相机
            camera =null;
        }

        ZogUtils.printLog(FlashlightManager.class, "setFlashLightNormal active:" + active);
    }
 
开发者ID:BigAppOS,项目名称:BigApp_Discuz_Android,代码行数:21,代码来源:FlashlightManager.java

示例6: getCameraInstance

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/**
 * A safe way to get an instance of the Camera object.
 */
public Camera getCameraInstance() {
    Camera c = null;
    try {
        c = Camera.open(cameraId); // attempt to get a Camera instance
    } catch (Exception e) {
        Log.e(TAG, "Error:  Camera not available!");
        // Camera is not available (in use or does not exist)
    }

    Parameters params = c.getParameters();
    params.setFlashMode(Parameters.FLASH_MODE_OFF);
    params.setPictureFormat(ImageFormat.JPEG);
    params.setJpegQuality(50);            // 1-100, 100 best
    c.setParameters(params);

    return c; // returns null if camera is unavailable
}
 
开发者ID:cycronix,项目名称:cloudturbine,代码行数:21,代码来源:CTandroidAV.java

示例7: startPreview

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
private void startPreview() {
	if (myCamera != null) {
		myCamera.stopPreview();
	} else {
		myCamera = getCameraInstance();
	}
	Parameters parameters = myCamera.getParameters();
	if (canOpenFlash) {
		if (camRecordEnabled) {
			parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
		}

	} else {
		parameters.setFlashMode(Parameters.FLASH_MODE_OFF);
	}

	parameters.setPreviewFormat(ImageFormat.NV21);
	myCamera.setParameters(parameters);
	myCamera.setPreviewCallbackWithBuffer(new MyPreview());
	myCamera.addCallbackBuffer(mCallbackBuf);
	myCamera.startPreview();
}
 
开发者ID:thmedialab,项目名称:DataDrivenBP,代码行数:23,代码来源:BPActivity.java

示例8: prepare

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public boolean prepare() {
        try {
            f = new SurfaceTexture(0);

//            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
//                f.setDefaultBufferSize(10000, 10000);
//            }
           // SurfaceHolder h = new SurfaceView(JCL_ApplicationContext.getContext()).getHolder();
            //mCamera.setPreviewDisplay(h);
            mCamera.setPreviewTexture(f);
        } catch (IOException e1) {
            Log.e("JCLCAMERA", e1.getMessage());
            return false;
        }

        Parameters params = mCamera.getParameters();
        params.setPreviewSize(width, height);
        params.setPictureSize(width, height);

        params.setJpegQuality(50);
        params.setFlashMode(Parameters.FLASH_MODE_OFF);
        params.setPictureFormat(ImageFormat.JPEG);
        mCamera.setParameters(params);
        return true;
    }
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:26,代码来源:JCL_Camera.java

示例9: turnLightOn

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static void turnLightOn(Camera mCamera) {  
    if (mCamera == null) {  
        return;  
    }  
    Parameters parameters = mCamera.getParameters();  
    if (parameters == null) {  
        return;  
    }  
List<String> flashModes = parameters.getSupportedFlashModes();  
    // Check if camera flash exists  
    if (flashModes == null) {  
        // Use the screen as a flashlight (next best thing)  
        return;  
    }  
    String flashMode = parameters.getFlashMode();  
    Log.i(TAG, "Flash mode: " + flashMode);  
    Log.i(TAG, "Flash modes: " + flashModes);  
    if (!Parameters.FLASH_MODE_TORCH.equals(flashMode)) {  
        // Turn on the flash  
        if (flashModes.contains(Parameters.FLASH_MODE_TORCH)) {  
            parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);  
            mCamera.setParameters(parameters);  
        } else {  
        }  
    }  
}
 
开发者ID:li-yu,项目名称:iTester,代码行数:27,代码来源:FlashlightManager.java

示例10: turnOffFlashLight

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/**
 * フラッシュライト消灯.
 */
public synchronized void turnOffFlashLight() {
    if (mCamera != null && isFlashLightState()) {
        Parameters p = mCamera.getParameters();
        p.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
        mCamera.setParameters(p);

        if (!isShow()) {
            mCamera.stopPreview();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                try {
                    mCamera.setPreviewTexture(null);
                } catch (IOException e) {
                    if (BuildConfig.DEBUG) {
                        e.printStackTrace();
                    }
                }
            }
            mCamera.release();
            mParams = null;
            mCamera = null;
        }
    }
    mFlashLightState = false;
    mUseFlashLight = false;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:29,代码来源:CameraOverlay.java

示例11: setBestParameters

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
@UiThread
private Parameters setBestParameters(Camera camera, Parameters params) {
	setVideoStabilisation(params);
	setFocusMode(params);
	params.setFlashMode(FLASH_MODE_OFF);
	setPreviewSize(params);
	camera.setParameters(params);
	return camera.getParameters();
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:10,代码来源:CameraView.java

示例12: openLight

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/**
 * 打开闪光灯
 */
public void openLight() {
	if (camera != null) {
		Parameters parameter = camera.getParameters();
		parameter.setFlashMode(Parameters.FLASH_MODE_TORCH);
		camera.setParameters(parameter);
	}
}
 
开发者ID:AnyRTC,项目名称:anyRTC-RTCP-Android,代码行数:11,代码来源:CameraManager.java

示例13: offLight

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/**
 * 关闭闪光灯
 */
public void offLight() {
	if (camera != null) {
		Parameters parameter = camera.getParameters();
		parameter.setFlashMode(Parameters.FLASH_MODE_OFF);
		camera.setParameters(parameter);
	}
}
 
开发者ID:AnyRTC,项目名称:anyRTC-RTCP-Android,代码行数:11,代码来源:CameraManager.java

示例14: turnLightOn

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/**
 * 通过设置Camera打开闪光灯
 */
public void turnLightOn() {
	if (camera == null) {
		return;
	}
	Parameters parameters = camera.getParameters();
	if (parameters == null) {
		return;
	}

	List<String> flashModes = parameters.getSupportedFlashModes();
	if (flashModes == null) {
		return;
	}
	String flashMode = parameters.getFlashMode();
	Log.i(TAG, "Flash mode: " + flashMode);
	Log.i(TAG, "Flash modes: " + flashModes);
	// 闪光灯关闭状态
	if (!Parameters.FLASH_MODE_TORCH.equals(flashMode)) {
		// Turn on the flash
		if (flashModes.contains(Parameters.FLASH_MODE_TORCH)) {
			parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
			camera.setParameters(parameters);
			camera.startPreview();
		} else {
		}
	}
}
 
开发者ID:guzhigang001,项目名称:Zxing,代码行数:31,代码来源:CameraManager.java

示例15: toggleFlash

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public void toggleFlash() {
    if (this.mCamera != null && CameraUtils.isFlashSupported(this.mCamera)) {
        Parameters parameters = this.mCamera.getParameters();
        if (parameters.getFlashMode().equals("torch")) {
            parameters.setFlashMode("off");
        } else {
            parameters.setFlashMode("torch");
        }
        this.mCamera.setParameters(parameters);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:BarcodeScannerView.java


注:本文中的android.hardware.Camera.Parameters.setFlashMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。