Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
7e6efcef
D
Docs
项目概览
OpenHarmony
/
Docs
11 个月 前同步成功
通知
158
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7e6efcef
编写于
7月 26, 2023
作者:
O
openharmony_ci
提交者:
Gitee
7月 26, 2023
浏览文件
操作
浏览文件
下载
差异文件
!20546 局部取色开发者文档
Merge pull request !20546 from pengpeng/fields/pp/regionDocs
上级
4f2cdf8c
6a0b7a3f
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
79 addition
and
4 deletion
+79
-4
zh-cn/application-dev/reference/apis/js-apis-effectKit.md
zh-cn/application-dev/reference/apis/js-apis-effectKit.md
+79
-4
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-effectKit.md
浏览文件 @
7e6efcef
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录