From 0cfd208189766a776b68ec06c1c720eddf334433 Mon Sep 17 00:00:00 2001 From: renhongwei Date: Thu, 2 Mar 2023 16:01:08 +0800 Subject: [PATCH] add image interface Signed-off-by: renhongwei --- .../reference/apis/js-apis-image.md | 175 +++++++++++++++++- 1 file changed, 173 insertions(+), 2 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md index 64c4c4f6a9..b08aa4862f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -1478,8 +1478,8 @@ createPixelMap(callback: AsyncCallback\): void ```js imageSourceApi.createPixelMap((err, pixelmap) => { - console.info('Succeeded in creating pixelmap object.'); - }) + console.info('Succeeded in creating pixelmap object.'); +}) ``` ### createPixelMap7+ @@ -1514,6 +1514,177 @@ imageSourceApi.createPixelMap(decodingOptions, pixelmap => { }) ``` +### createPixelMapList10+ + +createPixelMapList(options?: DecodingOptions): Promise>; + +通过图片解码参数创建PixelMap数组。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageSource + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | -------------------------- | +| options | [DecodingOptions](#decodingoptions7) | 否 | 解码参数。 | + +**返回值:** + +| 类型 | 说明 | +| -------------------------------- | --------------------- | +| Promise> | 异步返回PixeMap数组。 | + +**示例:** + +```js +let decodeOpts = { + sampleSize: 1, + editable: true, + desiredSize: { width: 198, height: 202 }, + rotate: 0, + desiredPixelFormat: RGBA_8888, + index: 0, +}; +let pixelmaplist = await imageSourceApi.createPixelMapList(decodeOpts); +``` + +### createPixelMapList10+ + +createPixelMapList(callback: AsyncCallback>): void + +通过默认参数创建PixelMap数组,使用callback形式返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageSource + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | -------------------------- | +| callback | AsyncCallback> | 是 | 通过回调返回PixelMap数组。 | + +**示例:** + +```js +imageSourceApi.createPixelMap( pixelmaplist => { + console.info('Succeeded in creating pixelmaplist object.'); +}) +``` + +### createPixelMapList10+ + +createPixelMapList(options: DecodingOptions, callback: AsyncCallback>): void; + +通过图片解码参数创建PixelMap数组,使用callback形式返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageSource + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------------------------- | +| options | [DecodingOptions](#decodingoptions7) | 是 | 解码参数。 | +| callback | AsyncCallback> | 是 | 通过回调返回PixelMap数组。 | + +**示例:** + +```js +let decodeOpts = { + sampleSize: 1, + editable: true, + desiredSize: { width: 198, height: 202 }, + rotate: 0, + desiredPixelFormat: RGBA_8888, + index: 0, +}; +imageSourceApi.createPixelMap(decodeOpts, pixelmaplist => { + console.log('Succeeded in creating pixelmaplist object.'); +}) +``` + +### getDelayTime10+ + +getDelayTime(callback: AsyncCallback>): void; + +获取图像延迟时间数组,使用callback形式返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageSource + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------------------------- | +| callback | AsyncCallback> | 是 | 通过回调返回延迟时间数组。 | + +**示例:** + +```js +imageSourceApi.getDelayTime( delayTimes => { + console.log('Succeeded in getting delay time.'); +}); +``` + +### getDelayTime10+ + +getDelayTime(): Promise>; + +获取图像延迟时间数组,使用Promise形式返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageSource + +**返回值:** + +| 类型 | 说明 | +| -------------- | --------------------------- | +| Promise> | Promise实例,异步返回延迟时间数组。 | + +**示例:** + +```js +let delayTimes = await imageSourceApi.getDelayTime(); +``` + +### getFrameCount10+ + +getFrameCount(callback: AsyncCallback): void; + +获取图像帧数,使用callback形式返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageSource + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------------------------- | +| callback | AsyncCallback\ | 是 | 通过回调返回图像帧数。 | + +**示例:** + +```js +imageSourceApi.getFrameCount( frameCount => { + console.log('Succeeded in getting frame count.'); +}); +``` + +### getFrameCount10+ + +getFrameCount(): Promise\; + +获取图像帧数,使用Promise形式返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageSource + +**返回值:** + +| 类型 | 说明 | +| -------------- | --------------------------- | +| Promise\ | Promise实例,异步返回图像帧数。 | + +**示例:** + +```js +let frameCount = await imageSourceApi.getFrameCount(); +``` + ### release release(callback: AsyncCallback\): void -- GitLab