mtk平台Camera应用的全屏分析

来源:互联网 发布:400块一家收淘宝店铺 编辑:程序博客网 时间:2024/05/13 00:18

     将摄像头的配置文件vendor/mediatek/proprietary/custom/mt6735/hal/D1/sendepfeature/xxxx_mipi_raw/config.ftbl.xxxx_mipi_raw.h

编译进系统后,选择预览大小为全屏,图片大小显示一个100万像素,拍出图片只有1280x768,

但真实的摄像头有500万像素,拍出的图片大小不应该这么小,当预览大小为4:3是,有多中图片

大小可供选择,照片大小正常.该应用的全屏为什么不对呢.

vendor/mediatek/proprietary/packages/apps/Camera/

CameraDeviceExt.java

// TODO    @Override    public void setPreviewSize() {        String pictureRatio = mPreferences.getString(SettingConstants.KEY_PICTURE_RATIO, null);         if (pictureRatio == null) {  //刷机第一次跑            List<String> supportedRatios = SettingUtils.buildPreviewRatios(mActivity,                    mParametersExt);            if (supportedRatios != null && supportedRatios.size() > 0) {                SharedPreferences.Editor editor = mPreferences.edit();                String ratioString = supportedRatios.get(supportedRatios.size() - 1);        editor.putString(SettingConstants.KEY_PICTURE_RATIO, ratioString);                editor.apply();                pictureRatio = ratioString;            }        }        SettingUtils.setPreviewSize(mActivity, mParametersExt, pictureRatio);        String pictureSize = mPreferences.getString(SettingConstants.KEY_PICTURE_SIZE, null);        int limitedResolution = SettingUtils.getLimitResolution();        if (limitedResolution > 0) {            int index = pictureSize.indexOf('x');            int width = Integer.parseInt(pictureSize.substring(0, index));            int height = Integer.parseInt(pictureSize.substring(index + 1));            if (width * height > limitedResolution) {                pictureSize = null;            }        }        if (pictureSize == null) {            List<String> supportedSizes = SettingUtils                    .buildSupportedPictureSizeByRatio(mParametersExt, pictureRatio);            SettingUtils.sortSizesInAscending(supportedSizes);            Log.i(TAG, "limitedResolution:" + limitedResolution);            if (limitedResolution > 0) {                SettingUtils.filterLimitResolution(supportedSizes);            }            if (supportedSizes != null && supportedSizes.size() > 0) {                pictureSize = supportedSizes.get(supportedSizes.size() - 1);                SharedPreferences.Editor editor = mPreferences.edit();                editor.putString(SettingConstants.KEY_PICTURE_SIZE, pictureSize);                editor.apply();            }        }        Point ps = SettingUtils.getSize(pictureSize);        mParametersExt.setPictureSize(ps.x, ps.y);    }

String pictureRatio = mPreferences.getString(SettingConstants.KEY_PICTURE_RATIO, null);

这里读上次的值,所有调试的时候要将/data/data/com.mediatek.camera/shared_prefs删掉,否则看不到打印信息

SettingUtils.java

    public static List<String> buildPreviewRatios(Context context, Parameters parameters) {        List<String> supportedRatios = new ArrayList<String>();        String findString = null;        if (context != null && parameters != null) {            // Add standard preview ratio.            supportedRatios.add(getRatioString(4d / 3));            mCurrentFullScreenRatio = findFullscreenRatio(context);            List<String> fullScreenPictureSizes = buildSupportedPictureSizeByRatio(parameters,                    getRatioString(mCurrentFullScreenRatio));            // Add full screen ratio if platform has full screen ratio picture sizes.            if (fullScreenPictureSizes.size() > 0) {                findString = getRatioString(mCurrentFullScreenRatio);                if (!supportedRatios.contains(findString)) {                    supportedRatios.add(findString);                }            }        }        Log.d(TAG, "buildPreviewRatios(" + parameters + ") add supportedRatio " + findString);        return supportedRatios;    }


public static final double[] RATIOS = new double[] { 1.3333, 1.5, 1.6667, 1.7778 };    public static double findFullscreenRatio(Context context) {        double find = 4d / 3;        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);        Display display = wm.getDefaultDisplay();        Point point = new Point();        display.getRealSize(point);        mFullScreenWidth = point.x;        mFullScreenHeight = point.y;        double fullscreen;        if (point.x > point.y) {            fullscreen = (double) point.x / point.y;        } else {            fullscreen = (double) point.y / point.x;        }        Log.i(TAG, "fullscreen = " + fullscreen + " x = " + point.x + " y = " + point.y);        for (int i = 0; i < RATIOS.length; i++) {            if (Math.abs(RATIOS[i] - fullscreen) < Math.abs(fullscreen - find)) {                find = RATIOS[i];            }        }        Log.d(TAG, "findFullscreenRatiom, return ratio:" + find);        return find;    }

从源码看就是从4:3,5:3,3:2,16:9中找出最接近屏幕的屏比,那么在摄像头的配置文件中添加相应比例

的图片大小即可,注意不要超过摄像头像素,否则第三方应用获取到的摄像头分辨率(所有图片大小

中最大的一个对应的像素)不对.




原创粉丝点击