diff --git a/react-native-harmony/Libraries/Image/AssetSourceResolver.harmony.ts b/react-native-harmony/Libraries/Image/AssetSourceResolver.harmony.ts index 3a70bcf0c94e56708b5c113cdca3c25c1be5f5bc..ac69e50be4067cdd782e37f412ba1152f0ea0119 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, }; } }