Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
0ac178f4
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
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,发现更多精彩内容 >>
提交
0ac178f4
编写于
7月 04, 2022
作者:
X
xu-rui-w
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
示例参数说明
Signed-off-by:
N
xu-rui-w
<
xurui101@huawei.com
>
上级
913e3672
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
61 deletion
+62
-61
zh-cn/application-dev/reference/apis/js-apis-image.md
zh-cn/application-dev/reference/apis/js-apis-image.md
+62
-61
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-image.md
浏览文件 @
0ac178f4
...
...
@@ -101,10 +101,11 @@ readPixelsToBuffer(dst: ArrayBuffer): Promise\<void>
**示例:**
```
js
pixelmap
.
readPixelsToBuffer
(
ReadBuffer
).
then
(()
=>
{
console
.
log
(
'
readPixelsToBuffer succeeded.
'
);
//符合条件则进入
const
readBuffer
=
new
ArrayBuffer
(
400
);
pixelmap
.
readPixelsToBuffer
(
readBuffer
).
then
(()
=>
{
console
.
log
(
'
Succeeded in reading image pixel data.
'
);
//符合条件则进入
}).
catch
(
error
=>
{
console
.
log
(
'
readPixelsToBuffer failed
.
'
);
//不符合条件则进入
console
.
log
(
'
Failed to read image pixel data
.
'
);
//不符合条件则进入
})
```
...
...
@@ -126,11 +127,12 @@ readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void
**示例:**
```
js
pixelmap
.
readPixelsToBuffer
(
ReadBuffer
,
(
err
,
res
)
=>
{
const
readBuffer
=
new
ArrayBuffer
(
400
);
pixelmap
.
readPixelsToBuffer
(
readBuffer
,
(
err
,
res
)
=>
{
if
(
err
)
{
console
.
log
(
'
readPixelsToBuffer failed
.
'
);
//不符合条件则进入
console
.
log
(
'
Failed to read image pixel data
.
'
);
//不符合条件则进入
}
else
{
console
.
log
(
'
readPixelsToBuffer succeeded
.
'
);
//符合条件则进入
console
.
log
(
'
Succeeded in reading image pixel data
.
'
);
//符合条件则进入
}
})
```
...
...
@@ -158,10 +160,11 @@ readPixels(area: PositionArea): Promise\<void>
**示例:**
```
js
pixelmap
.
readPixels
(
Area
).
then
((
data
)
=>
{
console
.
log
(
'
readPixels succeeded.
'
);
//符合条件则进入
const
area
=
new
ArrayBuffer
(
400
);
pixelmap
.
readPixels
(
area
).
then
(()
=>
{
console
.
log
(
'
Succeeded in reading the image data in the area.
'
);
//符合条件则进入
}).
catch
(
error
=>
{
console
.
log
(
'
readPixels failed
.
'
);
//不符合条件则进入
console
.
log
(
'
Failed to read the image data in the area
.
'
);
//不符合条件则进入
})
```
...
...
@@ -273,9 +276,10 @@ writePixels(area: PositionArea, callback: AsyncCallback\<void>): void
**示例:**
```
js
pixelmap
.
writePixels
(
Area
,
(
error
)
=>
{
const
area
=
new
ArrayBuffer
(
400
);
pixelmap
.
writePixels
(
area
,
(
error
)
=>
{
if
(
error
!=
undefined
)
{
console
.
info
(
'
writePixels failed
.
'
);
console
.
info
(
'
Failed to write pixelmap into the specified area
.
'
);
}
else
{
const
readArea
=
{
pixels
:
new
ArrayBuffer
(
20
),
...
...
@@ -311,8 +315,9 @@ writeBufferToPixels(src: ArrayBuffer): Promise\<void>
```
js
const
color
=
new
ArrayBuffer
(
96
);
const
pixelMap
=
new
ArrayBuffer
(
400
);
let
bufferArr
=
new
Unit8Array
(
color
);
P
ixelMap
.
writeBufferToPixels
(
color
).
then
(()
=>
{
p
ixelMap
.
writeBufferToPixels
(
color
).
then
(()
=>
{
console
.
log
(
"
Succeeded in writing data from a buffer to a PixelMap.
"
);
}).
catch
((
err
)
=>
{
console
.
error
(
"
Failed to write data from a buffer to a PixelMap.
"
);
...
...
@@ -337,9 +342,10 @@ writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\<void>): void
**示例:**
```
js
const
color
=
new
ArrayBuffer
(
96
);
const
color
=
new
ArrayBuffer
(
96
);
\
const
pixelMap
=
new
ArrayBuffer
(
400
);
let
bufferArr
=
new
Unit8Array
(
color
);
P
ixelMap
.
writeBufferToPixels
(
color
,
function
(
err
)
{
p
ixelMap
.
writeBufferToPixels
(
color
,
function
(
err
)
{
if
(
err
)
{
console
.
error
(
"
Failed to write data from a buffer to a PixelMap.
"
);
return
;
...
...
@@ -366,7 +372,8 @@ getImageInfo(): Promise\<ImageInfo>
**示例:**
```
js
PixelMap
.
getImageInfo
().
then
(
function
(
info
)
{
const
pixelMap
=
new
ArrayBuffer
(
400
);
pixelMap
.
getImageInfo
().
then
(
function
(
info
)
{
console
.
log
(
"
Succeeded in obtaining the image pixel map information.
"
);
}).
catch
((
err
)
=>
{
console
.
error
(
"
Failed to obtain the image pixel map information.
"
);
...
...
@@ -391,9 +398,7 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void
```
js
pixelmap
.
getImageInfo
((
imageInfo
)
=>
{
console
.
log
(
"
getImageInfo succeeded.
"
);
}).
catch
((
err
)
=>
{
console
.
error
(
"
getImageInfo failed.
"
);
console
.
log
(
"
Succeeded in obtaining the image pixel map information..
"
);
})
```
...
...
@@ -417,7 +422,7 @@ getBytesNumberPerRow(): number
const
color
=
new
ArrayBuffer
(
96
);
let
bufferArr
=
new
Unit8Array
(
color
);
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
image
.
createPixelMap
(
c
lol
r
,
opts
,
(
err
,
pixelmap
)
=>
{
image
.
createPixelMap
(
c
olo
r
,
opts
,
(
err
,
pixelmap
)
=>
{
let
rowCount
=
pixelmap
.
getBytesNumberPerRow
();
})
```
...
...
@@ -464,9 +469,9 @@ let bufferArr = new Unit8Array(color);
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
image
.
createPixelMap
(
color
,
opts
,
(
pixelmap
)
=>
{
pixelmap
.
release
().
then
(()
=>
{
console
.
log
(
'
release succeeded
.
'
);
console
.
log
(
'
Succeeded in releasing pixelmap object
.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
release failed
.
'
);
console
.
log
(
'
Failed to release pixelmap object
.
'
);
})
})
```
...
...
@@ -493,9 +498,9 @@ let bufferArr = new Unit8Array(color);
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
image
.
createPixelMap
(
color
,
opts
,
(
pixelmap
)
=>
{
pixelmap
.
release
().
then
(()
=>
{
console
.
log
(
'
release succeeded
.
'
);
console
.
log
(
'
Succeeded in releasing pixelmap object
.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
release failed
.
'
);
console
.
log
(
'
Failed to release pixelmap object
.
'
);
})
})
```
...
...
@@ -610,9 +615,7 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void
```
js
imageSourceApi
.
getImageInfo
(
imageInfo
=>
{
console
.
log
(
'
getImageInfo succeeded.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
getImageInfo failed.
'
);
console
.
log
(
'
Succeeded in obtaining the image information.
'
);
})
```
...
...
@@ -641,9 +644,9 @@ getImageInfo(index?: number): Promise\<ImageInfo>
```
js
imageSourceApi
.
getImageInfo
(
0
)
.
then
(
imageInfo
=>
{
console
.
log
(
'
getImageInfo succeeded
.
'
);
console
.
log
(
'
Succeeded in obtaining the image information
.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
getImageInfo failed
.
'
);
console
.
log
(
'
Failed to obtain the image information
.
'
);
})
```
...
...
@@ -673,9 +676,7 @@ getImageProperty(key:string, options?: GetImagePropertyOptions): Promise\<string
```
js
imageSourceApi
.
getImageProperty
(
"
BitsPerSample
"
)
.
then
(
data
=>
{
console
.
log
(
'
getImageProperty succeeded.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
getImageProperty failed.
'
);
console
.
log
(
'
Succeeded in getting the value of the specified attribute key of the image.
'
);
})
```
...
...
@@ -699,9 +700,9 @@ getImageProperty(key:string, callback: AsyncCallback\<string>): void
```
js
imageSourceApi
.
getImageProperty
(
"
BitsPerSample
"
,(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
getImageProperty failed
.
'
);
console
.
log
(
'
Failed to get the value of the specified attribute key of the image
.
'
);
}
else
{
console
.
log
(
'
getImageProperty succeeded
.
'
);
console
.
log
(
'
Succeeded in getting the value of the specified attribute key of the image
.
'
);
}
})
```
...
...
@@ -725,11 +726,12 @@ getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCa
**示例:**
```
js
imageSourceApi
.
getImageProperty
(
"
BitsPerSample
"
,
Property
,(
error
,
data
)
=>
{
const
property
=
new
ArrayBuffer
(
400
);
imageSourceApi
.
getImageProperty
(
"
BitsPerSample
"
,
property
,(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
getImageProperty failed
.
'
);
console
.
log
(
'
Failed to get the value of the specified attribute key of the image
.
'
);
}
else
{
console
.
log
(
'
getImageProperty succeeded
.
'
);
console
.
log
(
'
Succeeded in getting the value of the specified attribute key of the image
.
'
);
}
})
```
...
...
@@ -758,9 +760,9 @@ createPixelMap(options?: DecodingOptions): Promise\<PixelMap>
```
js
imageSourceApi
.
createPixelMap
().
then
(
pixelmap
=>
{
console
.
log
(
'
createPixelMap succeeded
.
'
);
console
.
log
(
'
Succeeded in creating pixelmap object through image decoding parameters
.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
createPixelMap failed
.
'
);
console
.
log
(
'
Failed to create pixelmap object through image decoding parameters
.
'
);
})
```
...
...
@@ -782,9 +784,9 @@ createPixelMap(callback: AsyncCallback\<PixelMap>): void
```
js
imageSourceApi
.
createPixelMap
(
pixelmap
=>
{
console
.
log
(
'
createPixelMap succeeded
.
'
);
console
.
log
(
'
Succeeded in creating pixelmap object
.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
createPixelMap failed
.
'
);
console
.
log
(
'
Failed to create pixelmap object
.
'
);
})
```
...
...
@@ -806,11 +808,10 @@ createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): vo
**示例:**
```
js
const
decodingOptions
=
new
ArrayBuffer
(
400
);
imageSourceApi
.
createPixelMap
(
decodingOptions
,
pixelmap
=>
{
console
.
log
(
'
createPixelMap succeeded.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
createPixelMap failed.
'
);
})
console
.
log
(
'
Succeeded in creating pixelmap object.
'
);
})
```
### release
...
...
@@ -832,8 +833,6 @@ release(callback: AsyncCallback\<void>): void
```
js
imageSourceApi
.
release
(()
=>
{
console
.
log
(
'
release succeeded.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
release failed.
'
);
})
```
...
...
@@ -855,9 +854,9 @@ release(): Promise\<void>
```
js
imageSourceApi
.
release
().
then
(()
=>
{
console
.
log
(
'
release succeeded
.
'
);
console
.
log
(
'
Succeeded in releasing the image source instance
.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
release failed
.
'
);
console
.
log
(
'
Failed to release the image source instance
.
'
);
})
```
...
...
@@ -913,7 +912,8 @@ packing(source: ImageSource, option: PackingOption, callback: AsyncCallback\<Arr
```
js
let
packOpts
=
{
format
:
"
image/jpeg
"
,
quality
:
98
};
imagePackerApi
.
packing
(
ImageSourceApi
,
packOpts
,
data
=>
{})
const
imageSourceApi
=
new
ArrayBuffer
(
400
);
imagePackerApi
.
packing
(
imageSourceApi
,
packOpts
,
data
=>
{})
```
### packing
...
...
@@ -941,7 +941,8 @@ packing(source: ImageSource, option: PackingOption): Promise\<ArrayBuffer>
```
js
let
packOpts
=
{
format
:
"
image/jpeg
"
,
quality
:
98
}
imagePackerApi
.
packing
(
ImageSourceApi
,
packOpts
)
const
imageSourceApi
=
new
ArrayBuffer
(
400
);
imagePackerApi
.
packing
(
imageSourceApi
,
packOpts
)
.
then
(
data
=>
{
console
.
log
(
'
packing succeeded.
'
);
}).
catch
(
error
=>
{
...
...
@@ -969,10 +970,11 @@ packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\<ArrayB
```
js
let
packOpts
=
{
format
:
"
image/jpeg
"
,
quality
:
98
}
imagePackerApi
.
packing
(
PixelMapApi
,
packOpts
,
data
=>
{
console
.
log
(
'
packing succeeded.
'
);
const
pixelMapApi
=
new
ArrayBuffer
(
400
);
imagePackerApi
.
packing
(
pixelMapApi
,
packOpts
,
data
=>
{
console
.
log
(
'
Succeeded in packing the image.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
packing failed
.
'
);
console
.
log
(
'
Failed to pack the image
.
'
);
})
```
...
...
@@ -1001,11 +1003,12 @@ packing(source: PixelMap, option: PackingOption): Promise\<ArrayBuffer>
```
js
let
packOpts
=
{
format
:
"
image/jpeg
"
,
quality
:
98
}
imagePackerApi
.
packing
(
PixelMapApi
,
packOpts
)
const
pixelMapApi
=
new
ArrayBuffer
(
400
);
imagePackerApi
.
packing
(
pixelMapApi
,
packOpts
)
.
then
(
data
=>
{
console
.
log
(
'
packing succeeded
.
'
);
console
.
log
(
'
Succeeded in packing the image
.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
packing failed
.
'
);
console
.
log
(
'
Failed to pack the image.
.
'
);
})
```
...
...
@@ -1027,9 +1030,7 @@ release(callback: AsyncCallback\<void>): void
```
js
imagePackerApi
.
release
(()
=>
{
console
.
log
(
'
release succeeded.
'
);
}).
catch
(
error
=>
{
console
.
log
(
'
release failed.
'
);
console
.
log
(
'
Succeeded in releasing image packaging.
'
);
})
```
...
...
@@ -1051,9 +1052,9 @@ release(): Promise\<void>
```
js
imagePackerApi
.
release
().
then
(()
=>
{
console
.
log
(
'
release succeeded
.
'
);
console
.
log
(
'
Succeeded in releasing image packaging
.
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
release failed
.
'
);
console
.
log
(
'
Failed to release image packaging
.
'
);
})
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录