TextReader组件在播控中心的icon显示不正确,没有铺满整个组件。
我们传入播控中心的图片是通过代码获取的image.PixelMap,获取image.PixelMap的代码是我们的官网提供的示例代码, 获取之后就在调用TextReader的时候传给 TextReader.ReadInfo中的image。
获取image.PixelMap的代码如下面所示:
class ImageSize {
height: number = 800
width: number = 800
}
export class ImagePixelMapUtil {
private imagePixelMap: Map<string, PixelMap> = new Map()
private options: Record<string, number | boolean | ImageSize> = {
'alphaType': 0, // 透明度
'editable': false, // 是否可编辑
'pixelFormat': 3, // 像素格式
'scaleMode': 1, // 缩略值
'size': {
height: 800, width: 800
}
}
downLoadAndSave(imageUrl: string) {
if (this.imagePixelMap.has(imageUrl)) {
return
}
http.createHttp().request(imageUrl,
(error: BusinessError, data: http.HttpResponse) => {
if (error) {
ZHGLog.error(`http request failed with. Code: ${error.code}, message: ${error.message}`);
} else {
image.createImageSource(data.result as ArrayBuffer)
.createPixelMap(this.options)
.then((pixelMap: PixelMap) => {
this.saveImagePixelMap(imageUrl, pixelMap)
})
}
}
)
}
需修改createPixelMap(this.options)中的option,修改为:
完整demo如下: