设置头像风格
SetAvatarStyle
接口描述
该接口用于设置头像风格。
注意事项
- 该接口为异步接口,返回值只代表接口是否调用成功,实际业务处理结果在对应的回调函数中返回。
方法定义
| 1 | HWM_SDK_AGENT_API hwmsdk::HwmErrCode SetAvatarStyle(const HwmAvatarStyle* avatarStyle); | 
回调函数
| 1 | virtual void OnSetAvatarStyleResult(hwmsdk::HwmErrCode ret, const char* reason) {}; | 
参数描述
| 参数 | 是否必须 | 类型 | 描述 | 
|---|---|---|---|
| backgroundColor | 是 | char[] | 背景色。格式为ARGB,如#ff59aaff | 
| textColor | 是 | char[] | 实体颜色。格式为ARGB,如#ffffffff | 
| phoneIconPath | 是 | char[] | 手机图标路径,使用绝对路径。如“to/path/image.svg”,支持svg/png等格式。 注:需要UTF8编码。 | 
| boardIconPath | 是 | char[] | 大屏图标路径,使用绝对路径。如“to/path/image.svg”,支持svg/png等格式。 注:需要UTF8编码。 | 
| nameShowType | 否 | HwmNameShowType | 姓名显示风格。 | 
| avatarShape | 否 | HwmAvatarShape | 头像形状。 | 
| 枚举值 | 描述 | 
|---|---|
| FIRST_LETTER | 显示拼音首字母(如果是英文名则显示首字母)。 | 
| FAMILY_NAME | 显示姓氏(如果是英文名则显示首字母)。 | 
| 枚举值 | 描述 | 
|---|---|
| CIRCLE | 圆形头像。 | 
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /** * 设置头像风格 */ void demoSetAvatarStyleDlg::SetAvatarStyle() { hwmsdkagent::HwmAvatarStyle avatarStyle{}; CString contentCStr; m_editBKColor.GetWindowText(contentCStr); std::string content = CTools::UNICODE2UTF(contentCStr.GetString()); errno_t err = strcpy_s(avatarStyle.backgroundColor, sizeof(avatarStyle.backgroundColor), content.c_str()); m_editTextColor.GetWindowText(contentCStr); content = CTools::UNICODE2UTF(contentCStr.GetString()); err += strcpy_s(avatarStyle.textColor, sizeof(avatarStyle.textColor), content.c_str()); m_editPhoneIconPath.GetWindowText(contentCStr); content = CTools::UNICODE2UTF(contentCStr.GetString()); err += strcpy_s(avatarStyle.phoneIconPath, sizeof(avatarStyle.phoneIconPath), content.c_str()); m_editBoardIconPath.GetWindowText(contentCStr); content = CTools::UNICODE2UTF(contentCStr.GetString()); err += strcpy_s(avatarStyle.boardIconPath, sizeof(avatarStyle.boardIconPath), content.c_str()); if (err != S_OK) { AfxMessageBox(_T("String Copy Error!")); } unsigned int nameShowType = hwmsdkagent::HwmNameShowType::FIRST_LETTER; nameShowType = (unsigned int)m_comboboxNameShowType.GetCurSel(); avatarStyle.nameShowType = static_cast<hwmsdkagent::HwmNameShowType>(nameShowType); unsigned int avatarShape = hwmsdkagent::HwmAvatarShape::CIRCLE; avatarShape = (unsigned int)m_comboboxAvatarType.GetCurSel(); avatarStyle.avatarShape = static_cast<hwmsdkagent::HwmAvatarShape>(avatarShape); int ret = hwmsdkagent::SetAvatarStyle(&avatarStyle); return ret; } | 
 
  