From bc7e5d5a9548213a4a049e72f72ef36b4ad9fd10 Mon Sep 17 00:00:00 2001 From: liujia178 Date: Fri, 16 May 2025 14:56:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9multimedia=20image=20arkts1.2?= =?UTF-8?q?=20=E5=B7=AE=E5=BC=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liujia178 --- .../reference/apis-image-kit/js-apis-image.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md b/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md index 947ed5e4818..573ca40c216 100644 --- a/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md @@ -4102,6 +4102,8 @@ createImageSource(fd: number, options: SourceOptions): ImageSource **示例:** +ArkTS1.1示例: + ```ts import { fileIo as fs } from '@kit.CoreFileKit'; @@ -4113,6 +4115,19 @@ let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE); const imageSourceApi: image.ImageSource = image.createImageSource(file.fd, sourceOptions); ``` +ArkTS1.2示例: + +```ts +import { fileIo as fs } from '@kit.CoreFileKit'; + +let sourceOptions: image.SourceOptions = { sourceDensity: 120 }; +const context: Context = getContext(); +//此处'test.jpg'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 +const filePath: string = context.filesDir + "/test.jpg"; +let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE); +const imageSourceApi: image.ImageSource = image.createImageSource(file.fd as int, sourceOptions); +``` + ## image.createImageSource9+ createImageSource(buf: ArrayBuffer): ImageSource -- Gitee