中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
微信扫码分享
const context = getContext(this); //获取resourceManager资源管理器 const resourceMgr: resourceManager.ResourceManager = context.resourceManager; const fileData: Uint8Array = await resourceMgr.getMediaContent(this.imgData[targetIndex]); //获取图片的ArrayBuffer const buffer = fileData.buffer; //创建imageSource const imageSource: image.ImageSource = image.createImageSource(buffer); //创建pixelMap const pixelMap: image.PixelMap = await imageSource.createPixelMap(); effectKit.createColorPicker(pixelMap, (err, colorPicker) => { //读取图像主色的颜色值,结果写入Color let color = colorPicker.getMainColorSync(); })