android 如何实现前置camera自拍镜像功能
对于普通单拍(非ZSD或其他拍照模式), 需要修改的代码为normalShot.cpp文件中的onCmd_capture()方法,
将原来的
bool
NormalShot::
onCmd_capture()
{
AutoCPTLog cptlog(Event_Shot_capture);
MBOOL ret = MTRUE;
NSCamShot::ISingleShot *pSingleShot = NSCamShot::ISingleShot::createInstance(static_cast<EShotMode>(mu4ShotMode), "NormalShot");
......
// shot param
NSCamShot::ShotParam rShotParam(eImgFmt_YUY2, //yuv format
mShotParam.mi4PictureWidth, //picutre width
mShotParam.mi4PictureHeight, //picture height
mShotParam.mi4Rotation, //picture rotation
0, //picture flip
ePostViewFmt, // postview format
mShotParam.mi4PostviewWidth, //postview width
mShotParam.mi4PostviewHeight, //postview height
0, //postview rotation
0, //postview flip
mShotParam.mu4ZoomRatio //zoom
);
......
}
修改为:
bool
NormalShot::
onCmd_capture()
{
AutoCPTLog cptlog(Event_Shot_capture);
MBOOL ret = MTRUE;
NSCamShot::ISingleShot *pSingleShot = NSCamShot::ISingleShot::createInstance(static_cast<EShotMode>(mu4ShotMode), "NormalShot");
......
// shot param
NSCamShot::ShotParam rShotParam(eImgFmt_YUY2, //yuv format
mShotParam.mi4PictureWidth, //picutre width
mShotParam.mi4PictureHeight, //picture height
mShotParam.mi4Rotation, //picture rotation
(getOpenId()==1? 1:0), //picture flip //此处为修改的代码,将这里的值改为1,底层则会将image做横向的flip, 相当于mirror.
ePostViewFmt, // postview format
mShotParam.mi4PostviewWidth, //postview width
mShotParam.mi4PostviewHeight, //postview height
0, //postview rotation
0, //postview flip
mShotParam.mu4ZoomRatio //zoom
);
......
}
主要将参数rShotParam里面的flip值改为1, 值为1表示底层将把image做横向的flip,若为0则不做.
(上述改动中的getOpenId()==1? 1:0只为测试使用,意为判断当前是否为前置camera, 若为前置camera, 则赋值为1)
请您注意:
在实际应用中, 请在Parameters中新增一个Flip参数, 并在app中通过Parameters传递Flip值到HAL层来通知底层做flip. (为避免影响CTS测试和三方应用, 请勿直接将上述的提到的flip值固定写为1.)
涉及修改的文件主要如下:
NormalShot.cpp (mediatek\platform\mt6589\hardware\camera\hal\adapter\scenario\shot\normalshot)
IShot.h (mediatek\platform\mt6589\hardware\camera\hal\adapter\inc\scenario\shot)
CameraParameters.cpp (frameworks\av\camera)
CameraParameters.h (frameworks\av\include\camera)
ParamsManager.update.cpp (mediatek\hardware\camera\common\paramsmgr\params)
MtkPhotoCamAdapter.Capture.cpp (mediatek\platform\mt6589\hardware\camera\hal\adapter\mtkphoto)
Camera.java(\frameworks\base\core\java\android\hardware\)
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。