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 947ed5e48182f00b4b6d1f9a32456f6c81757c25..573ca40c216dbed085b94aba04b473db5bca55f0 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