未验证 提交 7e6efcef 编写于 作者: O openharmony_ci 提交者: Gitee

!20546 局部取色开发者文档

Merge pull request !20546 from pengpeng/fields/pp/regionDocs
......@@ -83,6 +83,41 @@ image.createPixelMap(color, opts).then((pixelMap) => {
})
```
## effectKit.createColorPicker<sup>10+</sup>
createColorPicker(source: image.PixelMap, region: Array\<number>): Promise\<ColorPicker>
通过传入的PixelMap创建选定取色区域的ColorPicker实例,使用Promise异步回调。
**系统能力:** SystemCapability.Multimedia.Image.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------- | ---- | -------------------------- |
| source | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | image模块创建的PixelMap实例。可通过图片解码或直接创建获得,具体可见[图片开发指导](../../media/image-overview.md)。 |
| region | Array\<number> | 是 | 指定图片的取色区域。<br>数组元素个数为4,取值范围为[0, 1],数组元素分别表示图片区域的左、上、右、下位置,图片最左侧和最上侧对应位置0,最右侧和最下侧对应位置1。数组第三个元素需大于第一个元素,第四个元素需大于第二个元素。<br>此参数不填时,默认值为[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\<ColorPicker>): void
......@@ -116,6 +151,40 @@ image.createPixelMap(color, opts).then((pixelMap) => {
})
```
## effectKit.createColorPicker<sup>10+</sup>
createColorPicker(source: image.PixelMap, region:Array\<number>, callback: AsyncCallback\<ColorPicker>): void
通过传入的PixelMap创建选定取色区域的ColorPicker实例,使用callback异步回调。
**系统能力:** SystemCapability.Multimedia.Image.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------ | ---- | -------------------------- |
| source | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 |image模块创建的PixelMap实例。可通过图片解码或直接创建获得,具体可见[图片开发指导](../../media/image-overview.md)。 |
| region | Array\<number> | 是 | 指定图片的取色区域。<br>数组元素个数为4,取值范围为[0, 1],数组元素分别表示图片区域的左、上、右、下位置,图片最左侧和最上侧对应位置0,最右侧和最下侧对应位置1。数组第三个元素需大于第一个元素,第四个元素需大于第二个元素。<br>此参数不填时,默认值为[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]。 |
**返回值:**
| 类型 | 说明 |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册