camera2录像旋转_Android9.0 Camera2 横屏问题修改记录

vendor\mediatek\proprietary\packages\apps 目录下有三份相机源码 分别是

Camera、 Camera1、 Camera2

通过查看 mk 发现通过 ifeq ($(MTK_CAMERA_APP_VERSION), 3) 来控制编译哪一个,

MTK_CAMERA_APP_VERSION 宏定义在 device/mediateksample/xxxxxx/ProjectConfig.mk

整体界面相关

Camera2 中适配了两套 api, 老版本的 Camera 和新版本的 Camera2, 通过 CameraApiHelper 配置

Camera2\common\src\com\mediatek\camera\common\mode\CameraApiHelper.java

public static CameraApi getCameraApiType(@Nullable String modeName) {

return CameraApi.API2;

}

public enum CameraApi {

/** Use the {@link android.hardware.Camera} class. */

API1,

/** Use the {@link android.hardware.camera2} package. */

API2

}

预览布局不延伸到 navigation 中,不显示 statusbar

增加 requestWindowFeature(Window.FEATURE_NO_TITLE)

Camera2\host\src\com\mediatek\camera\QuickActivity.java

@Override

protected final void onCreate(Bundle bundle) {

LogHelper.i(TAG, "onCreate()");

IPerformanceProfile profile = PerformanceTracker.create(TAG, "onCreate").start();

mStartupOnCreate = true;

super.onCreate(bundle);

//cczheng add for don't show statusbar

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

requestWindowFeature(Window.FEATURE_NO_TITLE);

mMainHandler = new Handler(getMainLooper());

onPermissionCreateTasks(bundle);

profile.stop();

}

注释 setSystemUiVisibility(View.SYSTEM_UI_LAYOUT_FLAGS | View.SYSTEM_UI_FLAG_LAYOUT_STABLE

Camera2\host\src\com\mediatek\camera\CameraActivity.java

@Override

protected void onCreateTasks(Bundle savedInstanceState) {

if (!isThirdPartyIntent(this) && !isOpenFront(this)) {

CameraUtil.launchCamera(this);

}

IPerformanceProfile profile = PerformanceTracker.create(TAG, "onCreate").start();

super.onCreateTasks(savedInstanceState);

//cczheng annotation for layout forbbiden into navigationbar area

/*getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_LAYOUT_FLAGS

| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);*/

setContentView(R.layout.activity_main);

mOrientationListener = new OrientationEventListenerImpl(this);

//create common ui module.

mCameraAppUI = new CameraAppUI(this);

profile.mark("CameraAppUI initialized.");

mCameraAppUI.onCreate();

profile.mark("CameraAppUI.onCreate done.");

mIModeListener = new ModeManager();

mIModeListener.create(this);

profile.mark("ModeManager.create done.");

profile.stop();

}

旋转界面圆形图标 90 度, 闪光灯、HDR、拍照模式等

canvas.rotate(90)

Camera2\common\src\com\mediatek\camera\common\widget\RotateImageView.java

@Override

protected void onDraw(Canvas canvas) {

Drawable drawable = getDrawable();

if (drawable == null) {

return;

}

Rect bounds = drawable.getBounds();

int w = bounds.right - bounds.left;

int h = bounds.bottom - bounds.top;

....

// canvas.rotate(-mCurrentDegree);

canvas.rotate(90);//cczheng change 90 for rotate all imageView

canvas.translate(-w / 2, -h / 2);

if (mDrawableBitmap != null) {

canvas.drawBitmap(mDrawableBitmap, 0, 0, null);

} else {

drawable.draw(canvas);

}

canvas.restoreToCount(saveCount);

}

拍照相关

预览旋转 90

horizontalMirrorData() 和 changePreviewDisplayOrientation() 都是从网上找的简单矩阵算法,验证

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值