Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
ed7f2822
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
未验证
提交
ed7f2822
编写于
9月 04, 2023
作者:
刘
刘关鹏
提交者:
Gitee
9月 04, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/application-dev/reference/apis/js-apis-image.md.
Signed-off-by:
N
刘关鹏
<
liuguanpeng1@huawei.com
>
上级
68aa708d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
123 addition
and
123 deletion
+123
-123
zh-cn/application-dev/reference/apis/js-apis-image.md
zh-cn/application-dev/reference/apis/js-apis-image.md
+123
-123
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-image.md
浏览文件 @
ed7f2822
...
@@ -36,10 +36,10 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\<Pi
...
@@ -36,10 +36,10 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\<Pi
**示例:**
**示例:**
```
js
```
js
const
color
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
color
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
let
bufferArr
=
new
Uint8Array
(
color
);
let
bufferArr
:
Uint8Array
=
new
Uint8Array
(
color
);
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
let
opts
:
image
.
InitializationOptions
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
image
.
createPixelMap
(
color
,
opts
).
then
((
pixelmap
)
=>
{
image
.
createPixelMap
(
color
,
opts
).
then
((
pixelmap
:
image
.
PixelMap
)
=>
{
console
.
log
(
'
Succeeded in creating pixelmap.
'
);
console
.
log
(
'
Succeeded in creating pixelmap.
'
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
log
(
'
Failed to create pixelmap.
'
);
console
.
log
(
'
Failed to create pixelmap.
'
);
...
@@ -65,10 +65,10 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: As
...
@@ -65,10 +65,10 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: As
**示例:**
**示例:**
```
js
```
js
const
color
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
color
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
let
bufferArr
=
new
Uint8Array
(
color
);
let
bufferArr
:
Uint8Array
=
new
Uint8Array
(
color
);
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
let
opts
:
image
.
InitializationOptions
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
image
.
createPixelMap
(
color
,
opts
,
(
error
,
pixelmap
)
=>
{
image
.
createPixelMap
(
color
,
opts
,
(
error
,
pixelmap
:
image
.
PixelMap
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
'
Failed to create pixelmap.
'
);
console
.
log
(
'
Failed to create pixelmap.
'
);
}
else
{
}
else
{
...
@@ -112,7 +112,7 @@ readPixelsToBuffer(dst: ArrayBuffer): Promise\<void>
...
@@ -112,7 +112,7 @@ readPixelsToBuffer(dst: ArrayBuffer): Promise\<void>
**示例:**
**示例:**
```
js
```
js
const
readBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
readBuffer
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
pixelmap
.
readPixelsToBuffer
(
readBuffer
).
then
(()
=>
{
pixelmap
.
readPixelsToBuffer
(
readBuffer
).
then
(()
=>
{
console
.
log
(
'
Succeeded in reading image pixel data.
'
);
//符合条件则进入
console
.
log
(
'
Succeeded in reading image pixel data.
'
);
//符合条件则进入
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
...
@@ -138,7 +138,7 @@ readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void
...
@@ -138,7 +138,7 @@ readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
js
```
js
const
readBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
readBuffer
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
pixelmap
.
readPixelsToBuffer
(
readBuffer
,
(
err
,
res
)
=>
{
pixelmap
.
readPixelsToBuffer
(
readBuffer
,
(
err
,
res
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
Failed to read image pixel data.
'
);
//不符合条件则进入
console
.
log
(
'
Failed to read image pixel data.
'
);
//不符合条件则进入
...
@@ -171,7 +171,7 @@ readPixels(area: PositionArea): Promise\<void>
...
@@ -171,7 +171,7 @@ readPixels(area: PositionArea): Promise\<void>
**示例:**
**示例:**
```
js
```
js
const
area
=
{
const
area
image
.
PositionArea
=
{
pixels
:
new
ArrayBuffer
(
8
),
pixels
:
new
ArrayBuffer
(
8
),
offset
:
0
,
offset
:
0
,
stride
:
8
,
stride
:
8
,
...
@@ -202,14 +202,14 @@ readPixels(area: PositionArea, callback: AsyncCallback\<void>): void
...
@@ -202,14 +202,14 @@ readPixels(area: PositionArea, callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
js
```
js
const
color
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
color
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
let
bufferArr
=
new
Uint8Array
(
color
);
let
bufferArr
:
Uint8Array
=
new
Uint8Array
(
color
);
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
let
opts
:
image
.
InitializationOptions
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
image
.
createPixelMap
(
color
,
opts
,
(
err
,
pixelmap
)
=>
{
image
.
createPixelMap
(
color
,
opts
,
(
err
,
pixelmap
:
image
.
PixelMap
)
=>
{
if
(
pixelmap
==
undefined
){
if
(
pixelmap
==
undefined
){
console
.
info
(
'
createPixelMap failed.
'
);
console
.
info
(
'
createPixelMap failed.
'
);
}
else
{
}
else
{
const
area
=
{
pixels
:
new
ArrayBuffer
(
8
),
const
area
:
image
.
PositionArea
=
{
pixels
:
new
ArrayBuffer
(
8
),
offset
:
0
,
offset
:
0
,
stride
:
8
,
stride
:
8
,
region
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
}};
region
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
}};
...
@@ -243,20 +243,20 @@ writePixels(area: PositionArea): Promise\<void>
...
@@ -243,20 +243,20 @@ writePixels(area: PositionArea): Promise\<void>
**示例:**
**示例:**
```
js
```
js
const
color
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
color
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
let
bufferArr
=
new
Uint8Array
(
color
);
let
bufferArr
:
Uint8Array
=
new
Uint8Array
(
color
);
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
let
opts
:
image
.
InitializationOptions
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
image
.
createPixelMap
(
color
,
opts
)
image
.
createPixelMap
(
color
,
opts
)
.
then
(
pixelmap
=>
{
.
then
(
(
pixelmap
:
image
.
PixelMap
)
=>
{
if
(
pixelmap
==
undefined
)
{
if
(
pixelmap
==
undefined
)
{
console
.
info
(
'
createPixelMap failed.
'
);
console
.
info
(
'
createPixelMap failed.
'
);
}
}
const
area
=
{
pixels
:
new
ArrayBuffer
(
8
),
const
area
:
image
.
PositionArea
=
{
pixels
:
new
ArrayBuffer
(
8
),
offset
:
0
,
offset
:
0
,
stride
:
8
,
stride
:
8
,
region
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
}
region
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
}
}
}
let
bufferArr
=
new
Uint8Array
(
area
.
pixels
);
let
bufferArr
:
Uint8Array
=
new
Uint8Array
(
area
.
pixels
);
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
bufferArr
[
i
]
=
i
+
1
;
bufferArr
[
i
]
=
i
+
1
;
}
}
...
@@ -287,12 +287,12 @@ writePixels(area: PositionArea, callback: AsyncCallback\<void>): void
...
@@ -287,12 +287,12 @@ writePixels(area: PositionArea, callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
js
```
js
const
area
=
{
pixels
:
new
ArrayBuffer
(
8
),
const
area
:
image
.
PositionArea
=
{
pixels
:
new
ArrayBuffer
(
8
),
offset
:
0
,
offset
:
0
,
stride
:
8
,
stride
:
8
,
region
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
}
region
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
}
}
}
let
bufferArr
=
new
Uint8Array
(
area
.
pixels
);
let
bufferArr
:
Uint8Array
=
new
Uint8Array
(
area
.
pixels
);
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
bufferArr
[
i
]
=
i
+
1
;
bufferArr
[
i
]
=
i
+
1
;
}
}
...
@@ -328,8 +328,8 @@ writeBufferToPixels(src: ArrayBuffer): Promise\<void>
...
@@ -328,8 +328,8 @@ writeBufferToPixels(src: ArrayBuffer): Promise\<void>
**示例:**
**示例:**
```
js
```
js
const
color
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
color
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
let
bufferArr
=
new
Uint8Array
(
color
);
let
bufferArr
:
Uint8Array
=
new
Uint8Array
(
color
);
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
bufferArr
[
i
]
=
i
+
1
;
bufferArr
[
i
]
=
i
+
1
;
}
}
...
@@ -358,8 +358,8 @@ writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\<void>): void
...
@@ -358,8 +358,8 @@ writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
js
```
js
const
color
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
color
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
let
bufferArr
=
new
Uint8Array
(
color
);
let
bufferArr
:
Uint8Array
=
new
Uint8Array
(
color
);
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
bufferArr
[
i
]
=
i
+
1
;
bufferArr
[
i
]
=
i
+
1
;
}
}
...
@@ -390,13 +390,13 @@ getImageInfo(): Promise\<ImageInfo>
...
@@ -390,13 +390,13 @@ getImageInfo(): Promise\<ImageInfo>
**示例:**
**示例:**
```
js
```
js
const
color
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
color
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
let
opts
=
{
editable
:
true
,
pixelFormat
:
2
,
size
:
{
height
:
6
,
width
:
8
}
}
let
opts
:
image
.
InitializationOptions
=
{
editable
:
true
,
pixelFormat
:
2
,
size
:
{
height
:
6
,
width
:
8
}
}
image
.
createPixelMap
(
color
,
opts
).
then
(
pixelmap
=>
{
image
.
createPixelMap
(
color
,
opts
).
then
(
(
pixelmap
:
image
.
PixelMap
)
=>
{
if
(
pixelmap
==
undefined
)
{
if
(
pixelmap
==
undefined
)
{
console
.
error
(
"
Failed to obtain the image pixel map information.
"
);
console
.
error
(
"
Failed to obtain the image pixel map information.
"
);
}
}
pixelmap
.
getImageInfo
().
then
(
imageInfo
=>
{
pixelmap
.
getImageInfo
().
then
(
(
imageInfo
:
image
.
ImageInfo
)
=>
{
if
(
imageInfo
==
undefined
)
{
if
(
imageInfo
==
undefined
)
{
console
.
error
(
"
Failed to obtain the image pixel map information.
"
);
console
.
error
(
"
Failed to obtain the image pixel map information.
"
);
}
}
...
@@ -424,13 +424,13 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void
...
@@ -424,13 +424,13 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void
**示例:**
**示例:**
```
js
```
js
const
color
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
color
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
let
opts
:
image
.
InitializationOptions
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
image
.
createPixelMap
(
color
,
opts
,
(
err
,
pixelmap
)
=>
{
image
.
createPixelMap
(
color
,
opts
,
(
err
,
pixelmap
:
image
.
PixelMap
)
=>
{
if
(
pixelmap
==
undefined
)
{
if
(
pixelmap
==
undefined
)
{
console
.
error
(
"
Failed to obtain the image pixel map information.
"
);
console
.
error
(
"
Failed to obtain the image pixel map information.
"
);
}
}
pixelmap
.
getImageInfo
((
err
,
imageInfo
)
=>
{
pixelmap
.
getImageInfo
((
err
,
imageInfo
:
image
.
ImageInfo
)
=>
{
if
(
imageInfo
==
undefined
)
{
if
(
imageInfo
==
undefined
)
{
console
.
error
(
"
Failed to obtain the image pixel map information.
"
);
console
.
error
(
"
Failed to obtain the image pixel map information.
"
);
}
}
...
@@ -458,11 +458,11 @@ getBytesNumberPerRow(): number
...
@@ -458,11 +458,11 @@ getBytesNumberPerRow(): number
**示例:**
**示例:**
```
js
```
js
const
color
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
color
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
let
bufferArr
=
new
Uint8Array
(
color
);
let
bufferArr
:
Uint8Array
=
new
Uint8Array
(
color
);
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
let
opts
:
image
.
InitializationOptions
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
image
.
createPixelMap
(
color
,
opts
,
(
err
,
pixelmap
)
=>
{
image
.
createPixelMap
(
color
,
opts
,
(
err
,
pixelmap
:
image
.
PixelMap
)
=>
{
let
rowCount
=
pixelmap
.
getBytesNumberPerRow
();
let
rowCount
:
number
=
pixelmap
.
getBytesNumberPerRow
();
})
})
```
```
...
@@ -483,7 +483,7 @@ getPixelBytesNumber(): number
...
@@ -483,7 +483,7 @@ getPixelBytesNumber(): number
**示例:**
**示例:**
```
js
```
js
let
pixelBytesNumber
=
pixelmap
.
getPixelBytesNumber
();
let
pixelBytesNumber
:
number
=
pixelmap
.
getPixelBytesNumber
();
```
```
### getDensity<sup>9+</sup>
### getDensity<sup>9+</sup>
...
@@ -503,7 +503,7 @@ getDensity():number
...
@@ -503,7 +503,7 @@ getDensity():number
**示例:**
**示例:**
```
js
```
js
let
getDensity
=
pixelmap
.
getDensity
();
let
getDensity
:
number
=
pixelmap
.
getDensity
();
```
```
### opacity<sup>9+</sup>
### opacity<sup>9+</sup>
...
@@ -602,7 +602,7 @@ createAlphaPixelmap(callback: AsyncCallback\<PixelMap>): void
...
@@ -602,7 +602,7 @@ createAlphaPixelmap(callback: AsyncCallback\<PixelMap>): void
**示例:**
**示例:**
```
js
```
js
pixelmap
.
createAlphaPixelmap
((
err
,
alphaPixelMap
)
=>
{
pixelmap
.
createAlphaPixelmap
((
err
,
alphaPixelMap
:
image
.
PixelMap
)
=>
{
if
(
alphaPixelMap
==
undefined
)
{
if
(
alphaPixelMap
==
undefined
)
{
console
.
info
(
'
Failed to obtain new pixel map.
'
);
console
.
info
(
'
Failed to obtain new pixel map.
'
);
}
else
{
}
else
{
...
@@ -983,16 +983,16 @@ class MySequence {
...
@@ -983,16 +983,16 @@ class MySequence {
return
true
;
return
true
;
}
}
async
unmarshalling
(
messageSequence
)
{
async
unmarshalling
(
messageSequence
)
{
let
pixelParcel
=
await
image
.
createPixelMap
(
new
ArrayBuffer
(
96
),
{
size
:
{
height
:
4
,
width
:
6
}});
let
pixelParcel
:
image
.
PixelMap
=
await
image
.
createPixelMap
(
new
ArrayBuffer
(
96
),
{
size
:
{
height
:
4
,
width
:
6
}});
await
pixelParcel
.
unmarshalling
(
messageSequence
).
then
(
async
(
pixelMap
)
=>
{
await
pixelParcel
.
unmarshalling
(
messageSequence
).
then
(
async
(
pixelMap
:
image
.
PixelMap
)
=>
{
this
.
pixel_map
=
pixelMap
;
this
.
pixel_map
=
pixelMap
;
})
})
return
true
;
return
true
;
}
}
}
}
async
function
Demo
()
{
async
function
Demo
()
{
let
parcelable
=
new
MySequence
(
pixelmap
);
let
parcelable
:
MySequence
=
new
MySequence
(
pixelmap
);
let
data
=
rpc
.
MessageSequence
.
create
();
let
data
:
rpc
.
MessageSequence
=
rpc
.
MessageSequence
.
create
();
data
.
writeParcelable
(
parcelable
);
data
.
writeParcelable
(
parcelable
);
}
}
```
```
...
@@ -1042,8 +1042,8 @@ class MySequence {
...
@@ -1042,8 +1042,8 @@ class MySequence {
return
true
;
return
true
;
}
}
async
unmarshalling
(
messageSequence
)
{
async
unmarshalling
(
messageSequence
)
{
let
pixelParcel
=
await
image
.
createPixelMap
(
new
ArrayBuffer
(
96
),
{
size
:
{
height
:
4
,
width
:
6
}});
let
pixelParcel
:
image
.
PixelMap
=
await
image
.
createPixelMap
(
new
ArrayBuffer
(
96
),
{
size
:
{
height
:
4
,
width
:
6
}});
await
pixelParcel
.
unmarshalling
(
messageSequence
).
then
(
async
(
pixelMap
)
=>
{
await
pixelParcel
.
unmarshalling
(
messageSequence
).
then
(
async
(
pixelMap
:
image
.
PixelMap
)
=>
{
this
.
pixel_map
=
pixelMap
;
this
.
pixel_map
=
pixelMap
;
})
})
return
true
;
return
true
;
...
@@ -1051,8 +1051,8 @@ class MySequence {
...
@@ -1051,8 +1051,8 @@ class MySequence {
}
}
async
function
Demo
()
{
async
function
Demo
()
{
let
pixel_map
=
undefined
;
let
pixel_map
=
undefined
;
let
ret
=
new
MySequence
(
pixel_map
);
let
ret
:
MySequence
=
new
MySequence
(
pixel_map
);
let
data
=
rpc
.
MessageSequence
.
create
();
let
data
:
rpc
.
MessageSequence
=
rpc
.
MessageSequence
.
create
();
await
data
.
readParcelable
(
ret
);
await
data
.
readParcelable
(
ret
);
}
}
```
```
...
@@ -1127,18 +1127,18 @@ createImageSource(uri: string): ImageSource
...
@@ -1127,18 +1127,18 @@ createImageSource(uri: string): ImageSource
```
js
```
js
//Stage模型
//Stage模型
const
context
=
getContext
(
this
);
const
context
:
Context
=
getContext
(
this
);
const
path
=
context
.
cacheDir
+
"
/test.jpg
"
;
const
path
:
string
=
context
.
cacheDir
+
"
/test.jpg
"
;
const
imageSourceApi
=
image
.
createImageSource
(
path
);
const
imageSourceApi
:
image
.
ImageSource
=
image
.
createImageSource
(
path
);
```
```
```
js
```
js
//FA模型
//FA模型
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
const
context
=
featureAbility
.
getContext
();
const
context
:
Context
=
featureAbility
.
getContext
();
const
path
=
context
.
getCacheDir
()
+
"
/test.jpg
"
;
const
path
:
string
=
context
.
getCacheDir
()
+
"
/test.jpg
"
;
const
imageSourceApi
=
image
.
createImageSource
(
path
);
const
imageSourceApi
:
image
.
ImageSource
=
image
.
createImageSource
(
path
);
```
```
## image.createImageSource<sup>9+</sup>
## image.createImageSource<sup>9+</sup>
...
@@ -1165,8 +1165,8 @@ createImageSource(uri: string, options: SourceOptions): ImageSource
...
@@ -1165,8 +1165,8 @@ createImageSource(uri: string, options: SourceOptions): ImageSource
**示例:**
**示例:**
```
js
```
js
var
sourceOptions
=
{
sourceDensity
:
120
};
var
sourceOptions
:
image
.
SourceOptions
=
{
sourceDensity
:
120
};
let
imageSource
=
image
.
createImageSource
(
'
test.png
'
,
sourceOptions
);
let
imageSource
:
image
.
ImageSource
=
image
.
createImageSource
(
'
test.png
'
,
sourceOptions
);
```
```
## image.createImageSource<sup>7+</sup>
## image.createImageSource<sup>7+</sup>
...
@@ -1192,7 +1192,7 @@ createImageSource(fd: number): ImageSource
...
@@ -1192,7 +1192,7 @@ createImageSource(fd: number): ImageSource
**示例:**
**示例:**
```
js
```
js
const
imageSourceApi
=
image
.
createImageSource
(
0
);
const
imageSourceApi
:
image
.
ImageSource
=
image
.
createImageSource
(
0
);
```
```
## image.createImageSource<sup>9+</sup>
## image.createImageSource<sup>9+</sup>
...
@@ -1219,8 +1219,8 @@ createImageSource(fd: number, options: SourceOptions): ImageSource
...
@@ -1219,8 +1219,8 @@ createImageSource(fd: number, options: SourceOptions): ImageSource
**示例:**
**示例:**
```
js
```
js
var
sourceOptions
=
{
sourceDensity
:
120
};
var
sourceOptions
:
image
.
SourceOptions
=
{
sourceDensity
:
120
};
const
imageSourceApi
=
image
.
createImageSource
(
0
,
sourceOptions
);
const
imageSourceApi
:
image
.
ImageSource
=
image
.
createImageSource
(
0
,
sourceOptions
);
```
```
## image.createImageSource<sup>9+</sup>
## image.createImageSource<sup>9+</sup>
...
@@ -1240,8 +1240,8 @@ createImageSource(buf: ArrayBuffer): ImageSource
...
@@ -1240,8 +1240,8 @@ createImageSource(buf: ArrayBuffer): ImageSource
**示例:**
**示例:**
```
js
```
js
const
buf
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
buf
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
imageSourceApi
=
image
.
createImageSource
(
buf
);
const
imageSourceApi
:
image
.
ImageSource
=
image
.
createImageSource
(
buf
);
```
```
## image.createImageSource<sup>9+</sup>
## image.createImageSource<sup>9+</sup>
...
@@ -1268,8 +1268,8 @@ createImageSource(buf: ArrayBuffer, options: SourceOptions): ImageSource
...
@@ -1268,8 +1268,8 @@ createImageSource(buf: ArrayBuffer, options: SourceOptions): ImageSource
**示例:**
**示例:**
```
js
```
js
const
data
=
new
ArrayBuffer
(
112
);
const
data
:
ArrayBuffer
=
new
ArrayBuffer
(
112
);
const
imageSourceApi
=
image
.
createImageSource
(
data
);
const
imageSourceApi
:
image
.
ImageSource
=
image
.
createImageSource
(
data
);
```
```
## image.CreateIncrementalSource<sup>9+</sup>
## image.CreateIncrementalSource<sup>9+</sup>
...
@@ -1295,8 +1295,8 @@ CreateIncrementalSource(buf: ArrayBuffer): ImageSource
...
@@ -1295,8 +1295,8 @@ CreateIncrementalSource(buf: ArrayBuffer): ImageSource
**示例:**
**示例:**
```
js
```
js
const
buf
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
buf
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
imageSourceIncrementalSApi
=
image
.
CreateIncrementalSource
(
buf
);
const
imageSourceIncrementalSApi
:
image
.
ImageSource
=
image
.
CreateIncrementalSource
(
buf
);
```
```
## image.CreateIncrementalSource<sup>9+</sup>
## image.CreateIncrementalSource<sup>9+</sup>
...
@@ -1323,8 +1323,8 @@ CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource
...
@@ -1323,8 +1323,8 @@ CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource
**示例:**
**示例:**
```
js
```
js
const
buf
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
buf
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
imageSourceIncrementalSApi
=
image
.
CreateIncrementalSource
(
buf
);
const
imageSourceIncrementalSApi
:
image
.
ImageSource
=
image
.
CreateIncrementalSource
(
buf
);
```
```
## ImageSource
## ImageSource
...
@@ -1357,7 +1357,7 @@ getImageInfo(index: number, callback: AsyncCallback\<ImageInfo>): void
...
@@ -1357,7 +1357,7 @@ getImageInfo(index: number, callback: AsyncCallback\<ImageInfo>): void
**示例:**
**示例:**
```
js
```
js
imageSourceApi
.
getImageInfo
(
0
,(
error
,
imageInfo
)
=>
{
imageSourceApi
.
getImageInfo
(
0
,(
error
,
imageInfo
:
image
.
ImageInfo
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
'
getImageInfo failed.
'
);
console
.
log
(
'
getImageInfo failed.
'
);
}
else
{
}
else
{
...
@@ -1383,7 +1383,7 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void
...
@@ -1383,7 +1383,7 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void
**示例:**
**示例:**
```
js
```
js
imageSourceApi
.
getImageInfo
(
imageInfo
=>
{
imageSourceApi
.
getImageInfo
(
(
imageInfo
:
image
.
ImageInfo
)
=>
{
console
.
log
(
'
Succeeded in obtaining the image information.
'
);
console
.
log
(
'
Succeeded in obtaining the image information.
'
);
})
})
```
```
...
@@ -1412,7 +1412,7 @@ getImageInfo(index?: number): Promise\<ImageInfo>
...
@@ -1412,7 +1412,7 @@ getImageInfo(index?: number): Promise\<ImageInfo>
```
js
```
js
imageSourceApi
.
getImageInfo
(
0
)
imageSourceApi
.
getImageInfo
(
0
)
.
then
(
imageInfo
=>
{
.
then
(
(
imageInfo
:
image
.
ImageInfo
)
=>
{
console
.
log
(
'
Succeeded in obtaining the image information.
'
);
console
.
log
(
'
Succeeded in obtaining the image information.
'
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
log
(
'
Failed to obtain the image information.
'
);
console
.
log
(
'
Failed to obtain the image information.
'
);
...
@@ -1467,7 +1467,7 @@ getImageProperty(key:string, callback: AsyncCallback\<string>): void
...
@@ -1467,7 +1467,7 @@ getImageProperty(key:string, callback: AsyncCallback\<string>): void
**示例:**
**示例:**
```
js
```
js
imageSourceApi
.
getImageProperty
(
"
BitsPerSample
"
,(
error
,
data
)
=>
{
imageSourceApi
.
getImageProperty
(
"
BitsPerSample
"
,(
error
,
data
:
string
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
'
Failed to get the value of the specified attribute key of the image.
'
);
console
.
log
(
'
Failed to get the value of the specified attribute key of the image.
'
);
}
else
{
}
else
{
...
@@ -1495,7 +1495,7 @@ getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCa
...
@@ -1495,7 +1495,7 @@ getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCa
**示例:**
**示例:**
```
js
```
js
let
property
=
{
index
:
0
,
defaultValue
:
'
9999
'
}
let
property
:
image
.
GetImagePropertyOptions
=
{
index
:
0
,
defaultValue
:
'
9999
'
}
imageSourceApi
.
getImageProperty
(
"
BitsPerSample
"
,
property
,(
error
,
data
)
=>
{
imageSourceApi
.
getImageProperty
(
"
BitsPerSample
"
,
property
,(
error
,
data
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
'
Failed to get the value of the specified attribute key of the image.
'
);
console
.
log
(
'
Failed to get the value of the specified attribute key of the image.
'
);
...
@@ -1583,7 +1583,7 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number)
...
@@ -1583,7 +1583,7 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number)
**示例:**
**示例:**
```
js
```
js
const
array
=
new
ArrayBuffer
(
100
);
const
array
:
ArrayBuffer
=
new
ArrayBuffer
(
100
);
imageSourceApi
.
updateData
(
array
,
false
,
0
,
10
).
then
(
data
=>
{
imageSourceApi
.
updateData
(
array
,
false
,
0
,
10
).
then
(
data
=>
{
console
.
info
(
'
Succeeded in updating data.
'
);
console
.
info
(
'
Succeeded in updating data.
'
);
})
})
...
@@ -1611,7 +1611,7 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number,
...
@@ -1611,7 +1611,7 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number,
**示例:**
**示例:**
```
js
```
js
const
array
=
new
ArrayBuffer
(
100
);
const
array
:
ArrayBuffer
=
new
ArrayBuffer
(
100
);
imageSourceApi
.
updateData
(
array
,
false
,
0
,
10
,(
error
,
data
)
=>
{
imageSourceApi
.
updateData
(
array
,
false
,
0
,
10
,(
error
,
data
)
=>
{
if
(
data
!==
undefined
){
if
(
data
!==
undefined
){
console
.
info
(
'
Succeeded in updating data.
'
);
console
.
info
(
'
Succeeded in updating data.
'
);
...
@@ -1642,7 +1642,7 @@ createPixelMap(options?: DecodingOptions): Promise\<PixelMap>
...
@@ -1642,7 +1642,7 @@ createPixelMap(options?: DecodingOptions): Promise\<PixelMap>
**示例:**
**示例:**
```
js
```
js
imageSourceApi
.
createPixelMap
().
then
(
pixelmap
=>
{
imageSourceApi
.
createPixelMap
().
then
(
(
pixelmap
:
image
.
PixelMap
)
=>
{
console
.
log
(
'
Succeeded in creating pixelmap object through image decoding parameters.
'
);
console
.
log
(
'
Succeeded in creating pixelmap object through image decoding parameters.
'
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
log
(
'
Failed to create pixelmap object through image decoding parameters.
'
);
console
.
log
(
'
Failed to create pixelmap object through image decoding parameters.
'
);
...
@@ -1666,7 +1666,7 @@ createPixelMap(callback: AsyncCallback\<PixelMap>): void
...
@@ -1666,7 +1666,7 @@ createPixelMap(callback: AsyncCallback\<PixelMap>): void
**示例:**
**示例:**
```
js
```
js
imageSourceApi
.
createPixelMap
((
err
,
pixelmap
)
=>
{
imageSourceApi
.
createPixelMap
((
err
,
pixelmap
:
image
.
PixelMap
)
=>
{
console
.
info
(
'
Succeeded in creating pixelmap object.
'
);
console
.
info
(
'
Succeeded in creating pixelmap object.
'
);
})
})
```
```
...
@@ -1689,7 +1689,7 @@ createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): vo
...
@@ -1689,7 +1689,7 @@ createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): vo
**示例:**
**示例:**
```
js
```
js
let
decodingOptions
=
{
let
decodingOptions
:
image
.
DecodingOptions
=
{
sampleSize
:
1
,
sampleSize
:
1
,
editable
:
true
,
editable
:
true
,
desiredSize
:
{
width
:
1
,
height
:
2
},
desiredSize
:
{
width
:
1
,
height
:
2
},
...
@@ -1698,7 +1698,7 @@ let decodingOptions = {
...
@@ -1698,7 +1698,7 @@ let decodingOptions = {
desiredRegion
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
},
desiredRegion
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
},
index
:
0
index
:
0
};
};
imageSourceApi
.
createPixelMap
(
decodingOptions
,
pixelmap
=>
{
imageSourceApi
.
createPixelMap
(
decodingOptions
,
pixelmap
:
image
.
PixelMap
=>
{
console
.
log
(
'
Succeeded in creating pixelmap object.
'
);
console
.
log
(
'
Succeeded in creating pixelmap object.
'
);
})
})
```
```
...
@@ -1738,7 +1738,7 @@ createPixelMapList(options?: DecodingOptions): Promise<Array\<PixelMap>>;
...
@@ -1738,7 +1738,7 @@ createPixelMapList(options?: DecodingOptions): Promise<Array\<PixelMap>>;
**示例:**
**示例:**
```
js
```
js
let
decodeOpts
=
{
let
decodeOpts
:
image
.
DecodingOptions
=
{
sampleSize
:
1
,
sampleSize
:
1
,
editable
:
true
,
editable
:
true
,
desiredSize
:
{
width
:
198
,
height
:
202
},
desiredSize
:
{
width
:
198
,
height
:
202
},
...
@@ -1813,7 +1813,7 @@ createPixelMapList(options: DecodingOptions, callback: AsyncCallback<Array\<Pixe
...
@@ -1813,7 +1813,7 @@ createPixelMapList(options: DecodingOptions, callback: AsyncCallback<Array\<Pixe
**示例:**
**示例:**
```
js
```
js
let
decodeOpts
=
{
let
decodeOpts
:
image
.
DecodingOptions
=
{
sampleSize
:
1
,
sampleSize
:
1
,
editable
:
true
,
editable
:
true
,
desiredSize
:
{
width
:
198
,
height
:
202
},
desiredSize
:
{
width
:
198
,
height
:
202
},
...
@@ -2029,7 +2029,7 @@ createImagePacker(): ImagePacker
...
@@ -2029,7 +2029,7 @@ createImagePacker(): ImagePacker
**示例:**
**示例:**
```
js
```
js
const
imagePackerApi
=
image
.
createImagePacker
();
const
imagePackerApi
:
image
.
ImagePacker
=
image
.
createImagePacker
();
```
```
## ImagePacker
## ImagePacker
...
@@ -2063,9 +2063,9 @@ packing(source: ImageSource, option: PackingOption, callback: AsyncCallback\<Arr
...
@@ -2063,9 +2063,9 @@ packing(source: ImageSource, option: PackingOption, callback: AsyncCallback\<Arr
**示例:**
**示例:**
```
js
```
js
const
imageSourceApi
=
image
.
createImageSource
(
0
);
const
imageSourceApi
:
image
.
ImageSource
=
image
.
createImageSource
(
0
);
let
packOpts
=
{
format
:
"
image/jpeg
"
,
quality
:
98
};
let
packOpts
:
image
.
PackingOption
=
{
format
:
"
image/jpeg
"
,
quality
:
98
};
imagePackerApi
.
packing
(
imageSourceApi
,
packOpts
,
data
=>
{})
imagePackerApi
.
packing
(
imageSourceApi
,
packOpts
,
data
:
ArrayBuffer
=>
{})
```
```
### packing
### packing
...
@@ -2092,10 +2092,10 @@ packing(source: ImageSource, option: PackingOption): Promise\<ArrayBuffer>
...
@@ -2092,10 +2092,10 @@ packing(source: ImageSource, option: PackingOption): Promise\<ArrayBuffer>
**示例:**
**示例:**
```
js
```
js
const
imageSourceApi
=
image
.
createImageSource
(
0
);
const
imageSourceApi
:
image
.
ImageSource
=
image
.
createImageSource
(
0
);
let
packOpts
=
{
format
:
"
image/jpeg
"
,
quality
:
98
}
let
packOpts
:
image
.
PackingOption
=
{
format
:
"
image/jpeg
"
,
quality
:
98
}
imagePackerApi
.
packing
(
imageSourceApi
,
packOpts
)
imagePackerApi
.
packing
(
imageSourceApi
,
packOpts
)
.
then
(
data
=>
{
.
then
(
data
:
ArrayBuffer
=>
{
console
.
log
(
'
packing succeeded.
'
);
console
.
log
(
'
packing succeeded.
'
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
log
(
'
packing failed.
'
);
console
.
log
(
'
packing failed.
'
);
...
@@ -2121,12 +2121,12 @@ packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\<ArrayB
...
@@ -2121,12 +2121,12 @@ packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\<ArrayB
**示例:**
**示例:**
```
js
```
js
const
color
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
color
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
let
bufferArr
=
new
Uint8Array
(
color
);
let
bufferArr
:
Uint8Array
=
new
Uint8Array
(
color
);
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
let
opts
:
image
.
InitializationOptions
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
image
.
createPixelMap
(
color
,
opts
).
then
((
pixelmap
)
=>
{
image
.
createPixelMap
(
color
,
opts
).
then
((
pixelmap
:
image
.
image
.
PixelMap
)
=>
{
let
packOpts
=
{
format
:
"
image/jpeg
"
,
quality
:
98
}
let
packOpts
:
image
.
PackingOption
=
{
format
:
"
image/jpeg
"
,
quality
:
98
}
imagePackerApi
.
packing
(
pixelmap
,
packOpts
,
data
=>
{
imagePackerApi
.
packing
(
pixelmap
,
packOpts
,
data
:
ArrayBuffer
=>
{
console
.
log
(
'
Succeeded in packing the image.
'
);
console
.
log
(
'
Succeeded in packing the image.
'
);
})
})
})
})
...
@@ -2156,13 +2156,13 @@ packing(source: PixelMap, option: PackingOption): Promise\<ArrayBuffer>
...
@@ -2156,13 +2156,13 @@ packing(source: PixelMap, option: PackingOption): Promise\<ArrayBuffer>
**示例:**
**示例:**
```
js
```
js
const
color
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
const
color
:
ArrayBuffer
=
new
ArrayBuffer
(
96
);
//96为需要创建的像素buffer大小,取值为:height * width *4
let
bufferArr
=
new
Uint8Array
(
color
);
let
bufferArr
:
Uint8Array
=
new
Uint8Array
(
color
);
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
let
opts
:
image
.
InitializationOptions
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
image
.
createPixelMap
(
color
,
opts
).
then
((
pixelmap
)
=>
{
image
.
createPixelMap
(
color
,
opts
).
then
((
pixelmap
:
image
.
PixelMap
)
=>
{
let
packOpts
=
{
format
:
"
image/jpeg
"
,
quality
:
98
}
let
packOpts
:
image
.
PackingOption
=
{
format
:
"
image/jpeg
"
,
quality
:
98
}
imagePackerApi
.
packing
(
pixelmap
,
packOpts
)
imagePackerApi
.
packing
(
pixelmap
,
packOpts
)
.
then
(
data
=>
{
.
then
(
data
:
ArrayBuffer
=>
{
console
.
log
(
'
Succeeded in packing the image.
'
);
console
.
log
(
'
Succeeded in packing the image.
'
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
log
(
'
Failed to pack the image..
'
);
console
.
log
(
'
Failed to pack the image..
'
);
...
@@ -2242,7 +2242,7 @@ createImageReceiver(width: number, height: number, format: number, capacity: num
...
@@ -2242,7 +2242,7 @@ createImageReceiver(width: number, height: number, format: number, capacity: num
**示例:**
**示例:**
```
js
```
js
var
receiver
=
image
.
createImageReceiver
(
8192
,
8
,
2000
,
8
);
var
receiver
image
.
ImageReceiver
=
image
.
createImageReceiver
(
8192
,
8
,
2000
,
8
);
```
```
## ImageReceiver<sup>9+</sup>
## ImageReceiver<sup>9+</sup>
...
@@ -2278,7 +2278,7 @@ getReceivingSurfaceId(callback: AsyncCallback\<string>): void
...
@@ -2278,7 +2278,7 @@ getReceivingSurfaceId(callback: AsyncCallback\<string>): void
**示例:**
**示例:**
```
js
```
js
receiver
.
getReceivingSurfaceId
((
err
,
id
)
=>
{
receiver
.
getReceivingSurfaceId
((
err
,
id
:
string
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
getReceivingSurfaceId failed.
'
);
console
.
log
(
'
getReceivingSurfaceId failed.
'
);
}
else
{
}
else
{
...
@@ -2304,7 +2304,7 @@ getReceivingSurfaceId(): Promise\<string>
...
@@ -2304,7 +2304,7 @@ getReceivingSurfaceId(): Promise\<string>
**示例:**
**示例:**
```
js
```
js
receiver
.
getReceivingSurfaceId
().
then
(
id
=>
{
receiver
.
getReceivingSurfaceId
().
then
(
(
id
:
string
)
=>
{
console
.
log
(
'
getReceivingSurfaceId succeeded.
'
);
console
.
log
(
'
getReceivingSurfaceId succeeded.
'
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
log
(
'
getReceivingSurfaceId failed.
'
);
console
.
log
(
'
getReceivingSurfaceId failed.
'
);
...
@@ -2328,7 +2328,7 @@ readLatestImage(callback: AsyncCallback\<Image>): void
...
@@ -2328,7 +2328,7 @@ readLatestImage(callback: AsyncCallback\<Image>): void
**示例:**
**示例:**
```
js
```
js
receiver
.
readLatestImage
((
err
,
img
)
=>
{
receiver
.
readLatestImage
((
err
,
img
:
image
.
Image
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
readLatestImage failed.
'
);
console
.
log
(
'
readLatestImage failed.
'
);
}
else
{
}
else
{
...
@@ -2354,7 +2354,7 @@ readLatestImage(): Promise\<Image>
...
@@ -2354,7 +2354,7 @@ readLatestImage(): Promise\<Image>
**示例:**
**示例:**
```
js
```
js
receiver
.
readLatestImage
().
then
(
img
=>
{
receiver
.
readLatestImage
().
then
(
(
img
:
image
.
Image
)
=>
{
console
.
log
(
'
readLatestImage succeeded.
'
);
console
.
log
(
'
readLatestImage succeeded.
'
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
log
(
'
readLatestImage failed.
'
);
console
.
log
(
'
readLatestImage failed.
'
);
...
@@ -2378,7 +2378,7 @@ readNextImage(callback: AsyncCallback\<Image>): void
...
@@ -2378,7 +2378,7 @@ readNextImage(callback: AsyncCallback\<Image>): void
**示例:**
**示例:**
```
js
```
js
receiver
.
readNextImage
((
err
,
img
)
=>
{
receiver
.
readNextImage
((
err
,
img
:
image
.
Image
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
readNextImage failed.
'
);
console
.
log
(
'
readNextImage failed.
'
);
}
else
{
}
else
{
...
@@ -2404,7 +2404,7 @@ readNextImage(): Promise\<Image>
...
@@ -2404,7 +2404,7 @@ readNextImage(): Promise\<Image>
**示例:**
**示例:**
```
js
```
js
receiver
.
readNextImage
().
then
(
img
=>
{
receiver
.
readNextImage
().
then
(
(
img
:
image
.
Image
)
=>
{
console
.
log
(
'
readNextImage succeeded.
'
);
console
.
log
(
'
readNextImage succeeded.
'
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
log
(
'
readNextImage failed.
'
);
console
.
log
(
'
readNextImage failed.
'
);
...
@@ -2502,7 +2502,7 @@ createImageCreator(width: number, height: number, format: number, capacity: numb
...
@@ -2502,7 +2502,7 @@ createImageCreator(width: number, height: number, format: number, capacity: numb
**示例:**
**示例:**
```
js
```
js
var
creator
=
image
.
createImageCreator
(
8192
,
8
,
4
,
8
);
var
creator
:
image
.
ImageCreator
=
image
.
createImageCreator
(
8192
,
8
,
4
,
8
);
```
```
## ImageCreator<sup>9+</sup>
## ImageCreator<sup>9+</sup>
...
@@ -2536,7 +2536,7 @@ dequeueImage(callback: AsyncCallback\<Image>): void
...
@@ -2536,7 +2536,7 @@ dequeueImage(callback: AsyncCallback\<Image>): void
**示例:**
**示例:**
```
js
```
js
creator
.
dequeueImage
((
err
,
img
)
=>
{
creator
.
dequeueImage
((
err
,
img
:
image
.
Image
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
info
(
'
dequeueImage failed.
'
);
console
.
info
(
'
dequeueImage failed.
'
);
}
}
...
@@ -2561,7 +2561,7 @@ dequeueImage(): Promise\<Image>
...
@@ -2561,7 +2561,7 @@ dequeueImage(): Promise\<Image>
**示例:**
**示例:**
```
js
```
js
creator
.
dequeueImage
().
then
(
img
=>
{
creator
.
dequeueImage
().
then
(
(
img
:
image
.
Image
)
=>
{
console
.
info
(
'
dequeueImage succeeded.
'
);
console
.
info
(
'
dequeueImage succeeded.
'
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
log
(
'
dequeueImage failed:
'
+
error
);
console
.
log
(
'
dequeueImage failed:
'
+
error
);
...
@@ -2586,10 +2586,10 @@ queueImage(interface: Image, callback: AsyncCallback\<void>): void
...
@@ -2586,10 +2586,10 @@ queueImage(interface: Image, callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
js
```
js
creator
.
dequeueImage
().
then
(
img
=>
{
creator
.
dequeueImage
().
then
(
(
img
:
image
.
Image
)
=>
{
//绘制图片
//绘制图片
img
.
getComponent
(
4
).
then
(
component
=>
{
img
.
getComponent
(
4
).
then
(
component
:
image
.
Component
=>
{
var
bufferArr
=
new
Uint8Array
(
component
.
byteBuffer
);
var
bufferArr
:
Uint8Array
=
new
Uint8Array
(
component
.
byteBuffer
);
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
+=
4
)
{
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
+=
4
)
{
bufferArr
[
i
]
=
0
;
//B
bufferArr
[
i
]
=
0
;
//B
bufferArr
[
i
+
1
]
=
0
;
//G
bufferArr
[
i
+
1
]
=
0
;
//G
...
@@ -2630,10 +2630,10 @@ queueImage(interface: Image): Promise\<void>
...
@@ -2630,10 +2630,10 @@ queueImage(interface: Image): Promise\<void>
**示例:**
**示例:**
```
js
```
js
creator
.
dequeueImage
().
then
(
img
=>
{
creator
.
dequeueImage
().
then
(
(
img
:
image
.
Image
)
=>
{
//绘制图片
//绘制图片
img
.
getComponent
(
4
).
then
(
component
=>
{
img
.
getComponent
(
4
).
then
(
component
:
image
.
Component
=>
{
var
bufferArr
=
new
Uint8Array
(
component
.
byteBuffer
);
var
bufferArr
:
Uint8Array
=
new
Uint8Array
(
component
.
byteBuffer
);
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
+=
4
)
{
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
+=
4
)
{
bufferArr
[
i
]
=
0
;
//B
bufferArr
[
i
]
=
0
;
//B
bufferArr
[
i
+
1
]
=
0
;
//G
bufferArr
[
i
+
1
]
=
0
;
//G
...
@@ -2756,7 +2756,7 @@ getComponent(componentType: ComponentType, callback: AsyncCallback\<Component>):
...
@@ -2756,7 +2756,7 @@ getComponent(componentType: ComponentType, callback: AsyncCallback\<Component>):
**示例:**
**示例:**
```
js
```
js
img
.
getComponent
(
4
,
(
err
,
component
)
=>
{
img
.
getComponent
(
4
,
(
err
,
component
:
image
.
Component
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
getComponent failed.
'
);
console
.
log
(
'
getComponent failed.
'
);
}
else
{
}
else
{
...
@@ -2788,7 +2788,7 @@ getComponent(componentType: ComponentType): Promise\<Component>
...
@@ -2788,7 +2788,7 @@ getComponent(componentType: ComponentType): Promise\<Component>
**示例:**
**示例:**
```
js
```
js
img
.
getComponent
(
4
).
then
(
component
=>
{
})
img
.
getComponent
(
4
).
then
(
(
component
:
image
.
Component
)
=>
{
})
```
```
### release<sup>9+</sup>
### release<sup>9+</sup>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录