经过base64转码后的图片,转化为PixelMap并进行压缩,分享出去的小程序缩略图会变得模糊不清,但是如果不压缩,或者压缩不够的话就提示无法分享,
请问这有什么好的解决方案吗?
let imagePackerApi = image.createImagePacker();
let packOpts: image.PackingOption = { format: "image/png", quality: 100 }
if (shareBean.thumData && !StrUtil.isEmpty(shareBean.thumData)) {
ImageUtilStaticLibrary.base64ToPixelMap(shareBean.thumData).then(async (result) => {
let thumbBuffer = new ArrayBuffer(1024 * 1024 * 5);
thumbBuffer = await CEMBImageUtility.compressedImage(result, 64, packOpts)
mediaMessage.thumbData = new Uint8Array(thumbBuffer)
const req = new wxopensdk.SendMessageToWXReq()
req.scene = shareScene == 0 ? this.wxChatScene : this.wxFriendsScene
req.message = mediaMessage
let finished = await wxopensdk.WXAPIFactory.createWXAPI(CommonConstants.WX_APP_ID)
.sendReq(getContext(this) as common.UIAbilityContext, req)
if (!finished) {
CEMBAppDialogUtility.showFeedBackDialog("提示", "您目前的微信版本过低或未安装微信,需要安装微信才能使用")
}
})
}
系统的限制,可以直接传文件
https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Share_and_Favorites/ohos.html