Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
a1242034
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看板
提交
a1242034
编写于
3月 23, 2022
作者:
W
wangxiaokai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update image doc due to APIs check.
Signed-off-by:
N
wangxiaokai
<
wangxiaokai1@huawei.com
>
上级
cd443945
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
180 addition
and
243 deletion
+180
-243
zh-cn/application-dev/reference/apis/js-apis-image.md
zh-cn/application-dev/reference/apis/js-apis-image.md
+180
-243
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-image.md
浏览文件 @
a1242034
# 图片处理
图片处理
==========
> **说明:**
> **说明:**
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
导入模块
---------
```
```
import image from '@ohos.multimedia.image';
import image from '@ohos.multimedia.image';
...
@@ -34,8 +36,6 @@ createPixelMap(colors: ArrayBuffer, options: InitializetionOptions): Promise\<Pi
...
@@ -34,8 +36,6 @@ createPixelMap(colors: ArrayBuffer, options: InitializetionOptions): Promise\<Pi
```
js
```
js
image
.
createPixelMap
(
Color
,
opts
)
image
.
createPixelMap
(
Color
,
opts
)
.
then
((
pixelmap
)
=>
{
.
then
((
pixelmap
)
=>
{
expect
(
pixelmap
!==
null
).
assertTrue
()
done
()
})
})
```
```
...
@@ -59,8 +59,6 @@ createPixelMap(colors: ArrayBuffer, opts: InitializetionOptions) callback: Async
...
@@ -59,8 +59,6 @@ createPixelMap(colors: ArrayBuffer, opts: InitializetionOptions) callback: Async
```
js
```
js
image
.
createPixelMap
(
Color
,
opts
,
(
pixelmap
)
=>
{
image
.
createPixelMap
(
Color
,
opts
,
(
pixelmap
)
=>
{
expect
(
pixelmap
!==
null
).
assertTrue
()
done
()
})
})
```
```
...
@@ -98,25 +96,10 @@ readPixelsToBuffer(dst: ArrayBuffer): Promise\<void>
...
@@ -98,25 +96,10 @@ readPixelsToBuffer(dst: ArrayBuffer): Promise\<void>
```
js
```
js
pixelmap
.
readPixelsToBuffer
(
readBuffer
).
then
(()
=>
{
pixelmap
.
readPixelsToBuffer
(
readBuffer
).
then
(()
=>
{
var
bufferArr
=
new
Uint8Array
(
readBuffer
)
//符合条件则进入
var
res
=
true
}).
catch
(
error
=>
{
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
//不符合条件则进入
if
(
res
)
{
})
if
(
bufferArr
[
i
]
!==
0
)
{
res
=
false
console
.
info
(
'
TC_020 Success
'
)
expect
(
true
).
assertTrue
()
done
()
break
}
}
}
if
(
res
)
{
console
.
info
(
'
TC_020 buffer is all empty
'
)
expect
(
false
).
assertTrue
()
done
()
}
})
```
```
### readPixelsToBuffer<sup>7+</sup>
### readPixelsToBuffer<sup>7+</sup>
...
@@ -138,24 +121,6 @@ readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void
...
@@ -138,24 +121,6 @@ readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void
```
js
```
js
pixelmap
.
readPixelsToBuffer
(
readBuffer
,
()
=>
{
pixelmap
.
readPixelsToBuffer
(
readBuffer
,
()
=>
{
var
bufferArr
=
new
Uint8Array
(
readBuffer
)
var
res
=
true
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
if
(
res
)
{
if
(
bufferArr
[
i
]
!==
0
)
{
res
=
false
console
.
info
(
'
TC_020-1 Success
'
)
expect
(
true
).
assertTrue
()
done
()
break
}
}
}
if
(
res
)
{
console
.
info
(
'
TC_020-1 buffer is all empty
'
)
expect
(
false
).
assertTrue
()
done
()
}
})
})
```
```
...
@@ -183,28 +148,10 @@ readPixels(area: PositionArea): Promise\<void>
...
@@ -183,28 +148,10 @@ readPixels(area: PositionArea): Promise\<void>
```
js
```
js
pixelmap
.
readPixels
(
area
).
then
((
data
)
=>
{
pixelmap
.
readPixels
(
area
).
then
((
data
)
=>
{
if
(
data
!==
null
){
//符合条件则进入
var
bufferArr
=
new
Uint8Array
(
area
.
pixels
);
}).
catch
(
error
=>
{
var
res
=
true
;
//不符合条件则进入
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
})
console
.
info
(
'
TC_021 buffer
'
+
bufferArr
[
i
]);
if
(
res
)
{
if
(
bufferArr
[
i
]
==
0
)
{
res
=
false
;
console
.
info
(
'
TC_021 Success
'
);
expect
(
true
).
assertTrue
();
done
();
break
;
}
}
}
if
(
res
)
{
console
.
info
(
'
TC_021 buffer is all empty
'
);
expect
(
false
).
assertTrue
()
done
();
}
}
})
```
```
### readPixels<sup>7+</sup>
### readPixels<sup>7+</sup>
...
@@ -225,29 +172,29 @@ readPixels(area: PositionArea, callback: AsyncCallback\<void>): void
...
@@ -225,29 +172,29 @@ readPixels(area: PositionArea, callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
js
```
js
pixelmap
.
readPixels
(
area
,(
data
)
=>
{
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
if
(
data
!==
null
)
{
image
.
createPixelMap
(
color
,
opts
,
(
err
,
pixelmap
)
=>
{
var
bufferArr
=
new
Uint8Array
(
area
.
pixels
);
if
(
pixelmap
==
undefined
){
var
res
=
true
;
console
.
info
(
'
createPixelMap failed
'
)
;
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
expect
(
false
).
assertTrue
();
console
.
info
(
'
TC_021-1 buffer
'
+
bufferArr
[
i
]
);
done
(
);
if
(
res
)
{
}
else
{
if
(
bufferArr
[
i
]
==
0
)
{
const
area
=
{
pixels
:
new
ArrayBuffer
(
8
),
res
=
false
;
offset
:
0
,
console
.
info
(
'
TC_021-1 Success
'
);
stride
:
8
,
expect
(
true
).
assertTrue
();
region
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
}}
done
();
pixelmap
.
readPixels
(
area
,
()
=>
{
break
;
console
.
info
(
'
readPixels success
'
)
;
}
})
}
}
}
})
```
```
### writePixels<sup>7+</sup>
### writePixels<sup>7+</sup>
writePixels(area: PositionArea): Promise
\<
void>
writePixels(area: PositionArea): Promise
\<
void>
将Pixel
m
ap写入指定区域内,使用Promise形式返回写入结果。
将Pixel
M
ap写入指定区域内,使用Promise形式返回写入结果。
**系统能力:**
SystemCapability.Multimedia.Image
**系统能力:**
SystemCapability.Multimedia.Image
...
@@ -266,18 +213,46 @@ writePixels(area: PositionArea): Promise\<void>
...
@@ -266,18 +213,46 @@ writePixels(area: PositionArea): Promise\<void>
**示例:**
**示例:**
```
js
```
js
pixelMap
.
writePixels
(
area
).
then
(()
=>
{
const
color
=
new
ArrayBuffer
(
96
);
console
.
log
(
"
Succeeded in writing pixels.
"
);
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
}
}
}).
catch
((
err
)
=>
{
image
.
createPixelMap
(
color
,
opts
)
console
.
error
(
"
Failed to write pixels.
"
);
.
then
(
pixelmap
=>
{
});
if
(
pixelmap
==
undefined
)
{
console
.
info
(
'
createPixelMap failed
'
);
expect
(
false
).
assertTrue
()
done
();
}
const
area
=
{
pixels
:
new
ArrayBuffer
(
8
),
offset
:
0
,
stride
:
8
,
region
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
}
}
var
bufferArr
=
new
Uint8Array
(
area
.
pixels
);
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
++
)
{
bufferArr
[
i
]
=
i
+
1
;
}
pixelmap
.
writePixels
(
area
).
then
(()
=>
{
const
readArea
=
{
pixels
:
new
ArrayBuffer
(
8
),
offset
:
0
,
stride
:
8
,
// region.size.width + x < opts.width, region.size.height + y < opts.height
region
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
}
}
})
})
.
catch
(
error
=>
{
console
.
log
(
'
error:
'
+
error
);
expect
().
assertFail
();
done
();
})
```
```
### writePixels<sup>7+</sup>
### writePixels<sup>7+</sup>
writePixels(area: PositionArea, callback: AsyncCallback
\<
void>): void
writePixels(area: PositionArea, callback: AsyncCallback
\<
void>): void
将Pixel
m
ap写入指定区域内,使用callback形式返回写入结果。
将Pixel
M
ap写入指定区域内,使用callback形式返回写入结果。
**系统能力:**
SystemCapability.Multimedia.Image
**系统能力:**
SystemCapability.Multimedia.Image
...
@@ -305,7 +280,7 @@ pixelmap.writePixels(area, () => {
...
@@ -305,7 +280,7 @@ pixelmap.writePixels(area, () => {
writeBufferToPixels(src: ArrayBuffer): Promise
\<
void>
writeBufferToPixels(src: ArrayBuffer): Promise
\<
void>
读取缓冲区中的图片数据,结果写入Pixel
m
ap中,使用Promise形式返回。
读取缓冲区中的图片数据,结果写入Pixel
M
ap中,使用Promise形式返回。
**系统能力:**
SystemCapability.Multimedia.Image
**系统能力:**
SystemCapability.Multimedia.Image
...
@@ -335,7 +310,7 @@ pixelMap.writeBufferToPixels(colorBuffer).then(() => {
...
@@ -335,7 +310,7 @@ pixelMap.writeBufferToPixels(colorBuffer).then(() => {
writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback
\<
void>): void
writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback
\<
void>): void
读取缓冲区中的图片数据,结果写入Pixel
m
ap中,使用callback形式返回。
读取缓冲区中的图片数据,结果写入Pixel
M
ap中,使用callback形式返回。
**系统能力:**
SystemCapability.Multimedia.Image
**系统能力:**
SystemCapability.Multimedia.Image
...
@@ -399,19 +374,7 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void
...
@@ -399,19 +374,7 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void
**示例:**
**示例:**
```
js
```
js
pixelmap
.
getImageInfo
((
imageInfo
)
=>
{
pixelmap
.
getImageInfo
((
imageInfo
)
=>
{})
if
(
imageInfo
!==
null
)
{
console
.
info
(
'
TC_024-1 imageInfo is ready
'
)
expect
(
imageInfo
.
size
.
height
==
4
).
assertTrue
()
expect
(
imageInfo
.
size
.
width
==
6
).
assertTrue
()
expect
(
imageInfo
.
pixelFormat
==
1
).
assertTrue
()
done
()
}
else
{
console
.
info
(
'
TC_024-1 imageInfo is empty
'
)
expect
(
false
).
assertTrue
()
done
()
}
})
```
```
### getBytesNumberPerRow<sup>7+</sup>
### getBytesNumberPerRow<sup>7+</sup>
...
@@ -431,11 +394,7 @@ getBytesNumberPerRow(): number
...
@@ -431,11 +394,7 @@ getBytesNumberPerRow(): number
**示例:**
**示例:**
```
js
```
js
pixelmap
.
getBytesNumberPerRow
().
then
((
num
)
=>
{
rowCount
=
pixelmap
.
getBytesNumberPerRow
()
console
.
info
(
'
TC_025 num is
'
+
num
)
expect
(
num
==
expectNum
).
assertTrue
()
done
()
})
```
```
### getPixelBytesNumber<sup>7+</sup>
### getPixelBytesNumber<sup>7+</sup>
...
@@ -455,18 +414,14 @@ getPixelBytesNumber(): number
...
@@ -455,18 +414,14 @@ getPixelBytesNumber(): number
**示例:**
**示例:**
```
js
```
js
pixelmap
.
getPixelBytesNumber
().
then
((
num
)
=>
{
pixelBytesNumber
=
pixelmap
.
getPixelBytesNumber
()
console
.
info
(
'
TC_026 num is
'
+
num
)
expect
(
num
==
expectNum
).
assertTrue
()
done
()
})
```
```
### release<sup>7+</sup>
### release<sup>7+</sup>
release():Promise
\<
void>
release():Promise
\<
void>
释放Pixel
m
ap对象,使用Promise形式返回释放结果。
释放Pixel
M
ap对象,使用Promise形式返回释放结果。
**系统能力:**
SystemCapability.Multimedia.Image
**系统能力:**
SystemCapability.Multimedia.Image
...
@@ -479,16 +434,15 @@ release():Promise\<void>
...
@@ -479,16 +434,15 @@ release():Promise\<void>
**示例:**
**示例:**
```
js
```
js
pixelmap
.
release
()
pixelmap
.
release
().
then
(()
=>
{
})
expect
(
true
).
assertTrue
()
.
catch
(
error
=>
{})
done
()
```
```
### release<sup>7+</sup>
### release<sup>7+</sup>
release(callback: AsyncCallback
\<
void>): void
release(callback: AsyncCallback
\<
void>): void
释放Pixel
m
ap对象,使用callback形式返回释放结果。
释放Pixel
M
ap对象,使用callback形式返回释放结果。
**系统能力:**
SystemCapability.Multimedia.Image
**系统能力:**
SystemCapability.Multimedia.Image
...
@@ -501,11 +455,7 @@ release(callback: AsyncCallback\<void>): void
...
@@ -501,11 +455,7 @@ release(callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
js
```
js
pixelmap
.
release
(()
=>
{
pixelmap
.
release
(()
=>
{
})
expect
(
true
).
assertTrue
();
console
.
log
(
'
TC_027-1 success
'
);
done
();
})
```
```
## image.createImageSource
## image.createImageSource
...
@@ -524,9 +474,9 @@ createImageSource(uri: string): ImageSource
...
@@ -524,9 +474,9 @@ createImageSource(uri: string): ImageSource
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明
|
| --------------------------- | --------------------------------------- |
| --------------------------- | ---------------------------------------
-----
|
|
[
ImageSource
](
#imagesource
)
| 返回ImageSource类实例,失败时返回
null
。 |
|
[
ImageSource
](
#imagesource
)
| 返回ImageSource类实例,失败时返回
undefined
。 |
**示例:**
**示例:**
...
@@ -550,9 +500,9 @@ createImageSource(fd: number): ImageSource
...
@@ -550,9 +500,9 @@ createImageSource(fd: number): ImageSource
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明
|
| --------------------------- | --------------------------------------- |
| --------------------------- | ---------------------------------------
-----
|
|
[
ImageSource
](
#imagesource
)
| 返回ImageSource类实例,失败时返回
null
。 |
|
[
ImageSource
](
#imagesource
)
| 返回ImageSource类实例,失败时返回
undefined
。 |
**示例:**
**示例:**
...
@@ -588,20 +538,7 @@ getImageInfo(index: number, callback: AsyncCallback\<ImageInfo>): void
...
@@ -588,20 +538,7 @@ getImageInfo(index: number, callback: AsyncCallback\<ImageInfo>): void
**示例:**
**示例:**
```
js
```
js
it
(
'
TC_046
'
,
0
,
async
function
(
done
)
{
imageSourceApi
.
getImageInfo
(
0
,(
error
,
imageInfo
)
=>
{})
const
imageSourceApi
=
image
.
createImageSource
(
'
/sdcard/test.jpg
'
);
if
(
imageSourceApi
==
null
)
{
console
.
info
(
'
TC_046 create image source failed
'
);
expect
(
false
).
assertTrue
();
done
();
}
else
{
imageSourceApi
.
getImageInfo
(
0
,(
error
,
imageInfo
)
=>
{
console
.
info
(
'
TC_046 imageInfo
'
);
expect
(
imageInfo
!==
null
).
assertTrue
();
done
();
})
}
})
```
```
### getImageInfo
### getImageInfo
...
@@ -621,11 +558,7 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void
...
@@ -621,11 +558,7 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void
**示例:**
**示例:**
```
js
```
js
imageSourceApi
.
getImageInfo
(
imageInfo
=>
{
imageSourceApi
.
getImageInfo
(
imageInfo
=>
{})
console
.
info
(
'
TC_045 imageInfo
'
);
expect
(
imageInfo
!==
null
).
assertTrue
();
done
();
})
```
```
### getImageInfo
### getImageInfo
...
@@ -652,11 +585,8 @@ getImageInfo(index?: number): Promise\<ImageInfo>
...
@@ -652,11 +585,8 @@ getImageInfo(index?: number): Promise\<ImageInfo>
```
js
```
js
imageSourceApi
.
getImageInfo
(
0
)
imageSourceApi
.
getImageInfo
(
0
)
.
then
(
imageInfo
=>
{
.
then
(
imageInfo
=>
{})
console
.
info
(
'
TC_047 imageInfo
'
);
.
catch
(
error
=>
{})
expect
(
imageInfo
!==
null
).
assertTrue
();
done
();
})
```
```
### getImageProperty<sup>7+</sup>
### getImageProperty<sup>7+</sup>
...
@@ -683,7 +613,9 @@ getImageProperty(key:string, options?: GetImagePropertyOptions): Promise\<string
...
@@ -683,7 +613,9 @@ getImageProperty(key:string, options?: GetImagePropertyOptions): Promise\<string
**示例:**
**示例:**
```
js
```
js
const
w
=
imageSourceApi
.
getImageProperty
(
"
ImageWidth
"
)
imageSourceApi
.
getImageProperty
(
"
BitsPerSample
"
)
.
then
(
data
=>
{})
.
catch
(
error
=>
{})
```
```
### getImageProperty<sup>7+</sup>
### getImageProperty<sup>7+</sup>
...
@@ -704,7 +636,7 @@ getImageProperty(key:string, callback: AsyncCallback\<string>): void
...
@@ -704,7 +636,7 @@ getImageProperty(key:string, callback: AsyncCallback\<string>): void
**示例:**
**示例:**
```
js
```
js
const
w
=
imageSourceApi
.
getImageProperty
(
"
ImageWidth
"
,
w
=>
{})
imageSourceApi
.
getImageProperty
(
"
BitsPerSample
"
,(
error
,
data
)
=>
{})
```
```
### getImageProperty<sup>7+</sup>
### getImageProperty<sup>7+</sup>
...
@@ -726,14 +658,14 @@ getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCa
...
@@ -726,14 +658,14 @@ getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCa
**示例:**
**示例:**
```
js
```
js
imageSourceApi
.
getImageProperty
(
"
ImageWidth
"
,
PropertyOptions
,(
w
)
=>
{})
imageSourceApi
.
getImageProperty
(
"
BitsPerSample
"
,
property
,(
error
,
data
)
=>
{})
```
```
### createPixelMap<sup>7+</sup>
### createPixelMap<sup>7+</sup>
createPixelMap(
index: number, options: DecodingOptions, callback: AsyncCallback
\<
PixelMap>): void
createPixelMap(
options?: DecodingOptions): Promise
<PixelMap>
;
通过图片解码参数创建Pixel
map对象,使用callback形式返回结果
。
通过图片解码参数创建Pixel
Map对象
。
**系统能力:**
SystemCapability.Multimedia.Image
**系统能力:**
SystemCapability.Multimedia.Image
...
@@ -741,25 +673,21 @@ createPixelMap(index: number, options: DecodingOptions, callback: AsyncCallback\
...
@@ -741,25 +673,21 @@ createPixelMap(index: number, options: DecodingOptions, callback: AsyncCallback\
| 名称 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------------- | ---- | -------------------------- |
| ------------- | ------------------------------------- | ---- | -------------------------- |
| options |
[
DecodingOptions
](
#decodingoptions7
)
| 是 | 解码参数。 |
| options |
[
DecodingOptions
](
#decodingoptions7
)
| 否 | 解码参数。 |
| index | number | 是 | 图片索引。 |
| AsyncCallback | AsyncCallback
<
[
PixelMap
](
#pixelmap7
)
>
| 是 | 通过回调返回PixelMap对象。 |
| AsyncCallback | AsyncCallback
<
[
PixelMap
](
#pixelmap7
)
>
| 是 | 通过回调返回PixelMap对象。 |
**示例:**
**示例:**
```
js
```
js
imageSourceApi
.
createPixelMap
().
then
(
pixelmap
=>
{
imageSourceApi
.
createPixelMap
().
then
(
pixelmap
=>
{})
console
.
info
(
'
TC_050-11 createPixelMap
'
);
.
catch
(
error
=>
{})
expect
(
pixelmap
!==
null
).
assertTrue
();
done
();
})
```
```
### createPixelMap<sup>7+</sup>
### createPixelMap<sup>7+</sup>
createPixelMap(
options: DecodingOptions, callback: AsyncCallback
\<
PixelMap>): void
createPixelMap(
callback: AsyncCallback
<PixelMap>
): void;
通过
图片解码参数创建pixelmap对象
。
通过
默认参数创建PixelMap对象,使用callback形式返回结果
。
**系统能力:**
SystemCapability.Multimedia.Image
**系统能力:**
SystemCapability.Multimedia.Image
...
@@ -767,30 +695,17 @@ createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): vo
...
@@ -767,30 +695,17 @@ createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): vo
| 名称 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | -------------------------- |
| -------- | ------------------------------------- | ---- | -------------------------- |
| options |
[
DecodingOptions
](
#decodingoptions7
)
| 是 | 解码参数。 |
| callback | AsyncCallback
<
[
PixelMap
](
#pixelmap7
)
>
| 是 | 通过回调返回PixelMap对象。 |
| callback | AsyncCallback
<
[
PixelMap
](
#pixelmap7
)
>
| 是 | 通过回调返回PixelMap对象。 |
**示例:**
**示例:**
```
js
```
js
let
decodingOptions
=
{
imageSourceApi
.
createPixelMap
(
pixelmap
=>
{})
sampleSize
:
1
,
editable
:
true
,
desiredSize
:{
width
:
1
,
height
:
2
},
rotateDegrees
:
10
,
desiredPixelFormat
:
1
,
desiredRegion
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
},
};
imageSourceApi
.
createPixelMap
(
0
,
decodingOptions
,
pixelmap
=>
{
console
.
info
(
'
TC_050-1 createPixelMap
'
);
expect
(
pixelmap
!==
null
).
assertTrue
();
done
();
})
```
```
### createPixelMap<sup>7+</sup>
### createPixelMap<sup>7+</sup>
createPixelMap(opt
s: DecodingOptions, callback: AsyncCallback
\<
PixelMap>): void
createPixelMap(opt
ions: DecodingOptions, callback: AsyncCallback
<PixelMap>
): void;
通过图片解码参数创建pixelmap对象。
通过图片解码参数创建pixelmap对象。
...
@@ -800,26 +715,13 @@ createPixelMap(opts: DecodingOptions, callback: AsyncCallback\<PixelMap>): void
...
@@ -800,26 +715,13 @@ createPixelMap(opts: DecodingOptions, callback: AsyncCallback\<PixelMap>): void
| 名称 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | -------------------------- |
| -------- | ------------------------------------- | ---- | -------------------------- |
| opt
s
|
[
DecodingOptions
](
#decodingoptions7
)
| 是 | 解码参数。 |
| opt
ions
|
[
DecodingOptions
](
#decodingoptions7
)
| 是 | 解码参数。 |
| callback | AsyncCallback
<
[
PixelMap
](
#pixelmap7
)
>
| 是 | 通过回调返回PixelMap对象。 |
| callback | AsyncCallback
<
[
PixelMap
](
#pixelmap7
)
>
| 是 | 通过回调返回PixelMap对象。 |
**示例:**
**示例:**
```
js
```
js
let
decodingOptions
=
{
imageSourceApi
.
createPixelMap
(
decodingOptions
,
pixelmap
=>
{})
sampleSize
:
1
,
editable
:
true
,
desiredSize
:{
width
:
1
,
height
:
2
},
rotateDegrees
:
10
,
desiredPixelFormat
:
1
,
desiredRegion
:
{
size
:
{
height
:
1
,
width
:
2
},
x
:
0
,
y
:
0
},
index
:
1
};
imageSourceApi
.
createPixelMap
(
decodingOptions
,
pixelmap
=>
{
console
.
info
(
'
TC_050-1 createPixelMap
'
);
expect
(
pixelmap
!==
null
).
assertTrue
();
done
();
})
```
```
### release
### release
...
@@ -839,12 +741,7 @@ release(callback: AsyncCallback\<void>): void
...
@@ -839,12 +741,7 @@ release(callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
js
```
js
imageSourceApi
.
release
(()
=>
{
imageSourceApi
.
release
(()
=>
{})
console
.
info
(
'
TC_044-1 Success
'
);
expect
(
true
).
assertTrue
();
done
();
})
}
```
```
### release
### release
...
@@ -864,11 +761,7 @@ release(): Promise\<void>
...
@@ -864,11 +761,7 @@ release(): Promise\<void>
**示例:**
**示例:**
```
js
```
js
imageSourceApi
.
release
(()
=>
{
imageSourceApi
.
release
().
then
(()
=>
{
}).
catch
(
error
=>
{})
console
.
info
(
'
TC_044-1 Success
'
);
expect
(
true
).
assertTrue
();
done
();
})
```
```
## image.createImagePacker
## image.createImagePacker
...
@@ -921,11 +814,7 @@ packing(source: ImageSource, option: PackingOption, callback: AsyncCallback<Arra
...
@@ -921,11 +814,7 @@ packing(source: ImageSource, option: PackingOption, callback: AsyncCallback<Arra
```
js
```
js
let
packOpts
=
{
format
:[
"
image/jpeg
"
],
quality
:
98
}
let
packOpts
=
{
format
:[
"
image/jpeg
"
],
quality
:
98
}
imagePackerApi
.
packing
(
imageSourceApi
,
packOpts
,
data
=>
{
imagePackerApi
.
packing
(
imageSourceApi
,
packOpts
,
data
=>
{})
console
.
info
(
'
TC_062-1 finished
'
);
expect
(
data
!==
null
).
assertTrue
();
done
();
})
```
```
### packing
### packing
...
@@ -953,12 +842,62 @@ packing(source: ImageSource, option: PackingOption): Promise<Array\<number>>
...
@@ -953,12 +842,62 @@ packing(source: ImageSource, option: PackingOption): Promise<Array\<number>>
```
js
```
js
let
packOpts
=
{
format
:[
"
image/jpeg
"
],
quality
:
98
}
let
packOpts
=
{
format
:[
"
image/jpeg
"
],
quality
:
98
}
imagePackerApi
.
packing
(
imageSourceApi
,
packOpts
)
imagePackerApi
.
packing
(
imageSourceApi
,
packOpts
)
.
then
(
data
=>
{
.
then
(
data
=>
{
})
console
.
info
(
'
TC_062 finished
'
);
.
catch
(
error
=>
{})
expect
(
data
!==
null
).
assertTrue
();
```
done
();
})
### packing
packing(source: PixelMap, option: PackingOption, callback: AsyncCallback
<ArrayBuffer>
): void;
图片压缩或重新打包,使用callback形式返回结果。
**系统能力:**
SystemCapability.Multimedia.Image
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ---------------------------------- |
| source |
[
PixelMap
](
#pixelmap
)
| 是 | 打包的PixelMap资源。 |
| option |
[
PackingOption
](
#packingoption
)
| 是 | 设置打包参数。 |
| callback | AsyncCallback
<ArrayBuffer>
| 是 | 获取图片打包回调,返回打包后数据。 |
**示例:**
```
js
let
packOpts
=
{
format
:[
"
image/jpeg
"
],
quality
:
98
}
imagePackerApi
.
packing
(
pixelMapApi
,
packOpts
,
data
=>
{})
```
### packing
packing(source: PixelMap, option: PackingOption): Promise
<Array
\<
number
>
>
图片压缩或重新打包,使用Promise形式返回结果。
**系统能力:**
SystemCapability.Multimedia.Image
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------------- | ---- | -------------- |
| source |
[
PixelMap
](
#pixelmap
)
| 是 | 打包的PixelMap源。 |
| option |
[
PackingOption
](
#packingoption
)
| 是 | 设置打包参数。 |
**返回值:**
| 类型 | 说明 |
| :---------------------- | :-------------------------------------------- |
| Promise
<Array
\<
number
>
> | Promise实例,用于异步获取压缩或打包后的数据。 |
**示例:**
```
js
let
packOpts
=
{
format
:[
"
image/jpeg
"
],
quality
:
98
}
imagePackerApi
.
packing
(
pixelMapApi
,
packOpts
)
.
then
(
data
=>
{
})
.
catch
(
error
=>
{})
```
```
### release
### release
...
@@ -978,10 +917,7 @@ release(callback: AsyncCallback\<void>): void
...
@@ -978,10 +917,7 @@ release(callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
js
```
js
imagePackerApi
.
release
(()
=>
{
imagePackerApi
.
release
(()
=>
{})
console
.
info
(
'
TC_063-1 release
'
);
expect
(
true
).
assertTrue
();
done
();
```
```
### release
### release
...
@@ -1001,10 +937,8 @@ release(): Promise\<void>
...
@@ -1001,10 +937,8 @@ release(): Promise\<void>
**示例:**
**示例:**
```
js
```
js
imagePackerApi
.
release
();
imagePackerApi
.
release
().
then
(()
=>
{
console
.
info
(
'
TC_063 release
'
);
}).
catch
((
error
)
=>
{})
expect
(
true
).
assertTrue
();
done
();
```
```
## PositionArea<sup>7+</sup>
## PositionArea<sup>7+</sup>
...
@@ -1013,12 +947,12 @@ imagePackerApi.release();
...
@@ -1013,12 +947,12 @@ imagePackerApi.release();
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Multimedia.Image
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Multimedia.Image
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 可读 | 可写 | 说明
|
| ------ | ------------------ | ---- | ---- | -------------------- |
| ------ | ------------------ | ---- | ---- | --------------------
----------------------------------------
|
| pixels | ArrayBuffer | 是 | 否 | 像素。 |
| pixels | ArrayBuffer | 是 | 否 | 像素。
|
| offset | number | 是 | 否 | 偏移量。 |
| offset | number | 是 | 否 | 偏移量。
|
| stride | number | 是 | 否 | 像素间距
。
|
| stride | number | 是 | 否 | 像素间距
,stride >= region.size.width
*
4。
|
| region |
[
Region
](
#region8
)
| 是 | 否 | 区域,按照区域读写。 |
| region |
[
Region
](
#region8
)
| 是 | 否 | 区域,按照区域读写。
写入的区域宽度加X坐标不能大于原图的宽度,写入的区域高度加Y坐标不能大于原图的高度
|
## ImageInfo
## ImageInfo
...
@@ -1053,7 +987,7 @@ imagePackerApi.release();
...
@@ -1053,7 +987,7 @@ imagePackerApi.release();
| RGBA_8888 | 3 | 格式为RGBA_8888。 |
| RGBA_8888 | 3 | 格式为RGBA_8888。 |
| RGB_565 | 2 | 格式为RGB_565。 |
| RGB_565 | 2 | 格式为RGB_565。 |
## AlphaType<sup>
8
+</sup>
## AlphaType<sup>
9
+</sup>
枚举,透明度。
枚举,透明度。
...
@@ -1066,7 +1000,7 @@ imagePackerApi.release();
...
@@ -1066,7 +1000,7 @@ imagePackerApi.release();
| PREMUL | 2 | RGB前乘alpha。 |
| PREMUL | 2 | RGB前乘alpha。 |
| UNPREMUL | 3 | RGB不前乘alpha。 |
| UNPREMUL | 3 | RGB不前乘alpha。 |
## ScaleMode<sup>
8
+</sup>
## ScaleMode<sup>
9
+</sup>
枚举,缩略值。
枚举,缩略值。
...
@@ -1083,10 +1017,10 @@ imagePackerApi.release();
...
@@ -1083,10 +1017,10 @@ imagePackerApi.release();
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | ---------------------------------- | ---- | ---- | -------------- |
| ----------- | ---------------------------------- | ---- | ---- | -------------- |
| alphaType
|
[
AlphaType
](
#alphatype8
)
| 是 | 是 | 透明度。 |
| alphaType
<sup>
9+
</sup>
|
[
AlphaType
](
#alphatype9
)
| 是 | 是 | 透明度。 |
| editable | boolean | 是 | 是 | 是否可编辑。 |
| editable | boolean | 是 | 是 | 是否可编辑。 |
| pixelFormat |
[
PixelMapFormat
](
#pixelmapformat7
)
| 是 | 是 | 像素格式。 |
| pixelFormat |
[
PixelMapFormat
](
#pixelmapformat7
)
| 是 | 是 | 像素格式。 |
| scaleMode
|
[
ScaleMode
](
#scalemode8
)
| 是 | 是 | 缩略值。 |
| scaleMode
<sup>
9+
</sup>
|
[
ScaleMode
](
#scalemode9
)
| 是 | 是 | 缩略值。 |
| size |
[
Size
](
#size
)
| 是 | 是 | 创建图片大小。 |
| size |
[
Size
](
#size
)
| 是 | 是 | 创建图片大小。 |
## DecodingOptions<sup>7+</sup>
## DecodingOptions<sup>7+</sup>
...
@@ -1111,11 +1045,11 @@ imagePackerApi.release();
...
@@ -1111,11 +1045,11 @@ imagePackerApi.release();
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Multimedia.Image
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Multimedia.Image
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 可读 | 可写 | 说明
|
| ---- | ------------- | ---- | ---- | ---------- |
| ---- | ------------- | ---- | ---- | ----------
--
|
| size |
[
Size
](
#size
)
| 是 | 是 | 区域大小。 |
| size |
[
Size
](
#size
)
| 是 | 是 | 区域大小。
|
| x | number | 是 | 是 | 区域坐标。 |
| x | number | 是 | 是 | 区域
横
坐标。 |
| y | number | 是 | 是 | 区域坐标。 |
| y | number | 是 | 是 | 区域
纵
坐标。 |
## PackingOption
## PackingOption
...
@@ -1143,6 +1077,8 @@ imagePackerApi.release();
...
@@ -1143,6 +1077,8 @@ imagePackerApi.release();
枚举,Exif(Exchangeable image file format)图片信息。
枚举,Exif(Exchangeable image file format)图片信息。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Multimedia.Image
| 名称 | 默认值 | 说明 |
| 名称 | 默认值 | 说明 |
| ----------------- | ----------------- | -------------------- |
| ----------------- | ----------------- | -------------------- |
| BITS_PER_SAMPLE | "BitsPerSample" | 每个像素字节数。 |
| BITS_PER_SAMPLE | "BitsPerSample" | 每个像素字节数。 |
...
@@ -1152,4 +1088,5 @@ imagePackerApi.release();
...
@@ -1152,4 +1088,5 @@ imagePackerApi.release();
| GPS_LATITUDE | "GPSLatitude" | 图片纬度。 |
| GPS_LATITUDE | "GPSLatitude" | 图片纬度。 |
| GPS_LONGITUDE | "GPSLongitude" | 图片经度。 |
| GPS_LONGITUDE | "GPSLongitude" | 图片经度。 |
| GPS_LATITUDE_REF | "GPSLatitudeRef" | 纬度引用,例如N或S。 |
| GPS_LATITUDE_REF | "GPSLatitudeRef" | 纬度引用,例如N或S。 |
| GPS_LONGITUDE_REF | "GPSLongitudeRef" | 经度引用,例如W或E。 |
| GPS_LONGITUDE_REF | "GPSLongitudeRef" | 经度引用,例如W或E。 |
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录