Skip to content

Commit

Permalink
Change Image load event size info from logical size to pixel (#45198)
Browse files Browse the repository at this point in the history
Summary:
Fixes #45188. This fixes old arch. fabric fix may wait until #44918.

## Changelog:

[IOS] [BREAKING] - Change Image load event size info from logical size to pixel

Pull Request resolved: #45198

Test Plan:
Android/iOS return the same size .
```
    <Image
      style={{width: '100%', height: '100%'}}
      source={{
        uri: 'https://image-placeholder.com/images/actual-size/75x75.png',
      }}
      resizeMode={'cover'}
      onLoad={e => {
        console.log(
          `RNImage:${Platform.OS} load JPEG image from url`,
          e.nativeEvent,
        );
      }}
    />
```

Reviewed By: cortinico

Differential Revision: D67735347

Pulled By: cipolleschi

fbshipit-source-id: 72422d8c15e4cc6313215bf6d9a2c1e6b5a235ad
  • Loading branch information
zhongwuzw authored and facebook-github-bot committed Dec 31, 2024
1 parent b10491a commit 09995fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/react-native/Libraries/Image/RCTImageView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ static BOOL RCTShouldReloadImageForSizeChange(CGSize currentSize, CGSize idealSi
{
NSDictionary *dict = @{
@"uri" : source.request.URL.absoluteString,
@"width" : @(source.size.width),
@"height" : @(source.size.height),
@"width" : @(source.size.width * source.scale),
@"height" : @(source.size.height * source.scale),
};
return @{@"source" : dict};
}
Expand Down Expand Up @@ -406,7 +406,7 @@ - (void)imageLoaderLoadedImage:(UIImage *)loadedImage
}
} else {
if (strongSelf->_onLoad) {
RCTImageSource *sourceLoaded = [source imageSourceWithSize:image.size scale:source.scale];
RCTImageSource *sourceLoaded = [source imageSourceWithSize:image.size scale:image.scale];
strongSelf->_onLoad(onLoadParamsForSource(sourceLoaded));
}
if (strongSelf->_onLoadEnd) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ void ImageEventEmitter::onLoad(const ImageSource& source) const {
dispatchEvent("load", [source](jsi::Runtime& runtime) {
auto src = jsi::Object(runtime);
src.setProperty(runtime, "uri", source.uri);
src.setProperty(runtime, "width", source.size.width);
src.setProperty(runtime, "height", source.size.height);
src.setProperty(runtime, "width", source.size.width * source.scale);
src.setProperty(runtime, "height", source.size.height * source.scale);
auto payload = jsi::Object(runtime);
payload.setProperty(runtime, "source", src);
return payload;
Expand Down

0 comments on commit 09995fc

Please sign in to comment.