diff --git a/zh-cn/application-dev/reference/apis/js-apis-effectKit.md b/zh-cn/application-dev/reference/apis/js-apis-effectKit.md index 377f3e7ef73d3941138ff7b6693aed3a7267e5b6..0794363da748987fcf28d0494aba0b1bc6262f9b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-effectKit.md +++ b/zh-cn/application-dev/reference/apis/js-apis-effectKit.md @@ -83,6 +83,41 @@ image.createPixelMap(color, opts).then((pixelMap) => { }) ``` +## effectKit.createColorPicker10+ + +createColorPicker(source: image.PixelMap, region: Array\): Promise\ + +通过传入的PixelMap创建选定取色区域的ColorPicker实例,使用Promise异步回调。 + +**系统能力:** SystemCapability.Multimedia.Image.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------- | ---- | -------------------------- | +| source | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | image模块创建的PixelMap实例。可通过图片解码或直接创建获得,具体可见[图片开发指导](../../media/image-overview.md)。 | +| region | Array\ | 是 | 指定图片的取色区域。
数组元素个数为4,取值范围为[0, 1],数组元素分别表示图片区域的左、上、右、下位置,图片最左侧和最上侧对应位置0,最右侧和最下侧对应位置1。数组第三个元素需大于第一个元素,第四个元素需大于第二个元素。
此参数不填时,默认值为[0, 0, 1, 1],表示取色区域为全图。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | -------------- | +| Promise\<[ColorPicker](#colorpicker)> | Promise对象。返回创建的ColorPicker实例。 | + +**示例:** + +```js +import image from "@ohos.multimedia.image"; + +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +image.createPixelMap(color, opts).then((pixelMap) => { + effectKit.createColorPicker(pixelMap, [0, 0, 0.5, 0.5]).then(colorPicker => { + console.info("color picker=" + colorPicker); + }).catch(ex => console.error(".error=" + ex.toString())) +}) +``` + ## effectKit.createColorPicker createColorPicker(source: image.PixelMap, callback: AsyncCallback\): void @@ -116,6 +151,40 @@ image.createPixelMap(color, opts).then((pixelMap) => { }) ``` +## effectKit.createColorPicker10+ + +createColorPicker(source: image.PixelMap, region:Array\, callback: AsyncCallback\): void + +通过传入的PixelMap创建选定取色区域的ColorPicker实例,使用callback异步回调。 + +**系统能力:** SystemCapability.Multimedia.Image.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------ | ---- | -------------------------- | +| source | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 |image模块创建的PixelMap实例。可通过图片解码或直接创建获得,具体可见[图片开发指导](../../media/image-overview.md)。 | +| region | Array\ | 是 | 指定图片的取色区域。
数组元素个数为4,取值范围为[0, 1],数组元素分别表示图片区域的左、上、右、下位置,图片最左侧和最上侧对应位置0,最右侧和最下侧对应位置1。数组第三个元素需大于第一个元素,第四个元素需大于第二个元素。
此参数不填时,默认值为[0, 0, 1, 1],表示取色区域为全图。 | +| callback | AsyncCallback\<[ColorPicker](#colorpicker)> | 是 | 回调函数。返回创建的ColorPicker实例。 | + +**示例:** + +```js +import image from "@ohos.multimedia.image"; + +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +image.createPixelMap(color, opts).then((pixelMap) => { + effectKit.createColorPicker(pixelMap, [0, 0, 0.5, 0.5], (error, colorPicker) => { + if (error) { + console.log('Failed to create color picker.'); + } else { + console.log('Succeeded in creating color picker.'); + } + }) +}) +``` + ## Color 颜色类,用于保存取色的结果。 @@ -124,10 +193,10 @@ image.createPixelMap(color, opts).then((pixelMap) => { | 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ----- | ---- | ---- | ---------------- | -| red | number | 是 | 否 | 红色分量值。 | -| green | number | 是 | 否 | 绿色分量值。 | -| blue | number | 是 | 否 | 蓝色分量值。 | -| alpha | number | 是 | 否 | 透明通道分量值。 | +| red | number | 是 | 否 | 红色分量值,取值范围[0x0, 0xFF]。 | +| green | number | 是 | 否 | 绿色分量值,取值范围[0x0, 0xFF]。 | +| blue | number | 是 | 否 | 蓝色分量值,取值范围[0x0, 0xFF]。 | +| alpha | number | 是 | 否 | 透明通道分量值,取值范围[0x0, 0xFF]。 | ## ColorPicker @@ -254,6 +323,12 @@ isBlackOrWhiteOrGrayColor(color: number): boolean **系统能力:** SystemCapability.Multimedia.Image.Core +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------- | ---- | -------------------------- | +| color| number | 是 | 需要判断是否黑白灰色的颜色值,取值范围[0x0, 0xFFFFFFFF]。 | + **返回值:** | 类型 | 说明 |