java pixelformat_Java PixelFormat.RGBX_8888屬性代碼示例

private void start(final boolean isCamera) {

Log.d("ImageTakin", "StartCommand()");

pref = getApplicationContext().getSharedPreferences("MyPref", 0);

editor = pref.edit();

if (mCamera != null) {

queue.removeCallbacks(null);

mCamera.setPreviewCallback(null);

mCamera.stopPreview();

mCamera.release();

mCamera = Camera.open();

} else

mCamera = getCameraInstance();

parameters = mCamera.getParameters();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && parameters.getSupportedFocusModes().contains(

Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {

parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);

} else if (parameters.getSupportedFocusModes().contains(

Camera.Parameters.FOCUS_MODE_AUTO)) {

parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);

}

mCamera.setParameters(parameters);

size = parameters.getPreviewSize();

if (registeredShieldsIDs.contains(UIShield.COLOR_DETECTION_SHIELD.name()))

mCamera.setPreviewCallback(previewCallback);

windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

params = new WindowManager.LayoutParams(

WindowManager.LayoutParams.MATCH_PARENT,

WindowManager.LayoutParams.MATCH_PARENT,

WindowManager.LayoutParams.TYPE_PRIORITY_PHONE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,

PixelFormat.RGBX_8888);

params.gravity = Gravity.TOP | Gravity.LEFT;

DisplayMetrics metrics = new DisplayMetrics();

windowManager.getDefaultDisplay().getMetrics(metrics);

int expectedHeight = metrics.heightPixels - ((int) (250 * metrics.density + .5f));

int expectedWidth = ((expectedHeight * (size == null ? metrics.widthPixels : size.height)) / (size == null ? metrics.heightPixels : size.width));

params.width = 1;// metrics.widthPixels - ((int) (60 * metrics.density + .5f));

params.height = 1;

params.x = (int) ((metrics.widthPixels / 2) - expectedWidth / 2);

params.y = (int) (150 * metrics.density + .5f);

params.alpha = 1;

sv = new SurfaceView(getApplicationContext());

windowManager.addView(sv, params);

params = (WindowManager.LayoutParams) sv.getLayoutParams();

sHolder = sv.getHolder();

sHolder.addCallback(this);

mOrientationEventListener = new OrientationEventListener(this,

SensorManager.SENSOR_DELAY_NORMAL) {

@Override

public void onOrientationChanged(int orientation) {

if (orientation == ORIENTATION_UNKNOWN) return;

mOrientation = (orientation + 45) / 90 * 90;

}

};

if (mOrientationEventListener.canDetectOrientation()) {

mOrientationEventListener.enable();

}

// tells Android that this surface will have its data constantly

// replaced

if (Build.VERSION.SDK_INT < 11)

sHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值