本讲是Android Camera专题系列的第37讲,我们介绍Android Camera2 API专题的拍照打闪实战。
更多资源:
资源 | 描述 |
---|---|
在线课程 | 极客笔记在线课程 |
知识星球 | 星球名称:深入浅出Android Camera 星球ID: 17296815 |
极客笔记圈 |
CameraController2#CameraSettings#setAEMode
switch(flash_value) {
case "flash_off":
builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
builder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
break;
case "flash_auto":
// note we set this even in fake flash mode (where we manually turn torch on and off to simulate flash) so we
// can read the FLASH_REQUIRED state to determine if flash is required
/*if( use_fake_precapture || CameraController2.this.want_expo_bracketing )
builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
else*/
builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH);
builder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
break;
case "flash_on":
// see note above for "flash_auto" for why we set this even fake flash mode - arguably we don't need to know
// about FLASH_REQUIRED in flash_on mode, but we set it for consistency...
/*if( use_fake_precapture || CameraController2.this.want_expo_bracketing )
builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
else*/
builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_ALWAYS_FLASH);
builder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
break;
case "flash_torch":
builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
builder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH);
break;
case "flash_red_eye":
// not supported for expo bracketing or burst
if( CameraController2.this.burst_type != BurstType.BURSTTYPE_NONE )
builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
else
builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE);
builder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
break;
case "flash_frontscreen_auto":
case "flash_frontscreen_on":
case "flash_frontscreen_torch":
builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
builder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
break;
}
CameraController2#runPrecapture
等待precapture完成
CameraController2#handleStateChange
拍照
CameraController2#takePictureAfterPrecapture
本文链接:http://so.lmcjl.com/news/16261/