From cef9bfdd890a28dbf70ac19db96856c8ecac2b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8FJ?= Date: Thu, 20 Feb 2025 13:57:57 +0000 Subject: [PATCH] =?UTF-8?q?update=20react-native-harmony/Libraries/Image/A?= =?UTF-8?q?ssetSourceResolver.harmony.ts.=20=E9=80=82=E9=85=8D=20React-Nat?= =?UTF-8?q?ive=20=E6=A0=B9=E6=8D=AE=E8=AE=BE=E5=A4=87=20pixelRatio=20?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=AF=B9=E5=BA=94=E5=83=8F=E7=B4=A0=E5=AF=86?= =?UTF-8?q?=E5=BA=A6=E7=9A=84=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 小J --- .../Image/AssetSourceResolver.harmony.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/react-native-harmony/Libraries/Image/AssetSourceResolver.harmony.ts b/react-native-harmony/Libraries/Image/AssetSourceResolver.harmony.ts index 3a70bcf0..ac69e50b 100644 --- a/react-native-harmony/Libraries/Image/AssetSourceResolver.harmony.ts +++ b/react-native-harmony/Libraries/Image/AssetSourceResolver.harmony.ts @@ -1,11 +1,12 @@ import { getAssetDestRelativePath, Asset, -} from '@rnoh/react-native-harmony-cli/src/assetResolver'; +} from '@react-native-oh/react-native-harmony-cli/src/assetResolver'; import { getBasePath, } from '@react-native/assets-registry/path-support'; -import { Platform } from 'react-native'; +import { Platform, PixelRatio } from 'react-native'; +import { pickScale } from "react-native/Libraries/Image/AssetUtils" type ResolvedAssetSource = { readonly __packager_asset: boolean; @@ -17,7 +18,8 @@ type ResolvedAssetSource = { function getAssetPath(asset: Asset): string { const assetDir = getBasePath(asset); - return assetDir + '/' + asset.name + '.' + asset.type; + const scale = pickScale(asset.scales, PixelRatio.get()) + return assetDir + '/' + asset.name + (scale > 1 ? `@${scale}x` : '') + '.' + asset.type; } class AssetSourceResolver { @@ -65,12 +67,14 @@ class AssetSourceResolver { } fromSource(source: string): ResolvedAssetSource { + const scale = pickScale(this.asset.scales, PixelRatio.get()) + return { __packager_asset: true, - width: this.asset.width, - height: this.asset.height, + width: this.asset.width * scale, + height: this.asset.height * scale, uri: source, - scale: 1, + scale, }; } } -- Gitee