企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
**·腾讯** ``` //设置腾讯sdk自带基础美颜 private void setTxBeauty() { int[] currentBeautyMap = BeautyDataModel.getInstance().getCurrentBeautyMap ();   mLivePusher.setBeautyFilter(TXLiveConstants.BEAUT Y_STYLE_SMOOTH, currentBeautyMap[1], currentBeautyMap[0], currentBeautyMap[2]); } //滤镜 @Override public void onFilterChanged(FilterBean filterBean) {     if (mhBeautyManager == null) {         return;     }     FilterEnum filterEnum = filterBean.getFilterEnum();     if (filterEnum == FilterEnum.PRO_FILTER) {         mhBeautyManager.changeDynamicFilter(filterBean.getmFilterName());     } else {         Bitmap lookupBitmap = BitmapUtil.getFilterBitmap(this,filterEnum);         mhBeautyManager.setFilter(lookupBitmap);     } } ``` **·金山** ``` //设置金山直播sdk自带基础美颜     private void setKsyBeauty() {         if (mImgBeautyProFilter == null) {             initBaseBeauty();         }         if (mImgBeautyProFilter != null && mImgBeautyProFilter.isRuddyRatioSupported()) {             int[] currentBeautyMap = BeautyDataModel.getInstance().getCurrentBeautyMap();             float whiteValue = (currentBeautyMap[0] + currentBeautyMap[0]/10f) / 10f;             float grindValue = (currentBeautyMap[1] + currentBeautyMap[1]/10f) / 10f;             float ruddyValue = (currentBeautyMap[2] + currentBeautyMap[2]/10f) / 10f;             mImgBeautyProFilter.setGrindRatio(grindValue);             mImgBeautyProFilter.setWhitenRatio(whiteValue);             mImgBeautyProFilter.setRuddyRatio(ruddyValue);         } } //金山直播sdk自带滤镜     @Override     public void onFilterChanged(FilterEnum tiFilterEnum) { if (mStreamer == null || mhBeautyManager == null) return;         FilterEnum filterEnum = filterBean.getFilterEnum();         if (filterEnum == FilterEnum.PRO_FILTER) {             if (mFilterArray[2] != null) {                 mStreamer.getImgTexFilterMgt().replaceFilter(mFilterArray[2], null);             } else {                 mStreamer.getImgTexFilterMgt().addFilterAfter(mFilterArray[1], null);             }             mFilterArray[2] = null;             mhBeautyManager.changeDynamicFilter(filterBean.getmFilterName());         } else {             int type = 0;             switch (filterEnum) {                 case NO_FILTER:                     break;                 case ROMANTIC_FILTER:                     type = ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_RUDDY_NIGHT;                     break;                 case FRESH_FILTER:                     type = ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_NATURE;                     break;                 case BEAUTIFUL_FILTER:                     type = ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_SWEETY;                     break;                 case PINK_FILTER:                     type = ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_RUDDY;                     break;                 case NOSTALGIC_FILTER:                     type = ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_NOSTALGIA;                     break;                 case COOL_FILTER:                     type = ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_FRESHY;                     break;                 case BLUES_FILTER:                     type = ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_BLUE;                     break;                 case JAPANESE_FILTER:                     type = ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_SAKURA;                     break;             }             ImgBeautySpecialEffectsFilter colorFilter = null;             if (type != 0) {                 colorFilter = new ImgBeautySpecialEffectsFilter(mStreamer.getGLRender(), this, type);             }             mhBeautyManager.changeDynamicFilter("");             if (mFilterArray[2] != null) {                 mStreamer.getImgTexFilterMgt().replaceFilter(mFilterArray[2], colorFilter);             } else {                 mStreamer.getImgTexFilterMgt().addFilterAfter(mFilterArray[1], colorFilter);             }             mFilterArray[2] = colorFilter;         }     } ``` **·除腾讯、金山直播平台之外的其他平台** 使用美狐SDK自带基础美颜,请移除直播平台sdk自带美颜的相关功能的设置代码,以防过度耗费资源,美狐SDK自带基础美颜使用方式如下: ``` //滤镜回调接口     @Override public void onFilterChanged(FilterBean filterBean) {     if (mhBeautyManager == null) {         return;     }     FilterEnum filterEnum = filterBean.getFilterEnum();     if (filterEnum == FilterEnum.PRO_FILTER) {         mhBeautyManager.changeDynamicFilter(filterBean.getmFilterName());     } else {         Bitmap lookupBitmap = BitmapUtil.getFilterBitmap(this,filterEnum);         mhBeautyManager.setFilter(lookupBitmap);     } } //美狐sdk自带基础美颜回调接口处理方式     @Override     public void onMeiBaiChanged(int progress) {         if (mhBeautyManager != null) {             mhBeautyManager.setSkinWhiting(progress);         }     }     @Override     public void onMoPiChanged(int progress) {         if (mhBeautyManager != null) {             mhBeautyManager.setSkinSmooth(progress);         }     }     @Override     public void onFengNenChanged(int progress) {         if (mhBeautyManager != null) {             mhBeautyManager.setSkinTenderness(progress);         }     }     @Override     public void onBeautyOrigin() {         if (mhBeautyManager != null) {             mhBeautyManager.setSkinWhiting(0);             mhBeautyManager.setSkinSmooth(0);             mhBeautyManager.setSkinTenderness(0);         }     } ```