diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-image.md b/en/application-dev/reference/arkui-ts/ts-basic-components-image.md index 13d929c9352062c34fb75eb1bb39b3186c16a59a..8ae1b641b86f0946918759119ffc1cecfcd17d07 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -216,9 +216,9 @@ struct Index { } ``` -> **NOTE** -> -> For details about the request mode, timeout, and additional request parameters for loading online images, see [`request()`](../../reference/apis/js-apis-http.md) in the HTTP module. +> **NOTE** +> +> For details about the request mode, timeout, and additional request parameters for loading online images, see [`request()`](../../reference/apis/js-apis-http.md) in the HTTP module. ### Setting Attributes @@ -351,3 +351,57 @@ struct ImageExample3 { ``` ![en-us_image_0000001256858397](figures/en-us_image_0000001256858397.gif) + +### Rendering Sandbox Images + +```ts +import fileio from '@ohos.fileio' +import context from '@ohos.application.context' + +@Entry +@Component +struct LoadImageExample { + @State resourcesPath: string = '' + @State sandboxPath: string = '' + context: context.AbilityContext + + aboutToAppear() { + this.context = getContext(this) as context.AbilityContext + } + + build() { + Column() { + Button ('Read Sandbox Image') + .margin({ bottom: 10, top: 10 }) + .onClick(() => { + this.sandboxPath = this.context.getApplicationContext().filesDir + '/icon.png' + console.log(`Read the sandbox image=========>${this.sandboxPath}`) + let fd = fileio.openSync(this.sandboxPath, 0o100, 0o666) + console.log(`create file========>${fd}`) + let srcPath = this.context.bundleCodeDir + '/entry/resources/base/media/icon.png' + console.log('mySrcpath' + srcPath) + fileio.copyFileSync(srcPath, this.sandboxPath) // Copy the image to the sandbox path. + this.sandboxPath = 'file://' + this.context.getApplicationContext().filesDir + '/icon.png' + }) + Button ('Read Image') + .margin({ bottom: 10 }) + .onClick(() => { + this.resourcesPath = 'file://' + this.context.bundleCodeDir + '/entry/resources/base/media/icon.png' + }) + Text(`Image path: ${this.resourcesPath}`) + .fontSize(20) + .margin({ bottom: 10 }) + Image(this.resourcesPath) + .width(100) + .height(100) + Text(`Sandbox image path: ${this.sandboxPath}`) + .fontSize(20) + .margin({ bottom: 10 }) + Image(this.sandboxPath) + .width(100) + .height(100) + } + .width('100%').height('100%') + } +} +``` diff --git a/en/application-dev/reference/arkui-ts/ts-container-navigator.md b/en/application-dev/reference/arkui-ts/ts-container-navigator.md index c2596b7551b78f8d148c77f77386cc120057746c..e1d2c00f81527d3303b45031d858b76f9537099b 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-navigator.md +++ b/en/application-dev/reference/arkui-ts/ts-container-navigator.md @@ -78,7 +78,7 @@ import router from '@ohos.router' @Component struct DetailExample { // Receive the input parameters of Navigator.ets. - @State text: any = router.getParams().text + @State text: any = router.getParams()['text'] build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { diff --git a/en/application-dev/reference/arkui-ts/ts-pixel-units.md b/en/application-dev/reference/arkui-ts/ts-pixel-units.md index d595399e83fcac8822074b80a201e5855cf3f769..ecdaffd3f3407f079e1044031caaf43a9d2af843 100644 --- a/en/application-dev/reference/arkui-ts/ts-pixel-units.md +++ b/en/application-dev/reference/arkui-ts/ts-pixel-units.md @@ -3,12 +3,12 @@ The framework provides four pixel units, with vp as the reference data unit. -| Name| Description | -| ---- | ------------------------------------------------------------ | -| px | Physical pixel unit of the screen. | +| Name | Description | +| ---- | ---------------------------------------- | +| px | Physical pixel unit of the screen. | | vp | Pixel unit specific to the screen density. Pixels in this unit are converted into physical pixels of the screen based on the screen pixel density. This unit is used for values whose unit is not specified.| -| fp | Font pixel, which is similar to vp and varies according to the system font size.| -| lpx | Logical pixel unit of the window. It is the ratio of the actual screen width to the logical width (configured by **[designWidth](../../quick-start/package-structure.md)**). For example, if **designWidth** is set to **720** (default value), then 1lpx is equal to 2px for a screen with an actual width of 1440 physical pixels.| +| fp | Font pixel, which is similar to vp and varies according to the system font size. | +| lpx | Logical pixel unit of the window. It is the ratio of the actual screen width to the logical width (configured by **designWidth**. For example, if **designWidth** is set to **720** (default value), then 1lpx is equal to 2px for a screen with an actual width of 1440 physical pixels.| ## Pixel Unit Conversion