Android 12.0 默认相机前摄和后摄照片大小为4:3比例

Android 12.0 默认相机前摄和后摄照片大小为4:3比例

近来收到客户的反馈,想要在相机设置里把前摄和后摄的照片比例全部默认设置为4:3,因为相机前摄和后摄的4:3照片比例都是所有选项中的最高像素选项,所以我们只需通过将最高像素选项设为默认选项即可实现功能需求,具体修改点如下:

在/vendor/mediatek/proprietary/packages/apps/Camera2/feature/setting/picturesize/src/com/mediatek/camera/feature/setting/picturesize/PictureSize.java中做如下修改:

        if (valueInStore == null) {
            // Default picture size is the max full-ratio size.
            List entryValues = getEntryValues();
            for (String value : entryValues) {
                if (PictureSizeHelper.getStandardAspectRatio(value) == fullRatio) {
		    /*/start
                    valueInStore = value;
		    //*/
                    valueInStore =PictureSizeHelper.getMaxPictureSize(getEntryValues());
		    //*/end
                    break;
                }
            }
        }

在/vendor/mediatek/proprietary/packages/apps/Camera2/feature/setting/picturesize/src/com/mediatek/camera/feature/setting/picturesize/PictureSizeHelper.java中加入如下方法:

    public static String getMaxPictureSize(List supportedEntryValues){
        int temp=0;
        int maxSize=0;
        int maxIndex=0;
       for (int i=0;i< supportedEntryValues.size();i++) {
            Size size = valueToSize(supportedEntryValues.get(i));
            temp = size.width * size.height;      
            if (temp > maxSize) {
                maxSize = temp;
                maxIndex = i;
            }
        }
        return supportedEntryValues.get(maxIndex);
    }

重新编译验证,修改生效,相机默认前摄和后摄照片大小已改为4:3比例

你可能感兴趣的:(Android,android)