android 如何?前置camera自拍鏡像功能

來源:互聯網
上載者:User

android 如何?前置camera自拍鏡像功能
預設的前置camera, 文字”XI”在preview時顯示為”IX”(前置camera preview時預設會有mirror效果), 拍攝出來的照片為"XI",如何讓拍攝出來的照片也是”IX” , 也就是和preview時保持一致?



對於普通單拍(非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(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(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\)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.